def __requestForMoneyObtain(self, data): isTradeIn = data.tradeOff != -1 result = None if isTradeIn: tradeOffVehicle = self.itemsCache.items.getItemByCD(int(data.tradeOff)) confirmationType = 'tradeInConfirmation' addition = '' operations = [] if tradeOffVehicle.hasCrew: operations.append('crew') if tradeOffVehicle.hasShells: operations.append('shells') if tradeOffVehicle.hasEquipments: operations.append('equipments') if tradeOffVehicle.hasOptionalDevices: operations.append('optionalDevices') if operations: operationsStr = map(lambda o: i18n.makeString('#dialogs:%s/message/%s' % (confirmationType, o)), operations) addition = i18n.makeString('#dialogs:%s/message/addition' % confirmationType, operations=', '.join(operationsStr)) ctx = {'vehName': neutral(tradeOffVehicle.userName), 'addition': addition} result = yield showI18nConfirmDialog(confirmationType, meta=I18nConfirmDialogMeta(confirmationType, ctx, ctx), focusedID=DIALOG_BUTTON_ID.SUBMIT) if not result: return tradeOffVehicle = self.itemsCache.items.getItemByCD(int(data.tradeOff)) result = yield VehicleTradeInProcessor(self.vehicle, tradeOffVehicle, data.buySlot, data.buyAmmo, data.crewType).request() if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if not result.success: self.onWindowClose() return if data.buySlot: result = yield VehicleSlotBuyer(showConfirm=False, showWarning=False).request() if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if not result.success: return if not isTradeIn: if data.rentId != -1: result = yield VehicleRenter(self.vehicle, data.rentId, data.buyAmmo, data.crewType).request() else: result = yield self._getObtainVehicleProcessor(self.vehicle, data).request() if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if result and result.success: self.onWindowClose() return
def __requestForBuy(self, data): vehicle = g_itemsCache.items.getItem(GUI_ITEM_TYPE.VEHICLE, self.nationID, self.inNationID) if data.buySlot: result = yield VehicleSlotBuyer(showConfirm=False, showWarning=False).request() if len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType) if not result.success: return if data.rentId == -1: result = yield VehicleBuyer(vehicle, data.buySlot, data.buyAmmo, data.crewType).request() else: result = yield VehicleRenter(vehicle, data.rentId, data.buyAmmo, data.crewType).request() if len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType) self.as_setEnabledSubmitBtnS(True) if result.success: self.storeSettings(data.isHasBeenExpanded) self.onWindowClose()
def __requestForMoneyObtain(self, data): vehicle = g_itemsCache.items.getItem(GUI_ITEM_TYPE.VEHICLE, self.nationID, self.inNationID) if data.buySlot: result = yield VehicleSlotBuyer(showConfirm=False, showWarning=False).request() if len(result.userMsg): SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if not result.success: return if data.rentId != -1: result = yield VehicleRenter(vehicle, data.rentId, data.buyAmmo, data.crewType).request() else: result = yield self._getObtainVehicleProcessor(vehicle, data).request() if len(result.userMsg): SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if result.success: self.storeSettings(data.isHasBeenExpanded) self.onWindowClose()
def __buySlot(self): result = yield VehicleSlotBuyer().request() if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType)
def buySlot(self): result = yield VehicleSlotBuyer().request() if len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
def __requestForMoneyObtain(self): equipmentBlock = self.viewModel.equipmentBlock isTradeIn = self.__tradeOffVehicle is not None and not self.__isRentVisible isWithSlot = equipmentBlock.slot.getIsSelected() isWithAmmo = equipmentBlock.ammo.getIsSelected() if self.__isWithoutCommander: crewType = self.__CREW_NOT_SELECTED_IDX else: crewType = self.__selectedCardIdx result = None if isTradeIn: confirmationType = 'tradeInConfirmation' addition = '' operations = [] if self.__tradeOffVehicle.hasCrew: operations.append('crew') if self.__tradeOffVehicle.hasShells: operations.append('shells') if self.__tradeOffVehicle.hasEquipments: operations.append('equipments') if self.__tradeOffVehicle.hasOptionalDevices: operations.append('optionalDevices') if operations: operationsStr = [ i18n.makeString('#dialogs:%s/message/%s' % (confirmationType, o)) for o in operations ] addition = i18n.makeString('#dialogs:%s/message/addition' % confirmationType, operations=', '.join(operationsStr)) ctx = { 'vehName': neutral(self.__tradeOffVehicle.userName), 'addition': addition } self.__tradeinInProgress = True result = yield showI18nConfirmDialog( confirmationType, meta=I18nConfirmDialogMeta(confirmationType, ctx, ctx), focusedID=DIALOG_BUTTON_ID.SUBMIT) if not result: return result = yield VehicleTradeInProcessor(self.__vehicle, self.__tradeOffVehicle, isWithSlot, isWithAmmo, crewType).request() if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) self.__tradeinInProgress = False if not result.success: self.__onWindowClose() return if isWithSlot: result = yield VehicleSlotBuyer(showConfirm=False, showWarning=False).request() if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if not result.success: return if not isTradeIn: self.__purchaseInProgress = True emtySlotAvailable = self.itemsCache.items.inventory.getFreeSlots( self.__stats.vehicleSlots) > 0 if self.__isBuying(): if self.__vehicle.isRestoreAvailable(): result = yield self.getRestoreVehicleProcessor( crewType).request() else: result = yield self.__getObtainVehicleProcessor( crewType).request() if not emtySlotAvailable and not isWithSlot: self.__playSlotAnimation() else: result = yield VehicleRenter(self.__vehicle, self.__selectedRentTerm, isWithAmmo, crewType).request() if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) self.__purchaseInProgress = False self.__onItemCacheSyncCompleted() if result and result.success: self.__successOperation = True if self.__isRenting() or self.bootcamp.isInBootcamp(): self.__onWindowClose() else: self.__showCongratulations() return