def __doSellVehicle(self, vehicle, shells, eqs, optDevs, inventory, isDismissCrew): shop = yield ShopRequester().request() result = yield VehicleSeller(vehicle, shop.paidRemovalCost, shells, eqs, optDevs, inventory, isDismissCrew).request() if len(result.userMsg): SystemMessages.g_instance.pushMessage(result.userMsg, type=result.sysMsgType)
def buyBerths(self): stats = yield StatsRequesterr().request() shop = yield ShopRequester().request() berthPrice, berthsCount = shop.getTankmanBerthPrice( stats.tankmenBerthsCount) result = yield TankmanBerthsBuyer((0, berthPrice), berthsCount).request() if len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
def __init__(self): super(ItemsCache, self).__init__() goodies = GoodiesRequester() self.__items = ItemsRequester.ItemsRequester( InventoryRequester(), StatsRequester(), DossierRequester(), goodies, ShopRequester(goodies), RecycleBinRequester(), VehicleRotationRequester(), RankedRequester()) self.__waitForSync = False self.onSyncStarted = Event() self.onSyncCompleted = Event()
def __init__(self): super(ItemsCache, self).__init__() goodies = GoodiesRequester() self.__items = ItemsRequester.ItemsRequester( InventoryRequester(), StatsRequester(), DossierRequester(), goodies, ShopRequester(goodies), RecycleBinRequester(), VehicleRotationRequester(), RankedRequester(), BattleRoyaleRequester(), BadgesRequester(), EpicMetaGameRequester(), TokensRequester(), dependency.instance(IFestivityFactory).getRequester(), BlueprintsRequester(), SessionStatsRequester(), AnonymizerRequester()) self.__compatVehiclesCache = CompatVehiclesCache() self.__waitForSync = False self.__syncFailed = False self.onSyncStarted = Event() self.onSyncCompleted = Event() self.onSyncFailed = Event()
def populateTechnicalMaintenanceEquipment(self, eId1=None, currency1=None, eId2=None, currency2=None, eId3=None, currency3=None, slotIndex=None): shopRqs = yield ShopRequester().request() goldEqsForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits credits, gold = g_itemsCache.items.stats.money myVehicles = yield Requester('vehicle').getFromInventory() modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems( ['equipment']) oldStyleVehicle = None for v in myVehicles: if v.inventoryId == g_currentVehicle.invID: oldStyleVehicle = v break newStyleVehicle = g_currentVehicle.item availableData = yield AvailableItemsRequester(oldStyleVehicle, 'equipment').request() shopEqs = yield Requester('equipment').getFromShop() invEqs = yield Requester('equipment').getFromInventory() eqs = oldStyleVehicle.equipmentsLayout def getShopModule(module): for eq in shopEqs: if eq == module: return eq return None def getInventoryModule(module): for eq in invEqs: if eq == module: return eq return None def getModuleByCD(compactDescr): for eq in availableData: if eq.compactDescr == compactDescr: return eq return None installed = [m for m in availableData if m.isCurrent] currencies = [None, None, None] if eId1 is not None or eId2 is not None or eId3 is not None or slotIndex is not None: installed = [ getModuleByCD(id) for id in (eId1, eId2, eId3) if id is not None ] currencies = [currency1, currency2, currency3] data = [] for item in availableData: if item in installed: invEq = getInventoryModule(item) shopModule = getShopModule(item) i = InventoryItem( itemTypeName='equipment', compactDescr=item.compactDescr, count=invEq.count if invEq is not None else 0, priceOrder=shopModule.priceOrder if shopModule is not None else (0, 0)) if item == getModuleByCD(eId1): i.index = 0 elif item == getModuleByCD(eId2): i.index = 1 elif item == getModuleByCD(eId3): i.index = 2 else: i.index = item.index i.isCurrent = True elif isinstance(item, InventoryItem): i = InventoryItem(itemTypeName='equipment', compactDescr=item.compactDescr, count=item.count, priceOrder=item.priceOrder) else: i = item data.append(i) unlocks = [m for m in data if m.isCurrent] data.sort(reverse=True) installed = [0, 0, 0] for m in availableData: if m.isCurrent: installed[m.index] = m.compactDescr setup = [0, 0, 0] modules = [] if len(eqs): setup = eqs for module in data: vehCount = 0 try: vehCount = modulesAllVehicle[modulesAllVehicle.index( module)].count except Exception: pass invCount = 0 try: invCount = invEqs[invEqs.index(module)].count except Exception: pass shopModule = getShopModule(module) price = (yield shopModule.getPrice()) if shopModule is not None else (0, 0) if goldEqsForCredits: price = (price[0] + price[1] * shopRqs.exchangeRateForShellsAndEqs, price[1]) priceCurrency = 'gold' if not price[1]: priceCurrency = 'credits' elif goldEqsForCredits and module.index is not None: if module.index < len(eqs) and eqs[module.index] < 0: priceCurrency = 'credits' elif currencies[module.index] is not None: priceCurrency = currencies[module.index] fits = [] for i in xrange(3): fits.append( isModuleFitVehicle(module, newStyleVehicle, price, (credits, gold), unlocks, i)[1]) modules.append({ 'id': compactItem(module), 'name': module.name, 'desc': getShortDescr(module.getTableName(oldStyleVehicle)), 'target': module.target, 'compactDescr': module.compactDescr, 'prices': list(price)[:2], 'currency': priceCurrency, 'icon': module.icon, 'index': module.index, 'inventoryCount': invCount, 'vehicleCount': vehCount, 'count': module.count if isinstance(module, InventoryItem) else 0, 'fits': fits, 'goldEqsForCredits': goldEqsForCredits }) self.as_setEquipmentS(installed, setup, modules) return
def populateTechnicalMaintenance(self): shopRqs = yield ShopRequester().request() statsRqs = yield StatsRequesterr().request() goldShellsForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits data = {'gold': statsRqs.gold, 'credits': statsRqs.credits} if g_currentVehicle.isPresent(): iVehicles = yield Requester('vehicle').getFromInventory() for v in iVehicles: if v.inventoryId == g_currentVehicle.invID: vehicle = v break gun = VehicleItem(vehicle.descriptor.gun) iAmmo = yield Requester('shell').getFromInventory() sAmmo = yield Requester('shell').getFromShop() casseteCount = vehicle.descriptor.gun['clip'][0] data.update({ 'vehicleId': vehicle.pack(), 'repairCost': vehicle.repairCost, 'maxRepairCost': vehicle.descriptor.getMaxRepairCost(), 'autoRepair': vehicle.isAutoRepair, 'maxAmmo': gun.descriptor['maxAmmo'], 'casseteFieldText': '' if casseteCount == 1 else makeString('#menu:technicalMaintenance/ammoTitleEx') % casseteCount, 'shells': [] }) shells = data.get('shells') for shell in vehicle.shells: shopShell = sAmmo[sAmmo.index( shell)] if shell in sAmmo else None if shopShell: iCount = iAmmo[iAmmo.index( shell)].count if shell in iAmmo else 0 sPrice = (yield shopShell.getPrice() ) if shell is not shopShell else (0, 0) if goldShellsForCredits: sPrice = ( sPrice[0] + sPrice[1] * shopRqs.exchangeRateForShellsAndEqs, sPrice[1]) priceCurrency = 'gold' if sPrice[ 1] == 0 or goldShellsForCredits and shell.boughtForCredits: priceCurrency = 'credits' buyCount = max(shell.default - iCount - shell.count, 0) shells.append({ 'id': compactItem(shopShell), 'compactDescr': shopShell.compactDescr, 'type': shell.type, 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0], 'count': shell.count, 'userCount': shell.default, 'step': casseteCount, 'inventoryCount': iCount, 'goldShellsForCredits': goldShellsForCredits, 'prices': list(sPrice)[:2], 'currency': priceCurrency, 'ammoName': shell.longName, 'tableName': shell.tableName, 'maxAmmo': gun.descriptor['maxAmmo'] }) data.update({ 'autoShells': vehicle.isAutoLoad, 'autoEqip': vehicle.isAutoEquip }) self.as_setDataS(data) return
def requestTableData(self, nation, type, filter): Waiting.show('updateShop') AccountSettings.setFilter('shop_current', (nation, type)) AccountSettings.setFilter('shop_' + type, filter) nation = int(nation) if nation >= 0 else None if nation is not None: nation = getNationIndex(nation) filter = list(filter) requestType = [type] checkFits = None checkFitsArtefacts = None checkExtra = False modulesFits = {} vehicleFits = [] extra = [] modulesAllVehicle = [] if type == self._MODULE: typeSize = int(filter.pop(0)) requestType = filter[0:typeSize] filter = filter[typeSize:] fitsType = filter.pop(0) compact = filter.pop(0) if compact == '0': LOG_ERROR('compact value has invalid value: ', compact) Waiting.hide('updateShop') return fitsVehicle = getItemByCompact(compact) checkExtra = True extra = filter[:] checkFits = True if fitsType != 'otherVehicles' else None myVehicles = yield Requester(self._VEHICLE).getFromInventory() modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems( requestType) if fitsType == 'myVehicle': for rType in requestType: modulesFits.update( _getComponentsByType(fitsVehicle, ITEM_TYPE_INDICES[rType])) elif fitsType != 'otherVehicles': for vehicle in myVehicles: for rType in requestType: modulesFits.update( _getComponentsByType(vehicle, ITEM_TYPE_INDICES[rType])) filter = requestType elif type == self._SHELL: filterSize = int(filter.pop(0)) fitsType = filter.pop(filterSize) compact = filter.pop(filterSize) if compact == '0': LOG_ERROR('compact value has invalid value: ', compact) Waiting.hide('updateShop') return fitsVehicle = getItemByCompact(compact) checkFits = True if fitsType != 'otherGuns' else None if fitsType == 'myVehicleGun': for shoot in fitsVehicle.descriptor.gun['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True elif fitsType == 'myInventoryGuns': myGuns = yield Requester('vehicleGun').getFromInventory() for gun in myGuns: for shoot in gun.descriptor['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True elif fitsType != 'otherGuns': myGuns = yield Requester('vehicleGun').getFromInventory() for gun in myGuns: for shoot in gun.descriptor['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True myVehicles = yield Requester(self._VEHICLE).getFromInventory() for vehicle in myVehicles: for shoot in vehicle.descriptor.gun['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True elif type == self._VEHICLE: filterSize = int(filter.pop(0)) extra = filter[filterSize:] checkExtra = True filter = filter[0:filterSize] else: fitsType = filter.pop(0) compact = filter.pop(0) if compact == '0': LOG_ERROR('compact value has invalid value: ', compact) Waiting.hide('updateShop') return fitsVehicle = getItemByCompact(compact) extra = filter checkExtra = type in (self._OPTIONAL_DEVICE, self._EQUIPMENT) checkFitsArtefacts = True if fitsType != 'otherVehicles' else None myVehicles = yield Requester(self._VEHICLE).getFromInventory() modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems( requestType) if fitsType == 'myVehicle': vehicleFits = [fitsVehicle] elif fitsType != 'otherVehicles': vehicleFits = [v for v in myVehicles if v.nation == nation ] if nation != None else myVehicles filter = requestType filter = map(lambda w: w.lower(), filter) modulesAll = list() modulesAllInventory = list() for rType in requestType: inv = yield Requester(rType).getFromInventory() modulesAllInventory.extend(inv) shp = yield Requester(rType).getFromShop(nation=nation) modulesAll.extend(shp) unlocks = yield StatsRequester().getUnlocks() shopRqs = yield ShopRequester().request() self.__clearTableData() self.__tableData = [type] modulesAll.sort() for module in modulesAll: extraModuleInfo = None if module.hidden: continue if module.type.lower() not in filter: continue if checkFits is not None: if (module.compactDescr in modulesFits.keys()) != checkFits: continue if checkFitsArtefacts is not None: for veh in vehicleFits: if module.descriptor.checkCompatibilityWithVehicle( veh.descriptor)[0] == checkFitsArtefacts: break else: continue if module.isClipGun(): extraModuleInfo = CLIP_ICON_PATH inventoryCount = 0 vehicleCount = 0 installedIn = '' if module in modulesAllInventory: inventoryCount = 1 if type != self._VEHICLE: inventoryModule = modulesAllInventory[ modulesAllInventory.index(module)] inventoryCount = inventoryModule.count if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and module in modulesAllVehicle: vehModule = modulesAllVehicle[modulesAllVehicle.index(module)] vehicleCount = vehModule.count installedIn = ', '.join( [v.shortName for v in vehModule.vehicles]) if checkExtra: if 'locked' not in extra: if type == self._VEHICLE: compdecs = module.descriptor.type.compactDescr if compdecs not in unlocks: continue elif type not in (self._SHELL, self._OPTIONAL_DEVICE, self._EQUIPMENT ) and module.compactDescr not in unlocks: continue if 'inHangar' not in extra and type not in ( self._OPTIONAL_DEVICE, self._EQUIPMENT): if inventoryCount > 0: continue if 'onVehicle' not in extra: if vehicleCount > 0: continue disabled = '' if type == self._VEHICLE: if BigWorld.player().isLongDisconnectedFromCenter: disabled = MENU.SHOP_ERRORS_CENTERISDOWN if inventoryCount > 0: disabled = MENU.SHOP_ERRORS_INHANGAR else: compdecs = module.descriptor.type.compactDescr if compdecs not in unlocks: disabled = MENU.SHOP_ERRORS_UNLOCKNEEDED elif type not in ( self._SHELL, self._OPTIONAL_DEVICE, self._EQUIPMENT) and module.compactDescr not in unlocks: disabled = MENU.SHOP_ERRORS_UNLOCKNEEDED if not (shopRqs.isEnabledBuyingGoldShellsForCredits and module.itemTypeName == 'shell'): goldAmmoForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits and module.itemTypeName == 'equipment' module.priceOrder = goldAmmoForCredits and ( module.priceOrder[0] + module.priceOrder[1] * shopRqs.exchangeRateForShellsAndEqs, module.priceOrder[1]) valueElement = { 'id': compactItem(module), 'name': module.name if type in (self._OPTIONAL_DEVICE, self._EQUIPMENT) else module.longName, 'desc': getShortDescr(module.tableName), 'inventoryId': None, 'inventoryCount': inventoryCount, 'vehicleCount': vehicleCount, 'credits': module.priceOrder[0], 'gold': module.priceOrder[1], 'price': module.priceOrder, 'currency': 'credits' if module.priceOrder[1] == 0 else 'gold', 'level': module.level, 'nation': module.nation, 'type': module.itemTypeName if type not in (self._VEHICLE, self._OPTIONAL_DEVICE, self._SHELL, self._EQUIPMENT) else module.icon, 'disabled': disabled, 'statusLevel': InventoryVehicle.STATE_LEVEL.WARNING, 'removable': module.descriptor['removable'] if type == self._OPTIONAL_DEVICE else True, 'tankType': module.type if type == self._VEHICLE else type, 'isPremium': module.isPremium if type == self._VEHICLE else False, 'isElite': self.app.tooltipManager.isVehicleElite(module) if type == self._VEHICLE else False, 'itemTypeName': module.itemTypeName, 'goldShellsForCredits': shopRqs.isEnabledBuyingGoldShellsForCredits, 'goldEqsForCredits': shopRqs.isEnabledBuyingGoldEqsForCredits, EXTRA_MODULE_INFO: extraModuleInfo } self.__tableData.append(valueElement) requester = yield StatsRequesterr().request() self._table.as_setGoldS(requester.gold) self._table.as_setCreditsS(requester.credits) self._table.as_setTableS(self.__tableData) Waiting.hide('updateShop') return
def requestTableData(self, nation, type, filter): Waiting.show('updateInventory') AccountSettings.setFilter('inventory_current', (nation, type)) AccountSettings.setFilter('inventory_' + type, filter) nation = int(nation) if nation >= 0 else None if nation is not None: nation = getNationIndex(nation) filter = list(filter) requestType = [type] checkFits = None checkFitsArtefacts = None checkExtra = False modulesFits = {} vehicleFits = [] extra = [] modulesAllVehicle = [] if type == self._MODULE: typeSize = int(filter.pop(0)) requestType = filter[0:typeSize] filter = filter[typeSize:] fitsType = filter.pop(0) fitsVehicle = getItemByCompact(filter.pop(0)) checkExtra = True extra = filter[:] checkFits = True if fitsType != 'otherVehicles' else False myVehicles = yield Requester(self._VEHICLE).getFromInventory() modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(requestType) if fitsType == 'myVehicle': if fitsVehicle: for rType in requestType: modulesFits.update(_getComponentsByType(fitsVehicle, ITEM_TYPE_INDICES[rType])) else: for vehicle in myVehicles: for rType in requestType: modulesFits.update(_getComponentsByType(vehicle, ITEM_TYPE_INDICES[rType])) filter = requestType elif type == self._SHELL: filterSize = int(filter.pop(0)) fitsType = filter.pop(filterSize) fitsVehicle = getItemByCompact(filter.pop(filterSize)) checkFits = True if fitsType != 'otherGuns' else False if fitsType == 'myVehicleGun': for shoot in fitsVehicle.descriptor.gun['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True elif fitsType == 'myInventoryGuns': myGuns = yield Requester('vehicleGun').getFromInventory() for gun in myGuns: for shoot in gun.descriptor['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True else: myGuns = yield Requester('vehicleGun').getFromInventory() for gun in myGuns: for shoot in gun.descriptor['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True myVehicles = yield Requester(self._VEHICLE).getFromInventory() for vehicle in myVehicles: for shoot in vehicle.descriptor.gun['shots']: modulesFits[shoot[self._SHELL]['compactDescr']] = True elif type == self._VEHICLE: filterSize = int(filter.pop(0)) extra = filter[filterSize:] checkExtra = True filter = filter[0:filterSize] else: fitsType = filter.pop(0) compact = filter.pop(0) fitsVehicle = getItemByCompact(compact) extra = filter checkExtra = type in (self._OPTIONAL_DEVICE, self._EQUIPMENT) checkFitsArtefacts = True if fitsType != 'otherVehicles' else False myVehicles = yield Requester(self._VEHICLE).getFromInventory() modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(requestType) if fitsType == 'myVehicle': vehicleFits = [fitsVehicle] else: vehicleFits = myVehicles filter = requestType filter = map(lambda w: w.lower(), filter) modulesAll = list() modulesShop = list() for rType in requestType: inv = yield Requester(rType).getFromInventory() shp = yield Requester(rType).getFromShop() modulesShop.extend(shp) modulesAll.extend(inv) vehPrices = {} if type == self._VEHICLE: compactDescrs = [ v.compactDescr for v in modulesAll ] vehPrices = yield StatsRequester().getVehiclesPrices(compactDescrs) vehPrices = dict(zip(compactDescrs, vehPrices)) if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT): for vehModule in modulesAllVehicle: if vehModule not in modulesAll: if modulesShop.count(vehModule) != 0: modulesAll.append(vehModule) self.__clearTableData() self.__tableData = [type] excludeModules = [] for module in modulesAll: if modulesShop.count(module) != 0: module.priceOrder = modulesShop[modulesShop.index(module)].priceOrder elif constants.IS_DEVELOPMENT: excludeModules.append(module) LOG_ERROR("Not found module %s '%s' (%r) in shop." % (module.type, module.unicName, module.compactDescr)) modulesAll.sort() shopRqs = yield ShopRequester().request() for module in modulesAll: extraModuleInfo = None if module in excludeModules: continue if nation is not None: if module.nation != nation and module.nation != nations.NONE_INDEX: continue if module.type.lower() not in filter: continue if checkFits is not None: if (module.compactDescr in modulesFits.keys()) != checkFits: continue if module.isClipGun(): extraModuleInfo = CLIP_ICON_PATH if checkFitsArtefacts is not None: compatible = False for veh in vehicleFits: if nation is not None and veh.nation != nation: continue compatible |= module.descriptor.checkCompatibilityWithVehicle(veh.descriptor)[0] if compatible != checkFitsArtefacts: continue inventoryCount = 0 vehicleCount = 0 if isinstance(module, VehicleItem): vehicleCount = module.count else: inventoryCount = module.count if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and module in modulesAllVehicle: vehModule = modulesAllVehicle[modulesAllVehicle.index(module)] vehicleCount = vehModule.count if checkExtra: if type == self._VEHICLE and 'brocken' not in extra: if module.repairCost > 0: continue if type == self._VEHICLE and 'locked' not in extra: if module.lock != 0: continue if 'onVehicle' not in extra: if vehicleCount > 0 and inventoryCount == 0: continue disable = '' if type == self._VEHICLE and not module.canSell: disable = makeString(MENU.tankcarousel_vehiclestates(module.getState())) elif type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and isinstance(module, VehicleItem): if type == self._OPTIONAL_DEVICE: if not module.descriptor['removable']: disable = makeString(MENU.INVENTORY_DEVICE_ERRORS_NOT_REMOVABLE) else: disable = makeString(MENU.INVENTORY_DEVICE_ERRORS_RESERVED) else: disable = makeString(MENU.INVENTORY_ERRORS_RESERVED) sellPrice = isinstance(module, InventoryVehicle) and vehPrices.get(module.compactDescr, (0, 0)) else: sellPrice = (0, 0) item = g_itemsCache.items.getItemByCD(module.compactDescr) if item is not None: sellPrice = item.sellPrice valueElement = {'id': compactItem(module), 'name': module.name if type in (self._OPTIONAL_DEVICE, self._EQUIPMENT) else module.longName, 'desc': getShortDescr(module.tableName), 'inventoryId': module.inventoryId if isinstance(module, InventoryVehicle) else None, 'inventoryCount': inventoryCount, 'vehicleCount': vehicleCount, 'credits': sellPrice[0], 'gold': sellPrice[1], 'price': sellPrice, 'currency': 'credits' if sellPrice[1] == 0 else 'gold', 'level': module.level, 'nation': module.nation, 'type': module.itemTypeName if type not in (self._VEHICLE, self._OPTIONAL_DEVICE, self._SHELL, self._EQUIPMENT) else module.icon, 'disabled': disable, 'statusLevel': module.getStateLevel() if isinstance(module, InventoryVehicle) else InventoryVehicle.STATE_LEVEL.INFO, 'removable': module.descriptor['removable'] if type == self._OPTIONAL_DEVICE else True, 'tankType': module.type if type == self._VEHICLE else type, 'isPremium': module.isPremium if type == self._VEHICLE else False, 'isElite': self.app.tooltipManager.isVehicleElite(module) if type == self._VEHICLE else False, 'itemTypeName': module.itemTypeName, 'goldShellsForCredits': shopRqs.isEnabledBuyingGoldShellsForCredits, 'goldEqsForCredits': shopRqs.isEnabledBuyingGoldEqsForCredits, EXTRA_MODULE_INFO: extraModuleInfo} self.__tableData.append(valueElement) requester = yield StatsRequesterr().request() self._table.as_setGoldS(requester.gold) self._table.as_setCreditsS(requester.credits) self._table.as_setTableS(self.__tableData) Waiting.hide('updateInventory') return
def __updateAmmo(self): Waiting.show('updateAmmo') credits = g_itemsCache.items.stats.credits shopRqs = yield ShopRequester().request() ammo = {'gunName': '', 'maxAmmo': 0, 'reserved1': False, 'reserved2': False, 'defaultAmmoCount': 0, 'reserved3': 0, 'vehicleLocked': True, 'stateMsg': '', 'stateLevel': 'info', 'shells': [], 'stateWarning': 0} if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item default_ammo_count = 0 default_ammo = dict(((s.intCD, s.defaultCount) for s in vehicle.shells)) stateWarning = vehicle.isBroken or not vehicle.isCrewFull or not vehicle.isAmmoFull or not g_currentVehicle.isAutoLoadFull() or not g_currentVehicle.isAutoEquipFull() for compactDescr, count in default_ammo.iteritems(): default_ammo_count += count msg, msgLvl = g_currentVehicle.getHangarMessage() ammo.update({'gunName': vehicle.gun.longUserName, 'maxAmmo': vehicle.ammoMaxSize, 'reserved1': not g_currentVehicle.isLocked(), 'reserved2': not g_currentVehicle.isBroken(), 'defaultAmmoCount': default_ammo_count, 'reserved3': 0, 'vehicleLocked': g_currentVehicle.isLocked(), 'stateMsg': msg, 'stateLevel': msgLvl, 'stateWarning': int(stateWarning)}) iAmmo = yield Requester('shell').getFromInventory() sAmmo = yield Requester('shell').getFromShop() iVehicles = yield Requester('vehicle').getFromInventory() oldStyleVehicle = None for v in iVehicles: if v.inventoryId == vehicle.invID: oldStyleVehicle = v break shells = ammo.get('shells') for shell in oldStyleVehicle.shells: shopShell = sAmmo[sAmmo.index(shell)] if shell in sAmmo else None goldAmmoForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits if shopShell: iCount = iAmmo[iAmmo.index(shell)].count if shell in iAmmo else 0 sPrice = (yield shopShell.getPrice()) if shell is not shopShell else (0, 0) if goldAmmoForCredits: shopShell.priceOrder = (sPrice[0] + sPrice[1] * shopRqs.exchangeRateForShellsAndEqs, sPrice[1]) shells.append({'id': gui_items.compactItem(shopShell), 'type': shell.type, 'label': ITEM_TYPES.shell_kindsabbreviation(shell.type), 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0], 'count': shell.count, 'defaultCount': shell.default, 'inventoryCount': iCount, 'price': sPrice[0 if not sPrice[1] else 1], 'currentcy': 'credits' if not sPrice[1] else 'gold', 'ammoName': shell.longName, 'tableName': shell.tableName}) self.as_setAmmoS(ammo) Waiting.hide('updateAmmo') return