def buyAndInstallItem(self, itemCD, rootCD, state): itemTypeID, _, __ = vehicles.parseIntCompactDescr(itemCD) if itemTypeID not in GUI_ITEM_TYPE.VEHICLE_MODULES: raise SoftException('Specified type (itemTypeID={}) is not type of module'.format(itemTypeID)) vehicle = self.itemsCache.items.getItemByCD(rootCD) if not vehicle.isInInventory: raise SoftException('Vehicle (intCD={}) must be in inventory'.format(rootCD)) item = self.itemsCache.items.getItemByCD(itemCD) conflictedEqs = item.getConflictedEquipments(vehicle) if not self._mayObtainForMoney(item) and self._mayObtainWithMoneyExchange(item): isOk, _ = yield DialogsInterface.showDialog(ExchangeCreditsMeta(itemCD, vehicle.intCD)) if not isOk: return if self._mayObtainForMoney(item): Waiting.show('buyAndInstall') vehicle = self.itemsCache.items.getItemByCD(rootCD) gunCD = getGunCD(item, vehicle) result = yield BuyAndInstallItemProcessor(vehicle, item, 0, gunCD, conflictedEqs=conflictedEqs, skipConfirm=self.skipConfirm).request() processMsg(result) if result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): item = self.itemsCache.items.getItemByCD(itemCD) vehicle = self.itemsCache.items.getItemByCD(rootCD) if item.isInstalled(vehicle): yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('buyAndInstall') RequestState.received(state) yield lambda callback=None: callback return
def doAction(self): item = self.itemsCache.items.getItemByCD(self.__vehCD) if item.itemTypeID is not GUI_ITEM_TYPE.VEHICLE: LOG_ERROR('Value of int-type descriptor is not refer to vehicle', self.__vehCD) return else: if item.isInInventory and not item.isRented: showInventoryMsg('already_exists', item, msgType=SystemMessages.SM_TYPE.Warning) else: price = getGUIPrice(item, self.itemsCache.items.stats.money, self.itemsCache.items.shop.exchangeRate) if price is None: showShopMsg('not_found', item) return if not self._mayObtainForMoney(item): if self._mayObtainWithMoneyExchange(item): if item.isRestoreAvailable(): meta = RestoreExchangeCreditsMeta(self.__vehCD) else: meta = ExchangeCreditsMeta(self.__vehCD) isOk, _ = yield DialogsInterface.showDialog(meta) if not isOk: return else: showShopMsg('common_rent_or_buy_error', item) if self._mayObtainForMoney(item): shared_events.showVehicleBuyDialog(item, self.__isTradeIn) yield lambda callback=None: callback return
def buyAndInstallItem(self, itemCD, rootCD, state): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) assert itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES vehicle = g_itemsCache.items.getItemByCD(rootCD) assert vehicle.isInInventory, 'Vehicle must be in inventory' item = g_itemsCache.items.getItemByCD(itemCD) conflictedEqs = item.getConflictedEquipments(vehicle) if not self._canBuy(item) and self._canBuyWithExchange(item): isOk, args = yield DialogsInterface.showDialog(ExchangeCreditsMeta(itemCD, vehicle.intCD)) if not isOk: return if self._canBuy(item): Waiting.show('buyAndInstall') vehicle = g_itemsCache.items.getItemByCD(rootCD) gunCD = getGunCD(item, vehicle) result = yield BuyAndInstallItemProcessor(vehicle, item, 0, gunCD, conflictedEqs=conflictedEqs).request() processMsg(result) if result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): item = g_itemsCache.items.getItemByCD(itemCD) vehicle = g_itemsCache.items.getItemByCD(rootCD) if item.isInstalled(vehicle): yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('buyAndInstall') RequestState.received(state) yield lambda callback = None: callback
def doAction(self): item = g_itemsCache.items.getItemByCD(self.__vehCD) if item.itemTypeID is not GUI_ITEM_TYPE.VEHICLE: LOG_ERROR('Value of int-type descriptor is not refer to vehicle', self.__vehCD) return else: if item.isInInventory and not item.isRented: showInventoryMsg('already_exists', item, msgType=SystemMessages.SM_TYPE.Warning) else: price = item.minRentPrice or item.buyPrice if price is None: showShopMsg('not_found', item) return if not self._canRentOrBuy(item): if self._canBuyWithExchange(item): isOk, args = yield DialogsInterface.showDialog( ExchangeCreditsMeta(self.__vehCD)) if not isOk: return else: showShopMsg('common_rent_or_buy_error', item) if self._canRentOrBuy(item): shared_events.showVehicleBuyDialog(item) yield lambda callback=None: callback return
def doAction(self): vehicle = self.itemsCache.items.getVehicle(self.__vehInvID) if vehicle is None: return else: isUseMoney = self.__isRemove and self.__oldItemCD is not None LOG_DEBUG('isUseMoney, self.__isRemove, self.__oldItemCD', isUseMoney, self.__isRemove, self.__oldItemCD) newComponentItem = self.itemsCache.items.getItemByCD(int(self.__newItemCD)) if newComponentItem is None: return oldComponentItem = None if self.__oldItemCD: oldComponentItem = self.itemsCache.items.getItemByCD(int(self.__oldItemCD)) if not self.__isRemove: if oldComponentItem and oldComponentItem.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.BATTLE_BOOSTER): Waiting.show('installEquipment') result = yield getInstallerProcessor(vehicle, oldComponentItem, self.__slotIdx, False, True, skipConfirm=self.skipConfirm).request() processMsg(result) Waiting.hide('installEquipment') if not result.success: return if not self.__isRemove and not newComponentItem.isInInventory and not newComponentItem.itemTypeID == GUI_ITEM_TYPE.BATTLE_ABILITY: conflictedEqs = newComponentItem.getConflictedEquipments(vehicle) if not self._mayObtainForMoney(newComponentItem) and self._mayObtainWithMoneyExchange(newComponentItem): isOk, _ = yield DialogsInterface.showDialog(ExchangeCreditsMeta(newComponentItem.intCD, vehicle.intCD)) if not isOk: return if self._mayObtainForMoney(newComponentItem): Waiting.show('buyAndInstall') vehicle = self.itemsCache.items.getVehicle(self.__vehInvID) gunCD = getGunCD(newComponentItem, vehicle) result = yield BuyAndInstallItemProcessor(vehicle, newComponentItem, self.__slotIdx, gunCD, conflictedEqs=conflictedEqs, skipConfirm=self.skipConfirm).request() processMsg(result) if result.success and newComponentItem.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): newComponentItem = self.itemsCache.items.getItemByCD(int(self.__newItemCD)) vehicle = self.itemsCache.items.getItemByCD(vehicle.intCD) if newComponentItem.isInstalled(vehicle): yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('buyAndInstall') else: yield lambda callback=None: callback else: Waiting.show('applyModule') conflictedEqs = newComponentItem.getConflictedEquipments(vehicle) result = yield getInstallerProcessor(vehicle, newComponentItem, self.__slotIdx, not self.__isRemove, isUseMoney, conflictedEqs, self.skipConfirm).request() processMsg(result) if result.success and newComponentItem.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): newComponentItem = self.itemsCache.items.getItemByCD(int(self.__newItemCD)) vehicle = self.itemsCache.items.getItemByCD(vehicle.intCD) if newComponentItem.isInstalled(vehicle): yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('applyModule') return
def doAction(self): item = g_itemsCache.items.getItemByCD(self.__intCD) if not self._canBuy(item): if self._canBuyWithExchange(item): isOk, args = yield DialogsInterface.showDialog(ExchangeCreditsMeta(self.__intCD)) if not isOk: return else: showShopMsg('common_rent_or_buy_error', item) if self._canBuy(item): yield DialogsInterface.showDialog(BuyModuleMeta(self.__intCD, g_itemsCache.items.stats.money)) else: yield lambda callback = None: callback