def _getVehicleData(self, node, item): nodeCD = node["id"] tags = item.tags credits, gold = item.minRentPrice or item.buyPrice status, statusLevel = self._getRentStatus(item) action = None minRentPricePackage = item.getRentPackage() if item.buyPrice != item.defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage["rentPrice"] != minRentPricePackage["defaultRentPrice"]: action = getItemRentActionTooltipData(item, minRentPricePackage) return { "id": nodeCD, "state": node["state"], "type": item.itemTypeName, "nameString": item.shortUserName, "primaryClass": self._vClassInfo.getInfoByTags(tags), "level": item.level, "longName": item.longUserName, "iconPath": item.icon, "smallIconPath": item.iconSmall, "earnedXP": node["earnedXP"], "shopPrice": (credits, gold, action), "displayInfo": node["displayInfo"], "unlockProps": node["unlockProps"]._makeTuple(), "status": status, "statusLevel": statusLevel, "isRemovable": item.isRented, "isPremiumIGR": item.isPremiumIGR, }
def _getItemData(self, node, item, rootItem): nodeCD = node['id'] vClass = {'userString': '', 'name': ''} extraInfo = None status = statusLevel = '' if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE: vClass = self._vClassInfo.getInfoByTags(item.tags) status, statusLevel = self._getRentStatus(item) else: if item.itemTypeID == GUI_ITEM_TYPE.GUN and item.isClipGun(rootItem.descriptor): extraInfo = CLIP_ICON_PATH vClass.update({'name': item.itemTypeName, 'userString': item.userType}) credits, gold = item.minRentPrice or item.buyPrice action = None if item.buyPrice != item.defaultPrice: action = getItemActionTooltipData(item) return {'id': nodeCD, 'nameString': item.shortUserName, 'primaryClass': vClass, 'level': item.level, 'longName': item.longUserName, 'iconPath': item.icon, 'smallIconPath': item.iconSmall, 'earnedXP': node['earnedXP'], 'state': node['state'], 'shopPrice': (credits, gold, action), 'displayInfo': node['displayInfo'], 'unlockProps': node['unlockProps']._makeTuple(), 'extraInfo': extraInfo, 'status': status, 'statusLevel': statusLevel, 'isRemovable': item.isRented}
def _getVehicleData(self, node, item): nodeCD = node['id'] tags = item.tags credits, gold = item.minRentPrice or item.buyPrice status, statusLevel = self._getRentStatus(item) action = None minRentPricePackage = item.getRentPackage() if item.buyPrice != item.defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']: action = getItemRentActionTooltipData(item, minRentPricePackage) return {'id': nodeCD, 'state': node['state'], 'type': item.itemTypeName, 'nameString': item.shortUserName, 'primaryClass': self._vClassInfo.getInfoByTags(tags), 'level': item.level, 'longName': item.longUserName, 'iconPath': item.icon, 'smallIconPath': item.iconSmall, 'earnedXP': node['earnedXP'], 'shopPrice': (credits, gold, action), 'displayInfo': node['displayInfo'], 'unlockProps': node['unlockProps']._makeTuple(), 'status': status, 'statusLevel': statusLevel, 'isRemovable': item.isRented, 'isPremiumIGR': item.isPremiumIGR}
def itemWrapper(self, packedItem): module, inventoryCount, vehicleCount, disable, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = ( packedItem ) credits, gold = g_itemsCache.items.stats.money statusLevel = Vehicle.VEHICLE_STATE_LEVEL.INFO inventoryId = None isRented = False rentLeftTimeStr = "" if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE: statusLevel = module.getState()[1] if module.isRented: isRented = True formatter = RentLeftFormatter(module.rentInfo, module.isPremiumIGR) rentLeftTimeStr = formatter.getRentLeftStr( "#tooltips:vehicle/rentLeft/%s", formatter=lambda key, countType, count, _=None: "".join( [makeString(key % countType), ": ", str(count)] ), ) if module.isInInventory: inventoryId = module.invID name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName action = None if module.sellPrice != module.defaultSellPrice and not isRented: action = getItemActionTooltipData(module, False) return { "id": str(module.intCD), "name": name, "desc": module.getShortInfo(), "inventoryId": inventoryId, "inventoryCount": inventoryCount, "vehicleCount": vehicleCount, "credits": credits, "gold": gold, "price": module.sellPrice, "currency": "credits" if module.sellPrice[1] == 0 else "gold", "level": module.level, "nation": module.nationID, "type": module.itemTypeName if module.itemTypeID not in (GUI_ITEM_TYPE.VEHICLE, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT) else module.icon, "disabled": disable, "statusMessage": statusMessage, "statusLevel": statusLevel, "removable": module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True, "tankType": module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else None, "isPremium": module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, "isElite": module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, "itemTypeName": module.itemTypeName, "goldShellsForCredits": isEnabledBuyingGoldShellsForCredits, "goldEqsForCredits": isEnabledBuyingGoldEqsForCredits, "actionPriceData": action, "rentLeft": rentLeftTimeStr, "moduleLabel": module.getGUIEmblemID(), EXTRA_MODULE_INFO: extraModuleInfo, }
def populateTechnicalMaintenanceEquipment(self, eId1 = None, currency1 = None, eId2 = None, currency2 = None, eId3 = None, currency3 = None, slotIndex = None): items = g_itemsCache.items goldEqsForCredits = items.shop.isEnabledBuyingGoldEqsForCredits vehicle = g_currentVehicle.item credits, gold = g_itemsCache.items.stats.money installedItems = list(vehicle.eqs) currencies = [None, None, None] selectedItems = [None, None, None] if eId1 is not None or eId2 is not None or eId3 is not None or slotIndex is not None: selectedItems = map(lambda id: (items.getItemByCD(id) if id is not None else None), (eId1, eId2, eId3)) currencies = [currency1, currency2, currency3] inventoryVehicles = items.getVehicles(_RC.INVENTORY).values() itemsCriteria = ~_RC.HIDDEN | _RC.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE.EQUIPMENT]) data = sorted(g_itemsCache.items.getItems(GUI_ITEM_TYPE.EQUIPMENT, itemsCriteria).values(), reverse=True) vehicle.eqs = list(selectedItems) modules = [] for module in data: fits = [] for i in xrange(3): fits.append(self.__getStatus(module.mayInstall(vehicle, i)[1])) price = module.altPrice defaultPrice = module.defaultAltPrice index = None if module in selectedItems: index = selectedItems.index(module) priceCurrency = currencies[index] or 'credits' else: priceCurrency = module.getBuyPriceCurrency() action = None if price != defaultPrice: action = getItemActionTooltipData(module) modules.append({'id': str(module.intCD), 'name': module.userName, 'desc': module.fullDescription, 'target': module.getTarget(vehicle), 'compactDescr': module.intCD, 'prices': price, 'currency': priceCurrency, 'icon': module.icon, 'index': index, 'inventoryCount': module.inventoryCount, 'vehicleCount': len(module.getInstalledVehicles(inventoryVehicles)), 'count': module.inventoryCount, 'fits': fits, 'goldEqsForCredits': goldEqsForCredits, 'userCredits': {'credits': credits, 'gold': gold}, 'actionPriceData': action, 'moduleLabel': module.getGUIEmblemID()}) vehicle.eqs = list(installedItems) installed = map(lambda e: (e.intCD if e is not None else None), installedItems) setup = map(lambda e: (e.intCD if e is not None else None), selectedItems) self.__seveCurrentLayout(eId1=eId1, currency1=currency1, eId2=eId2, currency2=currency2, eId3=eId3, currency3=currency3) self.as_setEquipmentS(installed, setup, modules) return
def itemWrapper(self, packedItem): module, inventoryCount, vehicleCount, disable, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = packedItem credits, gold = g_itemsCache.items.stats.money statusLevel = InventoryVehicle.STATE_LEVEL.INFO inventoryId = None name = module.longUserName isRented = False rentLeftTimeStr = '' if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE: statusLevel = module.getState()[1] if module.isRented: isRented = True if not module.isPremiumIGR: localization = '#menu:vehicle/rentLeft/%s' rentLeftTimeStr = getRentLeftTimeStr(localization, module.rentLeftTime) if module.isInInventory: inventoryId = module.invID if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS: name = module.userName action = None if module.sellPrice != module.defaultSellPrice and not isRented: action = getItemActionTooltipData(module, False) return {'id': str(module.intCD), 'name': name, 'desc': module.getShortInfo(), 'inventoryId': inventoryId, 'inventoryCount': inventoryCount, 'vehicleCount': vehicleCount, 'credits': credits, 'gold': gold, 'price': module.sellPrice, 'currency': 'credits' if module.sellPrice[1] == 0 else 'gold', 'level': module.level, 'nation': module.nationID, 'type': module.itemTypeName if module.itemTypeID not in (GUI_ITEM_TYPE.VEHICLE, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT) else module.icon, 'disabled': disable, 'statusMessage': statusMessage, 'statusLevel': statusLevel, 'removable': module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True, 'tankType': module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else None, 'isPremium': module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'isElite': module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'itemTypeName': module.itemTypeName, 'goldShellsForCredits': isEnabledBuyingGoldShellsForCredits, 'goldEqsForCredits': isEnabledBuyingGoldEqsForCredits, 'actionPriceData': action, 'rentLeft': rentLeftTimeStr, 'moduleLabel': module.getGUIEmblemID(), EXTRA_MODULE_INFO: extraModuleInfo}
def populateTechnicalMaintenance(self, historicalBattleData = None): credits, gold = g_itemsCache.items.stats.money goldShellsForCredits = g_itemsCache.items.shop.isEnabledBuyingGoldShellsForCredits data = {'gold': gold, 'credits': credits} if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item casseteCount = vehicle.descriptor.gun['clip'][0] casseteText = makeString('#menu:technicalMaintenance/ammoTitleEx') % casseteCount data.update({'vehicleId': str(vehicle.intCD), 'repairCost': vehicle.repairCost, 'maxRepairCost': vehicle.descriptor.getMaxRepairCost(), 'autoRepair': vehicle.isAutoRepair, 'autoShells': vehicle.isAutoLoad, 'autoEqip': vehicle.isAutoEquip, 'maxAmmo': vehicle.gun.maxAmmo, 'gunIntCD': vehicle.gun.intCD, 'casseteFieldText': '' if casseteCount == 1 else casseteText, 'shells': [], 'infoAfterShellBlock': ''}) shells = data['shells'] for shell in vehicle.shells: price = shell.altPrice defaultPrice = shell.defaultAltPrice action = None if price != defaultPrice: action = getItemActionTooltipData(shell) shells.append({'id': str(shell.intCD), 'compactDescr': shell.intCD, 'type': shell.type, 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0], 'count': shell.count, 'userCount': shell.defaultCount, 'step': casseteCount, 'inventoryCount': shell.inventoryCount, 'goldShellsForCredits': goldShellsForCredits, 'prices': shell.altPrice, 'currency': shell.getBuyPriceCurrency(), 'ammoName': shell.longUserNameAbbr, 'tableName': shell.getShortInfo(vehicle, True), 'maxAmmo': vehicle.gun.maxAmmo, 'userCredits': {'credits': credits, 'gold': gold}, 'actionPriceData': action}) if historicalBattleData is None: self.as_setDataS(data) else: data.update({'historicalBattle': historicalBattleData}) self.as_setHistoricalDataS(data) return
def itemWrapper(self, packedItem): module, inventoryCount, vehicleCount, disabled, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = ( packedItem ) credits, gold = g_itemsCache.items.stats.money name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName price = module.altPrice or module.buyPrice defaultPrice = module.defaultAltPrice or module.defaultPrice rentLeftTimeStr = RentLeftFormatter(module.rentInfo).getRentLeftStr() minRentPricePackage = module.getRentPackage() action = None if price != defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(module) elif minRentPricePackage: price = minRentPricePackage["rentPrice"] if minRentPricePackage["rentPrice"] != minRentPricePackage["defaultRentPrice"]: action = getItemRentActionTooltipData(module, minRentPricePackage) return { "id": str(module.intCD), "name": name, "desc": module.getShortInfo(), "inventoryId": None, "inventoryCount": inventoryCount, "vehicleCount": vehicleCount, "credits": credits, "gold": gold, "price": price, "currency": "credits" if price[1] == 0 else "gold", "level": module.level, "nation": module.nationID, "type": module.itemTypeName if module.itemTypeID not in (GUI_ITEM_TYPE.VEHICLE, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT) else module.icon, "disabled": disabled, "statusMessage": statusMessage, "statusLevel": InventoryVehicle.STATE_LEVEL.WARNING, "removable": module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True, "tankType": module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else type, "isPremium": module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, "isElite": module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, "itemTypeName": module.itemTypeName, "goldShellsForCredits": isEnabledBuyingGoldShellsForCredits, "goldEqsForCredits": isEnabledBuyingGoldEqsForCredits, "actionPriceData": action, "rentLeft": rentLeftTimeStr, "moduleLabel": module.getGUIEmblemID(), EXTRA_MODULE_INFO: extraModuleInfo, }
def itemWrapper(self, packedItem): module, inventoryCount, vehicleCount, disable, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = packedItem credits, gold = g_itemsCache.items.stats.money statusLevel = InventoryVehicle.STATE_LEVEL.INFO inventoryId = None isRented = False rentLeftTimeStr = '' if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE: statusLevel = module.getState()[1] if module.isRented: isRented = True rentLeftTimeStr = RentLeftFormatter(module.rentInfo, module.isPremiumIGR).getRentTimeLeftStr() if module.isInInventory: inventoryId = module.invID name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName action = None if module.sellPrice != module.defaultSellPrice and not isRented: action = getItemActionTooltipData(module, False) return {'id': str(module.intCD), 'name': name, 'desc': module.getShortInfo(), 'inventoryId': inventoryId, 'inventoryCount': inventoryCount, 'vehicleCount': vehicleCount, 'credits': credits, 'gold': gold, 'price': module.sellPrice, 'currency': 'credits' if module.sellPrice[1] == 0 else 'gold', 'level': module.level, 'nation': module.nationID, 'type': module.itemTypeName if module.itemTypeID not in (GUI_ITEM_TYPE.VEHICLE, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT) else module.icon, 'disabled': disable, 'statusMessage': statusMessage, 'statusLevel': statusLevel, 'removable': module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True, 'tankType': module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else None, 'isPremium': module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'isElite': module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'itemTypeName': module.itemTypeName, 'goldShellsForCredits': isEnabledBuyingGoldShellsForCredits, 'goldEqsForCredits': isEnabledBuyingGoldEqsForCredits, 'actionPriceData': action, 'rentLeft': rentLeftTimeStr, 'moduleLabel': module.getGUIEmblemID(), EXTRA_MODULE_INFO: extraModuleInfo}
def itemWrapper(self, packedItem): module, inventoryCount, vehicleCount, disabled, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = packedItem credits, gold = g_itemsCache.items.stats.money name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName price = module.altPrice or module.buyPrice defaultPrice = module.defaultAltPrice or module.defaultPrice localization = '#menu:vehicle/rentLeft/%s' rentLeftTimeStr = getRentLeftTimeStr(localization, module.rentLeftTime) minRentPricePackage = module.getRentPackage() action = None if price != defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(module) elif minRentPricePackage: price = minRentPricePackage['rentPrice'] if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']: action = getItemRentActionTooltipData(module, minRentPricePackage) return {'id': str(module.intCD), 'name': name, 'desc': module.getShortInfo(), 'inventoryId': None, 'inventoryCount': inventoryCount, 'vehicleCount': vehicleCount, 'credits': credits, 'gold': gold, 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'level': module.level, 'nation': module.nationID, 'type': module.itemTypeName if module.itemTypeID not in (GUI_ITEM_TYPE.VEHICLE, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT) else module.icon, 'disabled': disabled, 'statusMessage': statusMessage, 'statusLevel': InventoryVehicle.STATE_LEVEL.WARNING, 'removable': module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True, 'tankType': module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else type, 'isPremium': module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'isElite': module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'itemTypeName': module.itemTypeName, 'goldShellsForCredits': isEnabledBuyingGoldShellsForCredits, 'goldEqsForCredits': isEnabledBuyingGoldEqsForCredits, 'actionPriceData': action, 'rentLeft': rentLeftTimeStr, 'moduleLabel': module.getGUIEmblemID(), EXTRA_MODULE_INFO: extraModuleInfo}
def itemWrapper(self, packedItem): module, inventoryCount, vehicleCount, disabled, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = packedItem credits, gold = g_itemsCache.items.stats.money name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName price = module.altPrice or module.buyPrice defaultPrice = module.defaultAltPrice or module.defaultPrice rentLeftTimeStr = RentLeftFormatter(module.rentInfo).getRentLeftStr() minRentPricePackage = module.getRentPackage() action = None if price != defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(module) elif minRentPricePackage: price = minRentPricePackage['rentPrice'] if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']: action = getItemRentActionTooltipData(module, minRentPricePackage) return {'id': str(module.intCD), 'name': name, 'desc': module.getShortInfo(), 'inventoryId': None, 'inventoryCount': inventoryCount, 'vehicleCount': vehicleCount, 'credits': credits, 'gold': gold, 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'level': module.level, 'nation': module.nationID, 'type': module.itemTypeName if module.itemTypeID not in (GUI_ITEM_TYPE.VEHICLE, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT) else module.icon, 'disabled': disabled, 'statusMessage': statusMessage, 'statusLevel': InventoryVehicle.STATE_LEVEL.WARNING, 'removable': module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True, 'tankType': module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else type, 'isPremium': module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'isElite': module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False, 'itemTypeName': module.itemTypeName, 'goldShellsForCredits': isEnabledBuyingGoldShellsForCredits, 'goldEqsForCredits': isEnabledBuyingGoldEqsForCredits, 'actionPriceData': action, 'rentLeft': rentLeftTimeStr, 'moduleLabel': module.getGUIEmblemID(), EXTRA_MODULE_INFO: extraModuleInfo}
def _getItemData(self, node, item, rootItem): nodeCD = node['id'] vClass = {'name': ''} extraInfo = None status = statusLevel = '' minRentPricePackage = None vehicleBtnLabel = '' if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE: vClass = self._vClassInfo.getInfoByTags(item.tags) status, statusLevel = self._getRentStatus(item) minRentPricePackage = item.getRentPackage() if item.isInInventory: vehicleBtnLabel = '#menu:research/labels/button/showInHangar' else: vehicleBtnLabel = '#menu:research/showInPreviewBtn/label' else: if item.itemTypeID == GUI_ITEM_TYPE.GUN and item.isClipGun(rootItem.descriptor): extraInfo = CLIP_ICON_PATH vClass.update({'name': item.itemTypeName}) credits, gold = item.minRentPrice or item.buyPrice action = None if item.buyPrice != item.defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']: action = getItemRentActionTooltipData(item, minRentPricePackage) return {'id': nodeCD, 'nameString': item.shortUserName, 'primaryClass': vClass, 'level': item.level, 'longName': item.longUserName, 'iconPath': item.icon, 'smallIconPath': item.iconSmall, 'earnedXP': node['earnedXP'], 'state': node['state'], 'shopPrice': (credits, gold, action), 'displayInfo': node['displayInfo'], 'unlockProps': node['unlockProps']._makeTuple(), 'extraInfo': extraInfo, 'status': status, 'statusLevel': statusLevel, 'isPremiumIGR': item.isPremiumIGR, 'showVehicleBtnLabel': i18n.makeString(vehicleBtnLabel), 'showVehicleBtnEnabled': item.isInInventory or item.isPreviewAllowed()}
def _getItemData(self, node, item, rootItem): nodeCD = node["id"] vClass = {"userString": "", "name": ""} extraInfo = None status = statusLevel = "" minRentPricePackage = None if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE: vClass = self._vClassInfo.getInfoByTags(item.tags) status, statusLevel = self._getRentStatus(item) minRentPricePackage = item.getRentPackage() else: if item.itemTypeID == GUI_ITEM_TYPE.GUN and item.isClipGun(rootItem.descriptor): extraInfo = CLIP_ICON_PATH vClass.update({"name": item.itemTypeName, "userString": item.userType}) credits, gold = item.minRentPrice or item.buyPrice action = None if item.buyPrice != item.defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage["rentPrice"] != minRentPricePackage["defaultRentPrice"]: action = getItemRentActionTooltipData(item, minRentPricePackage) return { "id": nodeCD, "nameString": item.shortUserName, "primaryClass": vClass, "level": item.level, "longName": item.longUserName, "iconPath": item.icon, "smallIconPath": item.iconSmall, "earnedXP": node["earnedXP"], "state": node["state"], "shopPrice": (credits, gold, action), "displayInfo": node["displayInfo"], "unlockProps": node["unlockProps"]._makeTuple(), "extraInfo": extraInfo, "status": status, "statusLevel": statusLevel, "isRemovable": item.isRented, "isPremiumIGR": item.isPremiumIGR, }
def _getItemData(self, node, item, rootItem): nodeCD = node['id'] vClass = {'userString': '', 'name': ''} extraInfo = None status = statusLevel = '' minRentPricePackage = None if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE: vClass = self._vClassInfo.getInfoByTags(item.tags) status, statusLevel = self._getRentStatus(item) minRentPricePackage = item.getRentPackage() else: if item.itemTypeID == GUI_ITEM_TYPE.GUN and item.isClipGun(rootItem.descriptor): extraInfo = CLIP_ICON_PATH vClass.update({'name': item.itemTypeName, 'userString': item.userType}) credits, gold = item.minRentPrice or item.buyPrice action = None if item.buyPrice != item.defaultPrice and not minRentPricePackage: action = getItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']: action = getItemRentActionTooltipData(item, minRentPricePackage) return {'id': nodeCD, 'nameString': item.shortUserName, 'primaryClass': vClass, 'level': item.level, 'longName': item.longUserName, 'iconPath': item.icon, 'smallIconPath': item.iconSmall, 'earnedXP': node['earnedXP'], 'state': node['state'], 'shopPrice': (credits, gold, action), 'displayInfo': node['displayInfo'], 'unlockProps': node['unlockProps']._makeTuple(), 'extraInfo': extraInfo, 'status': status, 'statusLevel': statusLevel, 'isRemovable': item.isRented, 'isPremiumIGR': item.isPremiumIGR}
def _initData(self, *args): stats = g_itemsCache.items.stats self.as_setGoldS(stats.gold) self.as_setCreditsS(stats.credits) windowExpanded = AccountSettings.getSettings(VEHICLE_BUY_WINDOW_SETTINGS) vehicle = g_itemsCache.items.getItem(GUI_ITEM_TYPE.VEHICLE, self.nationID, self.inNationID) if vehicle is None: LOG_ERROR("Vehicle Item mustn't be None!", 'NationID:', self.nationID, 'InNationID:', self.inNationID) elif vehicle.isInInventory and not vehicle.isRented: self.onWindowClose() else: shop = g_itemsCache.items.shop shopDefaults = shop.defaults tankMenCount = len(vehicle.crew) tankMenStudyPrice = shop.tankmanCostWithGoodyDiscount totalTankMenStudePrice = (tankMenStudyPrice[1]['credits'] * tankMenCount, tankMenStudyPrice[2]['gold'] * tankMenCount) defTankMenStudyPrice = shopDefaults.tankmanCost defTotalTankMenStudePrice = (defTankMenStudyPrice[1]['credits'] * tankMenCount, defTankMenStudyPrice[2]['gold'] * tankMenCount) studyPriceCreditsActionData = None if totalTankMenStudePrice[0] != defTotalTankMenStudePrice[0]: studyPriceCreditsActionData = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'creditsTankmanCost', 'isBuying': True, 'state': (ACTION_TOOLTIPS_STATE.DISCOUNT, None), 'newPrice': (totalTankMenStudePrice[0], 0), 'oldPrice': (defTotalTankMenStudePrice[0], 0)} studyPriceGoldActionData = None if totalTankMenStudePrice[1] != defTotalTankMenStudePrice[1]: studyPriceGoldActionData = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'goldTankmanCost', 'isBuying': True, 'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT), 'newPrice': (0, totalTankMenStudePrice[1]), 'oldPrice': (0, defTotalTankMenStudePrice[1])} vehiclePricesActionData = None if vehicle.buyPrice != vehicle.defaultPrice: vehiclePricesActionData = getItemActionTooltipData(vehicle) ammoPrice = [0, 0] defAmmoPrice = [0, 0] for shell in vehicle.gun.defaultAmmo: ammoPrice[0] += shell.buyPrice[0] * shell.defaultCount ammoPrice[1] += shell.buyPrice[1] * shell.defaultCount defAmmoPrice[0] += shell.defaultPrice[0] * shell.defaultCount defAmmoPrice[1] += shell.defaultPrice[1] * shell.defaultCount ammoActionPriceData = None if ammoPrice[0] != defAmmoPrice[0]: ammoActionPriceData = {'type': ACTION_TOOLTIPS_TYPE.AMMO, 'key': str(vehicle.intCD), 'isBuying': True, 'state': (ACTION_TOOLTIPS_STATE.DISCOUNT, None), 'newPrice': ammoPrice, 'oldPrice': defAmmoPrice} slotPrice = shop.getVehicleSlotsPrice(stats.vehicleSlots) slotDefaultPrice = shopDefaults.getVehicleSlotsPrice(stats.vehicleSlots) slotActionPriceData = None if slotPrice != slotDefaultPrice: slotActionPriceData = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'slotsPrices', 'isBuying': True, 'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT), 'newPrice': (0, slotPrice), 'oldPrice': (0, slotDefaultPrice)} tankmenLabel = i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMENLABEL, count=text_styles.titleFont(i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMEN) + ' ' + str(tankMenCount))) initData = {'expanded': windowExpanded, 'name': vehicle.userName, 'longName': vehicle.longUserName, 'description': vehicle.fullDescription, 'type': vehicle.type, 'icon': vehicle.icon, 'nation': self.nationID, 'level': vehicle.level, 'isElite': vehicle.isElite, 'tankmenLabel': tankmenLabel, 'studyPriceCredits': totalTankMenStudePrice[0], 'studyPriceCreditsActionData': studyPriceCreditsActionData, 'studyPriceGold': totalTankMenStudePrice[1], 'studyPriceGoldActionData': studyPriceGoldActionData, 'vehiclePrices': vehicle.buyPrice, 'vehiclePricesActionData': vehiclePricesActionData, 'ammoPrice': ammoPrice[0], 'ammoActionPriceData': ammoActionPriceData, 'slotPrice': slotPrice, 'slotActionPriceData': slotActionPriceData, 'isRentable': vehicle.isRentable, 'isStudyDisabled': vehicle.hasCrew, 'isNoAmmo': not vehicle.hasShells, 'rentDataDD': self._getRentData(vehicle, vehiclePricesActionData)} self.as_setInitDataS(initData) return
def _populate(self): super(VehicleSellDialog, self)._populate() g_clientUpdateManager.addCallbacks({'stats.gold': self.onSetGoldHndlr}) g_itemsCache.onSyncCompleted += self.__shopResyncHandler items = g_itemsCache.items vehicle = items.getVehicle(self.vehInvID) invVehs = items.getVehicles(REQ_CRITERIA.INVENTORY) if vehicle.isPremium or vehicle.level >= 3: self.as_visibleControlBlockS(True) self.__initCtrlQuestion() else: self.as_visibleControlBlockS(False) modules = items.getItems(criteria=REQ_CRITERIA.VEHICLE.SUITABLE([vehicle]) | REQ_CRITERIA.INVENTORY).values() shells = items.getItems(criteria=REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE.SHELL]) | REQ_CRITERIA.INVENTORY).values() otherVehsShells = set() for invVeh in invVehs.itervalues(): if invVeh.invID != self.vehInvID: for shot in invVeh.descriptor.gun['shots']: otherVehsShells.add(shot['shell']['compactDescr']) vehicleAction = None if vehicle.sellPrice != vehicle.defaultSellPrice: vehicleAction = getItemActionTooltipData(vehicle, False) vehicleData = {'intCD': vehicle.intCD, 'userName': vehicle.userName, 'icon': vehicle.icon, 'level': vehicle.level, 'isElite': vehicle.isElite, 'isPremium': vehicle.isPremium, 'type': vehicle.type, 'nationID': vehicle.nationID, 'sellPrice': vehicle.sellPrice, 'action': vehicleAction, 'hasCrew': vehicle.hasCrew, 'isRented': vehicle.isRented} onVehicleOptionalDevices = [] for o in vehicle.optDevices: data = None if o is not None: action = None if o.sellPrice != o.defaultSellPrice: action = getItemActionTooltipData(o, False) data = {'intCD': o.intCD, 'isRemovable': o.isRemovable, 'userName': o.userName, 'sellPrice': o.sellPrice, 'toInventory': True, 'action': action} onVehicleOptionalDevices.append(data) onVehicleoShells = [] for s in vehicle.shells: data = None if s is not None: action = None if s.sellPrice != s.defaultSellPrice: action = getItemActionTooltipData(s, False) data = {'intCD': s.intCD, 'count': s.count, 'sellPrice': s.sellPrice, 'userName': s.userName, 'kind': s.type, 'toInventory': s in otherVehsShells or s.isPremium, 'action': action} onVehicleoShells.append(data) onVehicleEquipments = [] for e in vehicle.eqs: data = None if e is not None: action = None if e.sellPrice != e.defaultSellPrice: action = getItemActionTooltipData(e, False) data = {'intCD': e.intCD, 'userName': e.userName, 'sellPrice': e.sellPrice, 'toInventory': True, 'action': action} onVehicleEquipments.append(data) inInventoryModules = [] for m in modules: inInventoryModules.append({'intCD': m.intCD, 'inventoryCount': m.inventoryCount, 'toInventory': True, 'sellPrice': m.sellPrice}) inInventoryShells = [] for s in shells: action = None if s.sellPrice != s.defaultSellPrice: action = getItemActionTooltipData(s, False) inInventoryShells.append({'intCD': s.intCD, 'count': s.inventoryCount, 'sellPrice': s.sellPrice, 'userName': s.userName, 'kind': s.type, 'toInventory': s in otherVehsShells or s.isPremium, 'action': action}) removePrice = items.shop.paidRemovalCost removePrices = (0, removePrice) defRemovePrice = (0, items.shop.defaults.paidRemovalCost) removeAction = None if removePrices != defRemovePrice: removeAction = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'paidRemovalCost', 'isBuying': True, 'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT), 'newPrice': removePrices, 'oldPrice': defRemovePrice} settings = self.getDialogSettings() isSlidingComponentOpened = settings['isOpened'] self.as_setDataS({'accountGold': items.stats.gold, 'sellVehicleVO': vehicleData, 'optionalDevicesOnVehicle': onVehicleOptionalDevices, 'shellsOnVehicle': onVehicleoShells, 'equipmentsOnVehicle': onVehicleEquipments, 'modulesInInventory': inInventoryModules, 'shellsInInventory': inInventoryShells, 'removeActionPrice': removeAction, 'removePrice': removePrice, 'isSlidingComponentOpened': isSlidingComponentOpened}) return
def _update(self, modulesData = None, shellsData = None): if g_currentVehicle.isPresent(): self.as_setModulesEnabledS(True) self.__updateAmmo(shellsData) money = g_itemsCache.items.stats.money exchangeRate = g_itemsCache.items.shop.exchangeRate vehicle = g_currentVehicle.item self.as_setVehicleHasTurretS(vehicle.hasTurrets) devices = [] for slotType in AmmunitionPanel.__FITTING_SLOTS: data = g_itemsCache.items.getItems(GUI_ITEM_TYPE_INDICES[slotType], REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE_INDICES[slotType]])).values() data.sort(reverse=True) if slotType in AmmunitionPanel.__ARTEFACTS_SLOTS: dataProvider = [[], [], []] else: dataProvider = [] for module in data: price = module.buyPrice defaultPrice = module.defaultPrice thisTypeHBItem = None target = module.TARGETS.OTHER if modulesData is not None: thisTypeHBItem = modulesData.get(module.itemTypeID) if thisTypeHBItem and thisTypeHBItem.intCD == module.intCD: target = module.TARGETS.CURRENT action = None if price != defaultPrice: action = getItemActionTooltipData(module) moduleData = {'id': module.intCD, 'type': slotType, 'name': module.userName, 'desc': module.getShortInfo(), 'target': target if thisTypeHBItem is not None else module.getTarget(vehicle), 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'actionPriceData': action, 'moduleLabel': module.getGUIEmblemID()} if slotType == ITEM_TYPE_NAMES[4]: if module.isClipGun(vehicle.descriptor): moduleData[EXTRA_MODULE_INFO] = CLIP_ICON_PATH isFit, reason = True, '' if not module.isInInventory: isFit, reason = module.mayPurchase(money) if not isFit and reason == 'credit_error': isFit = module.mayPurchaseWithExchange(money, exchangeRate) if slotType in AmmunitionPanel.__ARTEFACTS_SLOTS: moduleData['removable'] = module.isRemovable for i in xrange(3): md = moduleData.copy() if isFit: reason = self._getInstallReason(module, vehicle, reason, i) isCurrent = module.isInstalled(vehicle, i) if md.get('target') == 1: md['status'] = MENU.MODULEFITS_WRONG_SLOT if not isCurrent else self.__getStatus(reason) md['isSelected'] = isCurrent md['disabled'] = not isFit or not isCurrent or reason == 'unlock_error' else: md['status'] = self.__getStatus(reason) md['isSelected'] = False md['disabled'] = not isFit or reason == 'unlock_error' md['slotIndex'] = i dataProvider[i].append(md) else: if isFit: reason = self._getInstallReason(module, vehicle, reason) moduleData['icon'] = module.level moduleData['removable'] = True moduleData['isSelected'] = moduleData.get('target') == 1 moduleData['status'] = self.__getStatus(reason) moduleData['disabled'] = not isFit or reason == 'unlock_error' dataProvider.append(moduleData) if slotType in AmmunitionPanel.__ARTEFACTS_SLOTS: for i in xrange(3): self.__addDevice(devices, dataProvider[i], slotType, i) else: self.__addDevice(devices, dataProvider, slotType) self.as_setDataS(devices) statusId, msg, msgLvl = g_currentVehicle.getHangarMessage() rentAvailable = False if statusId == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER: canBuyOrRent, _ = vehicle.mayRentOrBuy(g_itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent isBackground = False if statusId == Vehicle.VEHICLE_STATE.NOT_PRESENT: isBackground = True isSuitableVeh = not (self.__falloutCtrl.isSelected() and not g_currentVehicle.item.isFalloutAvailable) and g_currentVehicle.item.getCustomState() != Vehicle.VEHICLE_STATE.UNSUITABLE_TO_QUEUE if not isSuitableVeh: msg = i18n.makeString('#menu:tankCarousel/vehicleStates/%s' % Vehicle.VEHICLE_STATE.NOT_SUITABLE) msgLvl = Vehicle.VEHICLE_STATE_LEVEL.WARNING msgString = makeHtmlString('html_templates:vehicleStatus', msgLvl, {'message': i18n.makeString(msg)}) self.as_updateVehicleStatusS({'message': msgString, 'rentAvailable': rentAvailable, 'isBackground': isBackground}) return
def _update(self, modulesData = None, shellsData = None, historicalBattleID = -1): if g_currentVehicle.isPresent(): self.as_setHistoricalBattleS(historicalBattleID) self.as_setModulesEnabledS(historicalBattleID == -1) self.__updateAmmo(shellsData, historicalBattleID) vehicle = g_currentVehicle.item self.as_setVehicleHasTurretS(vehicle.hasTurrets) for type in AmmunitionPanel.__FITTING_SLOTS: data = g_itemsCache.items.getItems(GUI_ITEM_TYPE_INDICES[type], REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE_INDICES[type]])).values() data.sort(reverse=True) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: dataProvider = [[], [], []] else: dataProvider = [] for module in data: price = module.buyPrice defaultPrice = module.defaultPrice thisTypeHBItem = None target = module.TARGETS.OTHER if modulesData is not None: thisTypeHBItem = modulesData.get(module.itemTypeID) if thisTypeHBItem and thisTypeHBItem.intCD == module.intCD: target = module.TARGETS.CURRENT action = None if price != defaultPrice: action = getItemActionTooltipData(module) moduleData = {'id': str(module.intCD), 'type': type, 'name': module.userName, 'desc': module.getShortInfo(), 'target': target if thisTypeHBItem is not None else module.getTarget(vehicle), 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'icon': module.icon if type in AmmunitionPanel.__ARTEFACTS_SLOTS else module.level, 'actionPriceData': action} if type == ITEM_TYPE_NAMES[4]: if module.isClipGun(vehicle.descriptor): moduleData[EXTRA_MODULE_INFO] = CLIP_ICON_PATH isFit, reason = True, '' if not module.isInInventory: isFit, reason = module.mayPurchase(g_itemsCache.items.stats.money) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: moduleData['removable'] = module.isRemovable for i in xrange(3): md = moduleData.copy() if isFit: _, reason = module.mayInstall(vehicle, i) isCurrent = module.isInstalled(vehicle, i) if md.get('target') == 1: md['status'] = MENU.MODULEFITS_WRONG_SLOT if not isCurrent else self.__getStatus(reason) md['isSelected'] = isCurrent else: md['status'] = self.__getStatus(reason) md['isSelected'] = False md['slotIndex'] = i dataProvider[i].append(md) else: if isFit: isFit, reason = module.mayInstall(vehicle) moduleData['removable'] = True moduleData['isSelected'] = moduleData.get('target') == 1 moduleData['status'] = self.__getStatus(reason) dataProvider.append(moduleData) self.as_setDataS(dataProvider, type) statusId, msg, msgLvl = g_currentVehicle.getHangarMessage() rentAvailable = False if statusId == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER: canBuyOrRent, _ = vehicle.mayRentOrBuy(g_itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent self.as_updateVehicleStatusS(statusId, msg, msgLvl, rentAvailable)
def populateTechnicalMaintenanceEquipment(self, eId1=None, currency1=None, eId2=None, currency2=None, eId3=None, currency3=None, slotIndex=None): items = g_itemsCache.items goldEqsForCredits = items.shop.isEnabledBuyingGoldEqsForCredits vehicle = g_currentVehicle.item credits, gold = g_itemsCache.items.stats.money installedItems = list(vehicle.eqs) currencies = [None, None, None] selectedItems = [None, None, None] if eId1 is not None or eId2 is not None or eId3 is not None or slotIndex is not None: selectedItems = map( lambda id: (items.getItemByCD(id) if id is not None else None), (eId1, eId2, eId3)) currencies = [currency1, currency2, currency3] inventoryVehicles = items.getVehicles(_RC.INVENTORY).values() itemsCriteria = ~_RC.HIDDEN | _RC.VEHICLE.SUITABLE( [vehicle], [GUI_ITEM_TYPE.EQUIPMENT]) data = sorted(g_itemsCache.items.getItems(GUI_ITEM_TYPE.EQUIPMENT, itemsCriteria).values(), reverse=True) vehicle.eqs = list(selectedItems) modules = [] for module in data: fits = [] for i in xrange(3): fits.append(self.__getStatus(module.mayInstall(vehicle, i)[1])) price = module.altPrice defaultPrice = module.defaultAltPrice index = None if module in selectedItems: index = selectedItems.index(module) priceCurrency = currencies[index] or 'credits' else: priceCurrency = module.getBuyPriceCurrency() action = None if price != defaultPrice: action = getItemActionTooltipData(module) modules.append({ 'id': str(module.intCD), 'name': module.userName, 'desc': module.fullDescription, 'target': module.getTarget(vehicle), 'compactDescr': module.intCD, 'prices': price, 'currency': priceCurrency, 'icon': module.icon, 'index': index, 'inventoryCount': module.inventoryCount, 'vehicleCount': len(module.getInstalledVehicles(inventoryVehicles)), 'count': module.inventoryCount, 'fits': fits, 'goldEqsForCredits': goldEqsForCredits, 'userCredits': { 'credits': credits, 'gold': gold }, 'actionPriceData': action, 'moduleLabel': module.getGUIEmblemID() }) vehicle.eqs = list(installedItems) installed = map(lambda e: (e.intCD if e is not None else None), installedItems) setup = map(lambda e: (e.intCD if e is not None else None), selectedItems) self.__seveCurrentLayout(eId1=eId1, currency1=currency1, eId2=eId2, currency2=currency2, eId3=eId3, currency3=currency3) self.as_setEquipmentS(installed, setup, modules)
def _initData(self, *args): stats = g_itemsCache.items.stats self.as_setGoldS(stats.gold) self.as_setCreditsS(stats.credits) windowExpanded = AccountSettings.getSettings( VEHICLE_BUY_WINDOW_SETTINGS) vehicle = g_itemsCache.items.getItem(GUI_ITEM_TYPE.VEHICLE, self.nationID, self.inNationID) if vehicle is None: LOG_ERROR("Vehicle Item mustn't be None!", 'NationID:', self.nationID, 'InNationID:', self.inNationID) elif vehicle.isInInventory and not vehicle.isRented: self.onWindowClose() else: shop = g_itemsCache.items.shop shopDefaults = shop.defaults tankMenCount = len(vehicle.crew) tankMenStudyPrice = shop.tankmanCostWithGoodyDiscount totalTankMenStudePrice = (tankMenStudyPrice[1]['credits'] * tankMenCount, tankMenStudyPrice[2]['gold'] * tankMenCount) defTankMenStudyPrice = shopDefaults.tankmanCost defTotalTankMenStudePrice = (defTankMenStudyPrice[1]['credits'] * tankMenCount, defTankMenStudyPrice[2]['gold'] * tankMenCount) studyPriceCreditsActionData = None if totalTankMenStudePrice[0] != defTotalTankMenStudePrice[0]: studyPriceCreditsActionData = { 'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'creditsTankmanCost', 'isBuying': True, 'state': (ACTION_TOOLTIPS_STATE.DISCOUNT, None), 'newPrice': (totalTankMenStudePrice[0], 0), 'oldPrice': (defTotalTankMenStudePrice[0], 0) } studyPriceGoldActionData = None if totalTankMenStudePrice[1] != defTotalTankMenStudePrice[1]: studyPriceGoldActionData = { 'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'goldTankmanCost', 'isBuying': True, 'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT), 'newPrice': (0, totalTankMenStudePrice[1]), 'oldPrice': (0, defTotalTankMenStudePrice[1]) } vehiclePricesActionData = None if vehicle.buyPrice != vehicle.defaultPrice: vehiclePricesActionData = getItemActionTooltipData(vehicle) ammoPrice = [0, 0] defAmmoPrice = [0, 0] for shell in vehicle.gun.defaultAmmo: ammoPrice[0] += shell.buyPrice[0] * shell.defaultCount ammoPrice[1] += shell.buyPrice[1] * shell.defaultCount defAmmoPrice[0] += shell.defaultPrice[0] * shell.defaultCount defAmmoPrice[1] += shell.defaultPrice[1] * shell.defaultCount ammoActionPriceData = None if ammoPrice[0] != defAmmoPrice[0]: ammoActionPriceData = { 'type': ACTION_TOOLTIPS_TYPE.AMMO, 'key': str(vehicle.intCD), 'isBuying': True, 'state': (ACTION_TOOLTIPS_STATE.DISCOUNT, None), 'newPrice': ammoPrice, 'oldPrice': defAmmoPrice } slotPrice = shop.getVehicleSlotsPrice(stats.vehicleSlots) slotDefaultPrice = shopDefaults.getVehicleSlotsPrice( stats.vehicleSlots) slotActionPriceData = None if slotPrice != slotDefaultPrice: slotActionPriceData = { 'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'slotsPrices', 'isBuying': True, 'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT), 'newPrice': (0, slotPrice), 'oldPrice': (0, slotDefaultPrice) } tankmenLabel = i18n.makeString( DIALOGS.BUYVEHICLEDIALOG_TANKMENLABEL, count=text_styles.titleFont( i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMEN) + ' ' + str(tankMenCount))) initData = { 'expanded': windowExpanded, 'name': vehicle.userName, 'longName': vehicle.longUserName, 'description': vehicle.fullDescription, 'type': vehicle.type, 'icon': vehicle.icon, 'nation': self.nationID, 'level': vehicle.level, 'isElite': vehicle.isElite, 'tankmenLabel': tankmenLabel, 'studyPriceCredits': totalTankMenStudePrice[0], 'studyPriceCreditsActionData': studyPriceCreditsActionData, 'studyPriceGold': totalTankMenStudePrice[1], 'studyPriceGoldActionData': studyPriceGoldActionData, 'vehiclePrices': vehicle.buyPrice, 'vehiclePricesActionData': vehiclePricesActionData, 'ammoPrice': ammoPrice[0], 'ammoActionPriceData': ammoActionPriceData, 'slotPrice': slotPrice, 'slotActionPriceData': slotActionPriceData, 'isRentable': vehicle.isRentable, 'isStudyDisabled': vehicle.hasCrew, 'isNoAmmo': not vehicle.hasShells, 'rentDataDD': self._getRentData(vehicle, vehiclePricesActionData) } self.as_setInitDataS(initData)
def _update(self, modulesData=None, shellsData=None, historicalBattleID=-1): if g_currentVehicle.isPresent(): self.as_setHistoricalBattleS(historicalBattleID) self.as_setModulesEnabledS(historicalBattleID == -1) self.__updateAmmo(shellsData, historicalBattleID) money = g_itemsCache.items.stats.money exchangeRate = g_itemsCache.items.shop.exchangeRate vehicle = g_currentVehicle.item self.as_setVehicleHasTurretS(vehicle.hasTurrets) devices = [] for type in AmmunitionPanel.__FITTING_SLOTS: data = g_itemsCache.items.getItems( GUI_ITEM_TYPE_INDICES[type], REQ_CRITERIA.VEHICLE.SUITABLE( [vehicle], [GUI_ITEM_TYPE_INDICES[type]])).values() data.sort(reverse=True) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: dataProvider = [[], [], []] else: dataProvider = [] for module in data: price = module.buyPrice defaultPrice = module.defaultPrice thisTypeHBItem = None target = module.TARGETS.OTHER if modulesData is not None: thisTypeHBItem = modulesData.get(module.itemTypeID) if thisTypeHBItem and thisTypeHBItem.intCD == module.intCD: target = module.TARGETS.CURRENT action = None if price != defaultPrice: action = getItemActionTooltipData(module) moduleData = { 'id': module.intCD, 'type': type, 'name': module.userName, 'desc': module.getShortInfo(), 'target': target if thisTypeHBItem is not None else module.getTarget(vehicle), 'price': price, 'currency': 'credits' if price[1] == 0 else 'gold', 'actionPriceData': action, 'moduleLabel': module.getGUIEmblemID() } if type == ITEM_TYPE_NAMES[4]: if module.isClipGun(vehicle.descriptor): moduleData[EXTRA_MODULE_INFO] = CLIP_ICON_PATH isFit, reason = True, '' if not module.isInInventory: isFit, reason = module.mayPurchase(money) if not isFit and reason == 'credit_error': isFit = module.mayPurchaseWithExchange( money, exchangeRate) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: moduleData['removable'] = module.isRemovable for i in xrange(3): md = moduleData.copy() if isFit: reason = self._getInstallReason( module, vehicle, reason, i) isCurrent = module.isInstalled(vehicle, i) if md.get('target') == 1: md['status'] = MENU.MODULEFITS_WRONG_SLOT if not isCurrent else self.__getStatus( reason) md['isSelected'] = isCurrent md['disabled'] = not isFit or not isCurrent or reason == 'unlock_error' else: md['status'] = self.__getStatus(reason) md['isSelected'] = False md['disabled'] = not isFit or reason == 'unlock_error' md['slotIndex'] = i dataProvider[i].append(md) else: if isFit: reason = self._getInstallReason( module, vehicle, reason) moduleData['icon'] = module.level moduleData['removable'] = True moduleData['isSelected'] = moduleData.get( 'target') == 1 moduleData['status'] = self.__getStatus(reason) moduleData[ 'disabled'] = not isFit or reason == 'unlock_error' dataProvider.append(moduleData) if type in AmmunitionPanel.__ARTEFACTS_SLOTS: for i in xrange(3): self.__addDevice(devices, dataProvider[i], type, i) else: self.__addDevice(devices, dataProvider, type) self.as_setDataS(devices) statusId, msg, msgLvl = g_currentVehicle.getHangarMessage() rentAvailable = False if statusId == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER: canBuyOrRent, _ = vehicle.mayRentOrBuy( g_itemsCache.items.stats.money) rentAvailable = vehicle.isRentable and canBuyOrRent self.as_updateVehicleStatusS(i18n.makeString(msg), msgLvl, rentAvailable)
def _populate(self): super(VehicleSellDialog, self)._populate() g_clientUpdateManager.addCallbacks({'stats.gold': self.onSetGoldHndlr}) g_itemsCache.onSyncCompleted += self.__shopResyncHandler items = g_itemsCache.items vehicle = items.getVehicle(self.vehInvID) invVehs = items.getVehicles(REQ_CRITERIA.INVENTORY) if vehicle.isPremium or vehicle.level >= 3: self.as_visibleControlBlockS(True) self.__initCtrlQuestion() else: self.as_visibleControlBlockS(False) modules = items.getItems( criteria=REQ_CRITERIA.VEHICLE.SUITABLE([vehicle]) | REQ_CRITERIA.INVENTORY).values() shells = items.getItems(criteria=REQ_CRITERIA.VEHICLE.SUITABLE( [vehicle], [GUI_ITEM_TYPE.SHELL]) | REQ_CRITERIA.INVENTORY).values() otherVehsShells = set() for invVeh in invVehs.itervalues(): if invVeh.invID != self.vehInvID: for shot in invVeh.descriptor.gun['shots']: otherVehsShells.add(shot['shell']['compactDescr']) vehicleAction = None if vehicle.sellPrice != vehicle.defaultSellPrice: vehicleAction = getItemActionTooltipData(vehicle, False) vehicleData = { 'intCD': vehicle.intCD, 'userName': vehicle.userName, 'icon': vehicle.icon, 'level': vehicle.level, 'isElite': vehicle.isElite, 'isPremium': vehicle.isPremium, 'type': vehicle.type, 'nationID': vehicle.nationID, 'sellPrice': vehicle.sellPrice, 'action': vehicleAction, 'hasCrew': vehicle.hasCrew, 'isRented': vehicle.isRented } onVehicle = defaultdict(list) onVehicleOptionalDevices = onVehicle['optionalDevices'] for o in vehicle.optDevices: data = None if o is not None: action = None if o.sellPrice != o.defaultSellPrice: action = getItemActionTooltipData(o, False) data = { 'intCD': o.intCD, 'isRemovable': o.isRemovable, 'userName': o.userName, 'sellPrice': o.sellPrice, 'toInventory': True, 'action': action } onVehicleOptionalDevices.append(data) onVehicleoShells = onVehicle['shells'] for s in vehicle.shells: data = None if s is not None: action = None if s.sellPrice != s.defaultSellPrice: action = getItemActionTooltipData(s, False) data = { 'intCD': s.intCD, 'count': s.count, 'sellPrice': s.sellPrice, 'userName': s.userName, 'kind': s.type, 'toInventory': s in otherVehsShells or s.isPremium, 'action': action } onVehicleoShells.append(data) onVehicleEquipments = onVehicle['equipments'] for e in vehicle.eqs: data = None if e is not None: action = None if e.sellPrice != e.defaultSellPrice: action = getItemActionTooltipData(e, False) data = { 'intCD': e.intCD, 'userName': e.userName, 'sellPrice': e.sellPrice, 'toInventory': True, 'action': action } onVehicleEquipments.append(data) inInventory = defaultdict(list) inInventoryModules = inInventory['modules'] for m in modules: inInventoryModules.append({ 'intCD': m.intCD, 'inventoryCount': m.inventoryCount, 'toInventory': True, 'sellPrice': m.sellPrice }) inInventoryShells = inInventory['shells'] for s in shells: action = None if s.sellPrice != s.defaultSellPrice: action = getItemActionTooltipData(s, False) inInventoryShells.append({ 'intCD': s.intCD, 'count': s.inventoryCount, 'sellPrice': s.sellPrice, 'userName': s.userName, 'kind': s.type, 'toInventory': s in otherVehsShells or s.isPremium, 'action': action }) removePrice = (0, items.shop.paidRemovalCost) defRemovePrice = (0, items.shop.defaults.paidRemovalCost) removeAction = None if removePrice != defRemovePrice: removeAction = { 'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'paidRemovalCost', 'isBuying': True, 'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT), 'newPrice': removePrice, 'oldPrice': defRemovePrice } removePrices = {'removePrice': removePrice, 'action': removeAction} self.as_setDataS(vehicleData, onVehicle, inInventory, removePrices, items.stats.gold)
def populateTechnicalMaintenance(self, historicalBattleData=None): credits, gold = g_itemsCache.items.stats.money goldShellsForCredits = g_itemsCache.items.shop.isEnabledBuyingGoldShellsForCredits data = {'gold': gold, 'credits': credits} if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item casseteCount = vehicle.descriptor.gun['clip'][0] casseteText = makeString( '#menu:technicalMaintenance/ammoTitleEx') % casseteCount data.update({ 'vehicleId': str(vehicle.intCD), 'repairCost': vehicle.repairCost, 'maxRepairCost': vehicle.descriptor.getMaxRepairCost(), 'autoRepair': vehicle.isAutoRepair, 'autoShells': vehicle.isAutoLoad, 'autoEqip': vehicle.isAutoEquip, 'maxAmmo': vehicle.gun.maxAmmo, 'gunIntCD': vehicle.gun.intCD, 'casseteFieldText': '' if casseteCount == 1 else casseteText, 'shells': [], 'infoAfterShellBlock': '' }) shells = data['shells'] for shell in vehicle.shells: price = shell.altPrice defaultPrice = shell.defaultAltPrice action = None if price != defaultPrice: action = getItemActionTooltipData(shell) shells.append({ 'id': str(shell.intCD), 'compactDescr': shell.intCD, 'type': shell.type, 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0], 'count': shell.count, 'userCount': shell.defaultCount, 'step': casseteCount, 'inventoryCount': shell.inventoryCount, 'goldShellsForCredits': goldShellsForCredits, 'prices': shell.altPrice, 'currency': shell.getBuyPriceCurrency(), 'ammoName': shell.longUserNameAbbr, 'tableName': shell.getShortInfo(vehicle, True), 'maxAmmo': vehicle.gun.maxAmmo, 'userCredits': { 'credits': credits, 'gold': gold }, 'actionPriceData': action }) if historicalBattleData is None: self.as_setDataS(data) else: data.update({'historicalBattle': historicalBattleData}) self.as_setHistoricalDataS(data)