def buyAndInstallItem(self, itemCD, state, inInventory = False): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) assert itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES vehicle = self._data.getRootItem() assert vehicle.isInInventory, 'Vehicle must be in inventory' item = self._data.getItem(itemCD) conflictedEqs = item.getConflictedEquipments(vehicle) if not inInventory: Waiting.show('buyItem') buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=conflictedEqs, install=True).request() Waiting.hide('buyItem') if len(buyResult.userMsg): SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType) if buyResult.success: item = self._data.getItem(itemCD) else: return else: RequestState.sent(state) if item.isInInventory: Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, item, conflictedEqs=conflictedEqs).request() if result and result.auxData: for m in result.auxData: SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType) if result and len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType) if result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): vehicle = g_itemsCache.items.getItemByCD(vehicle.intCD) yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('applyModule') RequestState.received(state)
def buyAndInstallItem(self, itemCD, state, inInventory = False): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID in _RESEARCH_ITEMS or AssertionError oldStyleVehicle = self._data.getInvItem(self._data.getRootCD()) if not oldStyleVehicle is not None: raise AssertionError, 'Vehicle has be in inventory' eqs = functions.findConflictedEquipments(itemCD, itemTypeID, oldStyleVehicle) item = g_itemsCache.items.getItemByCD(itemCD) vehicle = g_itemsCache.items.getItemByCD(self._data.getRootCD()) if not inInventory: Waiting.show('buyItem') buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=eqs, install=True).request() if len(buyResult.userMsg): SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType) Waiting.hide('buyItem') else: RequestState.sent(state) item = g_itemsCache.items.getItemByCD(itemCD) if item is not None and item.isInInventory: Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, item).request() success = result.success if result and result.auxData: for m in result.auxData: SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType) if result and len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType) success and itemTypeID in (_GUN, _TURRET) and self.tryLoadShells() Waiting.hide('applyModule') RequestState.received(state) return
def _doUnlockItem(self, unlockCD, vehCD, unlockIdx, xpCost, result): if result and self._validateItem2Unlock(unlockCD, vehCD, unlockIdx, xpCost): costCtx = self._getXPCostCtx(self._data.getVehXP(vehCD), xpCost) Waiting.show('research') RequestState.sent('unlock') BigWorld.player().stats.unlock(vehCD, unlockIdx, callback=partial( self.__cb_onUnlock, unlockCD, costCtx))
def installItem(self, itemCD, rootCD, state): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES or AssertionError vehicle = g_itemsCache.items.getItemByCD(rootCD) if not vehicle.isInInventory: raise AssertionError('Vehicle must be in inventory') item = g_itemsCache.items.getItemByCD(itemCD) conflictedEqs = item.getConflictedEquipments(vehicle) RequestState.sent(state) if item.isInInventory: Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, item, conflictedEqs=conflictedEqs).request() processMsg(result) vehicle = result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN) and g_itemsCache.items.getItemByCD(vehicle.intCD) yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('applyModule') RequestState.received(state) yield lambda callback = None: callback return
def buyAndInstallItem(self, itemCD, state, inInventory=False): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID in _RESEARCH_ITEMS or AssertionError oldStyleVehicle = self._data.getInvItem(self._data.getRootCD()) if not oldStyleVehicle is not None: raise AssertionError, 'Vehicle has be in inventory' eqs = functions.findConflictedEquipments(itemCD, itemTypeID, oldStyleVehicle) item = g_itemsCache.items.getItemByCD(itemCD) vehicle = g_itemsCache.items.getItemByCD(self._data.getRootCD()) if not inInventory: Waiting.show('buyItem') buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=eqs, install=True).request() if len(buyResult.userMsg): SystemMessages.g_instance.pushI18nMessage( buyResult.userMsg, type=buyResult.sysMsgType) Waiting.hide('buyItem') else: RequestState.sent(state) item = g_itemsCache.items.getItemByCD(itemCD) if item is not None and item.isInInventory: Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, item).request() success = result.success if result and result.auxData: for m in result.auxData: SystemMessages.g_instance.pushI18nMessage( m.userMsg, type=m.sysMsgType) if result and len(result.userMsg): SystemMessages.g_instance.pushI18nMessage( result.userMsg, type=result.sysMsgType) success and itemTypeID in (_GUN, _TURRET) and self.tryLoadShells() Waiting.hide('applyModule') RequestState.received(state) return
def buyAndInstallItem(self, itemCD, rootCD, state, inInventory = False): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES or AssertionError vehicle = g_itemsCache.items.getItemByCD(rootCD) if not vehicle.isInInventory: raise AssertionError('Vehicle must be in inventory') item = g_itemsCache.items.getItemByCD(itemCD) conflictedEqs = item.getConflictedEquipments(vehicle) if not inInventory: if not self._canBuy(item) and self._canBuyWithExchange(item): isOk, args = yield DialogsInterface.showDialog(ExchangeCreditsMeta(itemCD)) if not isOk: return if self._canBuy(item): Waiting.show('buyItem') buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=conflictedEqs, install=True).request() Waiting.hide('buyItem') if len(buyResult.userMsg): SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType) if buyResult.success: item = g_itemsCache.items.getItemByCD(itemCD) else: return else: RequestState.sent(state) if item.isInInventory: Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, item, conflictedEqs=conflictedEqs).request() if result and result.auxData: for m in result.auxData: SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType) if result and len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType) vehicle = result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN) and g_itemsCache.items.getItemByCD(vehicle.intCD) yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('applyModule') RequestState.received(state) yield lambda callback = None: callback return
def _request(self, callback): RequestState.sent('unlock') BigWorld.player().stats.unlock(self.vehTypeCD, self.unlockIdx, lambda code: self._response(code, callback))
def _doUnlockItem(self, unlockCD, vehCD, unlockIdx, xpCost, result): if result and self._validateItem2Unlock(unlockCD, vehCD, unlockIdx, xpCost): costCtx = self._getXPCostCtx(self._data.getVehXP(vehCD), xpCost) Waiting.show('research') RequestState.sent('unlock') BigWorld.player().stats.unlock(vehCD, unlockIdx, callback=partial(self.__cb_onUnlock, unlockCD, costCtx))