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 = packItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage['rentPrice'] != minRentPricePackage[ 'defaultRentPrice']: action = packItemRentActionTooltipData(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 _populate(self): super(BoosterBuyWindow, self)._populate() if self.__item.isCrewBooster(): isPerkReplace = not self.__item.isAffectedSkillLearnt(g_currentVehicle.item) desc = self.__item.getCrewBoosterAction(isPerkReplace) overlayType = SLOT_HIGHLIGHT_TYPES.BATTLE_BOOSTER_CREW_REPLACE if isPerkReplace else SLOT_HIGHLIGHT_TYPES.BATTLE_BOOSTER else: desc = self.__item.getOptDeviceBoosterDescription(g_currentVehicle.item) overlayType = SLOT_HIGHLIGHT_TYPES.BATTLE_BOOSTER self.as_setInitDataS({'windowTitle': MENU.BOOSTERBUYWINDOW_WINDOWTITLE, 'nameText': text_styles.highTitle(self.__item.userName), 'descText': text_styles.main(desc), 'countLabelText': text_styles.main(MENU.BOOSTERBUYWINDOW_BUYCOUNT), 'buyLabelText': text_styles.main(MENU.BOOSTERBUYWINDOW_TOTALPRICE), 'totalPriceLabelText': text_styles.highlightText(MENU.BOOSTERBUYWINDOW_TOTALLABEL), 'inHangarLabelText': text_styles.main(MENU.BOOSTERBUYWINDOW_INHANGARCOUNT), 'boosterSlot': self.__getItemSlotData(self.__item, overlayType), 'rearmCheckboxLabel': MENU.BOOSTERBUYWINDOW_REARMCHECKBOXLABEL, 'rearmCheckboxTooltip': '', 'submitBtnLabel': MENU.BOOSTERBUYWINDOW_BUYBUTTONLABEL, 'cancelBtnLabel': MENU.BOOSTERBUYWINDOW_CANCELBUTTONLABEL}) stats = self.itemsCache.items.stats itemPrice = self.__getItemPrice() currency = itemPrice.getCurrency(byWeight=True) vehicle = g_currentVehicle.item self.as_updateDataS({'actionPriceData': packItemActionTooltipData(self.__item, isBuying=True), 'itemPrice': itemPrice.price.getSignValue(currency), 'itemCount': self.__item.inventoryCount, 'currency': currency, 'currencyCount': stats.money.getSignValue(currency), 'rearmCheckboxValue': vehicle.isAutoBattleBoosterEquip() if vehicle is not None else False}) return
def _buildModuleData(self, module, isInstalledInSlot, stats): isEnoughCurrency = True price = module.buyPrice currency = price.getCurrency() inInventory = module.isInInventory isInstalled = module.isInstalled(self._vehicle) isBought = inInventory or isInstalled priceValue = price.get(currency) if isBought: isFit, reason = True, '' else: isFit, reason = module.mayPurchase(stats['money']) if not isFit: if reason == 'credits_error': isEnoughCurrency = False isFit = module.mayPurchaseWithExchange(stats['money'], stats['exchangeRate']) if isFit and reason != 'unlock_error': reason = _getInstallReason(module, self._vehicle, reason, self._slotIndex) moduleData = self._buildCommonModuleData(module, reason) moduleData.update({'targetVisible': isBought, 'price': BigWorld.wg_getIntegralFormat(priceValue), 'showPrice': not isBought, 'isEnoughCurrency': isEnoughCurrency, 'currency': currency, 'actionPriceData': packItemActionTooltipData(module) if price != module.defaultPrice else None, 'isSelected': isInstalledInSlot, 'disabled': not isFit or isInstalled and not isInstalledInSlot}) return moduleData
def _buildModuleData(self, module, isInstalledInSlot, stats): isEnoughCurrency = True price = module.buyPrice currency = price.getCurrency() inInventory = module.isInInventory isInstalled = module.isInstalled(self._vehicle) isBought = inInventory or isInstalled priceValue = price.get(currency) if isBought: isFit, reason = True, "" else: isFit, reason = module.mayPurchase(stats["money"]) if not isFit: if reason == "credits_error": isEnoughCurrency = False isFit = module.mayPurchaseWithExchange(stats["money"], stats["exchangeRate"]) if isFit and reason != "unlock_error": reason = _getInstallReason(module, self._vehicle, reason, self._slotIndex) moduleData = self._buildCommonModuleData(module, reason) moduleData.update( { "targetVisible": isBought, "price": BigWorld.wg_getIntegralFormat(priceValue), "showPrice": not isBought, "isEnoughCurrency": isEnoughCurrency, "currency": currency, "actionPriceData": packItemActionTooltipData(module) if price != module.defaultPrice else None, "isSelected": isInstalledInSlot, "disabled": not isFit or isInstalled and not isInstalledInSlot, } ) return moduleData
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 = packItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']: action = packItemRentActionTooltipData(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 populateTechnicalMaintenance(self): money = self.itemsCache.items.stats.money data = {Currency.CREDITS: money.getSignValue(Currency.CREDITS), Currency.GOLD: money.getSignValue(Currency.GOLD)} if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item gun = vehicle.descriptor.gun cassetteText = '' if not isAutoReloadGun(gun): cassetteCount = vehicle.descriptor.gun.clip[0] if cassetteCount > 1: cassetteText = makeString('#menu:technicalMaintenance/ammoTitleEx') % cassetteCount else: cassetteCount = 1 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': cassetteText, 'shells': [], 'infoAfterShellBlock': ''}) sellGoldShellsForCredits = self.itemsCache.items.shop.isEnabledBuyingGoldShellsForCredits shells = data['shells'] for shell in vehicle.shells: if shell.isHidden: continue if sellGoldShellsForCredits: prices = shell.buyPrices.getSum().price else: prices = shell.buyPrices.itemPrice.price currency = shell.buyPrices.itemPrice.price.getCurrency(byWeight=True) action = None buyPrice = shell.getBuyPrice() if buyPrice.isActionPrice(): action = packItemActionTooltipData(shell) shells.append({'id': str(shell.intCD), 'type': shell.type, 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor.icon[0], 'count': shell.count, 'userCount': shell.defaultCount, 'step': cassetteCount, 'inventoryCount': shell.inventoryCount, 'prices': prices.toMoneyTuple(), 'currency': currency, 'ammoName': shell.longUserNameAbbr, 'tableName': shell.getShortInfo(vehicle, True), 'maxAmmo': vehicle.gun.maxAmmo, 'userCredits': money.toDict(), 'actionPriceData': action, 'desc': MENU.SHELLLISTITEMRENDERER_REPLACE}) self.as_setDataS(data) return
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 money = 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 Currency.CREDITS else: priceCurrency = module.getBuyPriceCurrency() action = None if price != defaultPrice: action = packItemActionTooltipData(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': money.toDict(), '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 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 money = 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 Currency.CREDITS else: priceCurrency = module.getBuyPriceCurrency() action = None if price != defaultPrice: action = packItemActionTooltipData(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': money.toDict(), '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 _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 = packItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage['rentPrice'] != minRentPricePackage[ 'defaultRentPrice']: action = packItemRentActionTooltipData(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 __init__(self, item, itemType=None): super(_VSDItemData, self).__init__() self.__fittingItem = item self._itemRemovalPrice = None self.__itemType = itemType itemPrice = item.sellPrices.itemPrice self._itemSellPrice = _VSDMoney(item.sellPrices.itemPrice.price) self._flashData = { 'count': 1, 'toInventory': True, 'userName': item.userName, 'sellPrice': itemPrice.price.toMoneyTuple() } if itemPrice.isActionPrice(): self._flashData['action'] = packItemActionTooltipData(item, False) return
def populateTechnicalMaintenance(self): money = g_itemsCache.items.stats.money goldShellsForCredits = g_itemsCache.items.shop.isEnabledBuyingGoldShellsForCredits data = {'gold': money.gold, 'credits': money.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: if shell.isHidden: continue price = shell.altPrice defaultPrice = shell.defaultAltPrice action = None if price != defaultPrice: action = packItemActionTooltipData(shell) shells.append({'id': str(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': money.toDict(), 'actionPriceData': action}) self.as_setDataS(data) return
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 = packItemActionTooltipData(item) elif minRentPricePackage: if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']: action = packItemRentActionTooltipData(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 _buildModuleData(self, module, isInstalledInSlot, stats): isEnoughCurrency = True price = module.buyPrice currency = price.getCurrency() inInventory = module.isInInventory isInstalled = module.isInstalled(self._vehicle) isBought = inInventory or isInstalled priceValue = price.get(currency) if isBought: isFit, reason = True, '' else: isFit, reason = module.mayPurchase(stats['money']) if not isFit: if reason == 'credits_error': isEnoughCurrency = False isFit = module.mayPurchaseWithExchange( stats['money'], stats['exchangeRate']) if isFit and reason != 'unlock_error': reason = _getInstallReason(module, self._vehicle, reason, self._slotIndex) moduleData = self._buildCommonModuleData(module, reason) moduleData.update({ 'targetVisible': isBought, 'price': BigWorld.wg_getIntegralFormat(priceValue), 'showPrice': not isBought, 'isEnoughCurrency': isEnoughCurrency, 'currency': currency, 'actionPriceData': packItemActionTooltipData(module) if price != module.defaultPrice else None, 'isSelected': isInstalledInSlot, 'disabled': not isFit or isInstalled and not isInstalledInSlot }) return moduleData
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 = tankMenCount * Money(credits=tankMenStudyPrice[1]['credits'], gold=tankMenStudyPrice[2]['gold']) defTankMenStudyPrice = shopDefaults.tankmanCost defTotalTankMenStudePrice = tankMenCount * Money(credits=defTankMenStudyPrice[1]['credits'], gold=defTankMenStudyPrice[2]['gold']) studyPriceCreditsActionData = None if totalTankMenStudePrice != defTotalTankMenStudePrice: studyPriceCreditsActionData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'creditsTankmanCost', True, totalTankMenStudePrice, defTotalTankMenStudePrice) studyPriceGoldActionData = None if totalTankMenStudePrice != defTotalTankMenStudePrice: studyPriceGoldActionData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'goldTankmanCost', True, totalTankMenStudePrice, defTotalTankMenStudePrice) vehiclePricesActionData = None if vehicle.buyPrice != vehicle.defaultPrice: vehiclePricesActionData = packItemActionTooltipData(vehicle) ammoPrice = ZERO_MONEY defAmmoPrice = ZERO_MONEY for shell in vehicle.gun.defaultAmmo: ammoPrice += shell.buyPrice * shell.defaultCount defAmmoPrice += shell.defaultPrice * shell.defaultCount ammoActionPriceData = None if ammoPrice != defAmmoPrice: ammoActionPriceData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.AMMO, str(vehicle.intCD), True, ammoPrice, defAmmoPrice) slotPrice = shop.getVehicleSlotsPrice(stats.vehicleSlots) slotDefaultPrice = shopDefaults.getVehicleSlotsPrice(stats.vehicleSlots) slotActionPriceData = None if slotPrice != slotDefaultPrice: slotActionPriceData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'slotsPrices', True, Money(gold=slotPrice), Money(gold=slotDefaultPrice)) tankmenLabel = i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMENLABEL, count=text_styles.titleFont(i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMEN) + ' ' + str(tankMenCount))) initData = {'expanded': windowExpanded, 'name': vehicle.userName, 'shortName': vehicle.shortUserName, '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.credits, 'studyPriceCreditsActionData': studyPriceCreditsActionData, 'studyPriceGold': totalTankMenStudePrice.gold, 'studyPriceGoldActionData': studyPriceGoldActionData, 'vehiclePrices': vehicle.buyPrice, 'vehiclePricesActionData': vehiclePricesActionData, 'ammoPrice': ammoPrice.credits, '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 _getItemActionData(self, item): if item.sellPrice != item.defaultSellPrice and not item.isRented: return packItemActionTooltipData(item, False) else: return None
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) sellPrice = vehicle.sellPrice sellForGold = sellPrice.gold > 0 priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR priceTextValue = _ms(DIALOGS.VEHICLESELLDIALOG_PRICE_SIGN_ADD) + _ms( BigWorld.wg_getIntegralFormat( sellPrice.gold if sellForGold else sellPrice.credits)) currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS 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 sellPrice != vehicle.defaultSellPrice: vehicleAction = packItemActionTooltipData(vehicle, False) if vehicle.isElite: description = TOOLTIPS.tankcaruseltooltip_vehicletype_elite( vehicle.type) else: description = DIALOGS.vehicleselldialog_vehicletype(vehicle.type) levelStr = text_styles.concatStylesWithSpace( text_styles.stats(int2roman(vehicle.level)), text_styles.main(_ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_LEVEL))) tankmenGoingToBuffer, deletedTankmen = self.restore.getTankmenDeletedBySelling( vehicle) deletedCount = len(deletedTankmen) if deletedCount > 0: recoveryBufferFull = True deletedStr = formatDeletedTankmanStr(deletedTankmen[0]) maxCount = self.restore.getMaxTankmenBufferLength() currCount = len(self.restore.getDismissedTankmen()) if deletedCount == 1: crewTooltip = text_styles.concatStylesToMultiLine( text_styles.middleTitle( _ms(TOOLTIPS. VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main( _ms(TOOLTIPS. VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_BODY, maxVal=maxCount, curVal=currCount, sourceName=tankmenGoingToBuffer[-1].fullUserName, targetInfo=deletedStr))) else: crewTooltip = text_styles.concatStylesToMultiLine( text_styles.middleTitle( _ms(TOOLTIPS. VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main( _ms(TOOLTIPS. DISMISSTANKMANDIALOG_BUFFERISFULLMULTIPLE_BODY, deletedStr=deletedStr, extraCount=deletedCount - 1, maxCount=maxCount, currCount=currCount))) else: crewTooltip = None recoveryBufferFull = False barracksDropDownData = [{ 'label': _ms(MENU.BARRACKS_BTNUNLOAD) }, { 'label': _ms(MENU.BARRACKS_BTNDISSMISS) }] sellVehicleData = { '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': sellPrice, 'priceTextValue': priceTextValue, 'priceTextColor': priceTextColor, 'currencyIcon': currencyIcon, 'action': vehicleAction, 'hasCrew': vehicle.hasCrew, 'isRented': vehicle.isRented, 'description': description, 'levelStr': levelStr, 'priceLabel': _ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_EMPTYSELLPRICE), 'crewLabel': _ms(DIALOGS.VEHICLESELLDIALOG_CREW_LABEL), 'crewTooltip': crewTooltip, 'barracksDropDownData': barracksDropDownData, 'crewRecoveryBufferFull': recoveryBufferFull } onVehicleOptionalDevices = [] for o in vehicle.optDevices: if o is not None: action = None if o.sellPrice != o.defaultSellPrice: action = packItemActionTooltipData(o, False) data = { 'intCD': o.intCD, 'isRemovable': o.isRemovable, 'userName': o.userName, 'sellPrice': o.sellPrice, 'toInventory': True, 'action': action } onVehicleOptionalDevices.append(data) onVehicleoShells = [] for shell in vehicle.shells: if shell is not None: action = None if shell.sellPrice != shell.defaultSellPrice: action = packItemActionTooltipData(shell, False) data = { 'intCD': shell.intCD, 'count': shell.count, 'sellPrice': shell.sellPrice, 'userName': shell.userName, 'kind': shell.type, 'toInventory': shell in otherVehsShells or shell.isPremium, 'action': action } onVehicleoShells.append(data) onVehicleEquipments = [] for equipmnent in vehicle.eqs: if equipmnent is not None: action = None if equipmnent.sellPrice != equipmnent.defaultSellPrice: action = packItemActionTooltipData(equipmnent, False) data = { 'intCD': equipmnent.intCD, 'userName': equipmnent.userName, 'sellPrice': equipmnent.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 = packItemActionTooltipData(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 = Money(gold=removePrice) defRemovePrice = Money(gold=items.shop.defaults.paidRemovalCost) removeAction = None if removePrices != defRemovePrice: removeAction = packActionTooltipData( ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True, removePrices, defRemovePrice) settings = self.getDialogSettings() isSlidingComponentOpened = settings['isOpened'] self.as_setDataS({ 'accountGold': items.stats.gold, 'sellVehicleVO': sellVehicleData, 'optionalDevicesOnVehicle': onVehicleOptionalDevices, 'shellsOnVehicle': onVehicleoShells, 'equipmentsOnVehicle': onVehicleEquipments, 'modulesInInventory': inInventoryModules, 'shellsInInventory': inInventoryShells, 'removeActionPrice': removeAction, 'removePrice': removePrice, 'isSlidingComponentOpened': isSlidingComponentOpened }) return
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 = tankMenCount * Money( credits=tankMenStudyPrice[1]['credits'], gold=tankMenStudyPrice[2]['gold']) defTankMenStudyPrice = shopDefaults.tankmanCost defTotalTankMenStudePrice = tankMenCount * Money( credits=defTankMenStudyPrice[1]['credits'], gold=defTankMenStudyPrice[2]['gold']) studyPriceCreditsActionData = None if totalTankMenStudePrice != defTotalTankMenStudePrice: studyPriceCreditsActionData = packActionTooltipData( ACTION_TOOLTIPS_TYPE.ECONOMICS, 'creditsTankmanCost', True, totalTankMenStudePrice, defTotalTankMenStudePrice) studyPriceGoldActionData = None if totalTankMenStudePrice != defTotalTankMenStudePrice: studyPriceGoldActionData = packActionTooltipData( ACTION_TOOLTIPS_TYPE.ECONOMICS, 'goldTankmanCost', True, totalTankMenStudePrice, defTotalTankMenStudePrice) vehiclePricesActionData = None if vehicle.buyPrice != vehicle.defaultPrice: vehiclePricesActionData = packItemActionTooltipData(vehicle) ammoPrice = ZERO_MONEY defAmmoPrice = ZERO_MONEY for shell in vehicle.gun.defaultAmmo: ammoPrice += shell.buyPrice * shell.defaultCount defAmmoPrice += shell.defaultPrice * shell.defaultCount ammoActionPriceData = None if ammoPrice != defAmmoPrice: ammoActionPriceData = packActionTooltipData( ACTION_TOOLTIPS_TYPE.AMMO, str(vehicle.intCD), True, ammoPrice, defAmmoPrice) slotPrice = shop.getVehicleSlotsPrice(stats.vehicleSlots) slotDefaultPrice = shopDefaults.getVehicleSlotsPrice( stats.vehicleSlots) slotActionPriceData = None if slotPrice != slotDefaultPrice: slotActionPriceData = packActionTooltipData( ACTION_TOOLTIPS_TYPE.ECONOMICS, 'slotsPrices', True, Money(gold=slotPrice), Money(gold=slotDefaultPrice)) tankmenLabel = i18n.makeString( DIALOGS.BUYVEHICLEDIALOG_TANKMENLABEL, count=text_styles.titleFont( i18n.makeString(DIALOGS.BUYVEHICLEDIALOG_TANKMEN) + ' ' + str(tankMenCount))) initData = { 'expanded': windowExpanded, 'name': vehicle.userName, 'shortName': vehicle.shortUserName, '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.credits, 'studyPriceCreditsActionData': studyPriceCreditsActionData, 'studyPriceGold': totalTankMenStudePrice.gold, 'studyPriceGoldActionData': studyPriceGoldActionData, 'vehiclePrices': vehicle.buyPrice, 'vehiclePricesActionData': vehiclePricesActionData, 'ammoPrice': ammoPrice.credits, '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.addCurrencyCallback(Currency.GOLD, self.onSetGoldHndlr) self.itemsCache.onSyncCompleted += self.__shopResyncHandler items = self.itemsCache.items vehicle = items.getVehicle(self.__vehInvID) sellPrice = vehicle.sellPrices.itemPrice.price sellCurrency = sellPrice.getCurrency(byWeight=True) sellForGold = sellCurrency == Currency.GOLD priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR priceTextValue = _ms(DIALOGS.VEHICLESELLDIALOG_PRICE_SIGN_ADD) + _ms( BigWorld.wg_getIntegralFormat( sellPrice.getSignValue(sellCurrency))) currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS invVehs = items.getVehicles(REQ_CRITERIA.INVENTORY) self.checkControlQuestion(self.__checkUsefulTankman) 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.sellPrices.itemPrice.isActionPrice(): vehicleAction = packItemActionTooltipData(vehicle, False) if vehicle.isElite: description = TOOLTIPS.tankcaruseltooltip_vehicletype_elite( vehicle.type) else: description = DIALOGS.vehicleselldialog_vehicletype(vehicle.type) levelStr = text_styles.concatStylesWithSpace( text_styles.stats(int2roman(vehicle.level)), text_styles.main(_ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_LEVEL))) tankmenGoingToBuffer, deletedTankmen = self.restore.getTankmenDeletedBySelling( vehicle) deletedCount = len(deletedTankmen) if deletedCount > 0: deletedStr = formatDeletedTankmanStr(deletedTankmen[0]) maxCount = self.restore.getMaxTankmenBufferLength() currCount = len(self.restore.getDismissedTankmen()) if deletedCount == 1: crewTooltip = text_styles.concatStylesToMultiLine( text_styles.middleTitle( _ms(TOOLTIPS. VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main( _ms(TOOLTIPS. VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_BODY, maxVal=maxCount, curVal=currCount, sourceName=tankmenGoingToBuffer[-1].fullUserName, targetInfo=deletedStr))) else: crewTooltip = text_styles.concatStylesToMultiLine( text_styles.middleTitle( _ms(TOOLTIPS. VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main( _ms(TOOLTIPS. DISMISSTANKMANDIALOG_BUFFERISFULLMULTIPLE_BODY, deletedStr=deletedStr, extraCount=deletedCount - 1, maxCount=maxCount, currCount=currCount))) else: crewTooltip = None if vehicle.isCrewLocked: hasCrew = False else: hasCrew = vehicle.hasCrew barracksDropDownData = [{ 'label': _ms(MENU.BARRACKS_BTNUNLOAD) }, { 'label': _ms(MENU.BARRACKS_BTNDISSMISS) }] sellVehicleData = { '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': sellPrice.toMoneyTuple(), 'priceTextValue': priceTextValue, 'priceTextColor': priceTextColor, 'currencyIcon': currencyIcon, 'action': vehicleAction, 'hasCrew': hasCrew, 'isRented': vehicle.isRented, 'description': description, 'levelStr': levelStr, 'priceLabel': _ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_EMPTYSELLPRICE), 'crewLabel': _ms(DIALOGS.VEHICLESELLDIALOG_CREW_LABEL), 'crewTooltip': crewTooltip, 'barracksDropDownData': barracksDropDownData } currentGoldBalance = self.itemsCache.items.stats.money.get( Currency.GOLD, 0) onVehicleOptionalDevices = [] for o in vehicle.optDevices: if o is not None: itemPrice = o.sellPrices.itemPrice action = None if itemPrice.isActionPrice(): action = packItemActionTooltipData(o, False) removalPrice = o.getRemovalPrice(items) removeAction = None if removalPrice.isActionPrice(): removeAction = packActionTooltipData( ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True, removalPrice.price, removalPrice.defPrice) removalPriceInGold = removalPrice.price.get(Currency.GOLD, 0) enoughGold = currentGoldBalance >= removalPriceInGold if enoughGold: currentGoldBalance -= removalPriceInGold data = { 'intCD': o.intCD, 'isRemovable': o.isRemovable, 'userName': o.userName, 'sellPrice': itemPrice.price.toMoneyTuple(), 'toInventory': enoughGold, 'action': action, 'removePrice': removalPrice.price.toMoneyTuple(), 'removeActionPrice': removeAction } onVehicleOptionalDevices.append(data) onVehicleoShells = [] for shell in vehicle.shells: if shell is not None: itemPrice = shell.sellPrices.itemPrice action = None if itemPrice.isActionPrice(): action = packItemActionTooltipData(shell, False) data = { 'intCD': shell.intCD, 'count': shell.count, 'sellPrice': itemPrice.price.toMoneyTuple(), 'userName': shell.userName, 'kind': shell.type, 'toInventory': shell in otherVehsShells or shell.isPremium, 'action': action } onVehicleoShells.append(data) onVehicleEquipments = [] for equipmnent in vehicle.equipment.regularConsumables.getInstalledItems( ): action = None if equipmnent.sellPrices.itemPrice.isActionPrice(): action = packItemActionTooltipData(equipmnent, False) data = { 'intCD': equipmnent.intCD, 'userName': equipmnent.userName, 'sellPrice': equipmnent.sellPrices.itemPrice.price.toMoneyTuple(), 'toInventory': True, 'action': action } onVehicleEquipments.append(data) onVehicleBattleBoosters = [] for booster in vehicle.equipment.battleBoosterConsumables.getInstalledItems( ): data = { 'intCD': booster.intCD, 'userName': booster.userName, 'sellPrice': MONEY_UNDEFINED.toMoneyTuple(), 'onlyToInventory': True } onVehicleBattleBoosters.append(data) inInventoryModules = [] for m in modules: inInventoryModules.append({ 'intCD': m.intCD, 'inventoryCount': m.inventoryCount, 'toInventory': True, 'sellPrice': m.sellPrices.itemPrice.price.toMoneyTuple() }) inInventoryShells = [] for s in shells: action = None itemPrice = s.sellPrices.itemPrice if itemPrice.isActionPrice(): action = packItemActionTooltipData(s, False) inInventoryShells.append({ 'intCD': s.intCD, 'count': s.inventoryCount, 'sellPrice': itemPrice.price.toMoneyTuple(), 'userName': s.userName, 'kind': s.type, 'toInventory': s in otherVehsShells or s.isPremium, 'action': action }) customizationOnVehicle = [] settings = self.getDialogSettings() isSlidingComponentOpened = settings['isOpened'] self.as_setDataS({ 'accountMoney': items.stats.money.toMoneyTuple(), 'sellVehicleVO': sellVehicleData, 'optionalDevicesOnVehicle': onVehicleOptionalDevices, 'shellsOnVehicle': onVehicleoShells, 'equipmentsOnVehicle': onVehicleEquipments, 'modulesInInventory': inInventoryModules, 'shellsInInventory': inInventoryShells, 'isSlidingComponentOpened': isSlidingComponentOpened, 'battleBoostersOnVehicle': onVehicleBattleBoosters, 'customizationOnVehicle': customizationOnVehicle }) return
def _getItemActionData(self, item): return packItemActionTooltipData( item, False) if item.sellPrices.itemPrice.isActionPrice( ) and not item.isRented else None
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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = Money(gold=removePrice) defRemovePrice = Money(gold=items.shop.defaults.paidRemovalCost) removeAction = None if removePrices != defRemovePrice: removeAction = packActionTooltipData( ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True, removePrices, 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 populateTechnicalMaintenanceEquipment(self, eId1=None, currency1=None, eId2=None, currency2=None, eId3=None, currency3=None, slotIndex=None): items = self.itemsCache.items vehicle = g_currentVehicle.item money = self.itemsCache.items.stats.money installedItems = vehicle.equipment.regularConsumables 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 = [] for _id in (eId1, eId2, eId3): if _id is not None: item = items.getItemByCD(_id) else: item = None selectedItems.append(item) currencies = [currency1, currency2, currency3] inventoryVehicles = items.getVehicles(_RC.INVENTORY).values() itemsCriteria = ~_RC.HIDDEN | _RC.VEHICLE.SUITABLE( [vehicle], [GUI_ITEM_TYPE.EQUIPMENT]) data = sorted(self.itemsCache.items.getItems(GUI_ITEM_TYPE.EQUIPMENT, itemsCriteria).values(), reverse=True) vehicle.equipment.setRegularConsumables( RegularEquipmentConsumables(*selectedItems)) modules = [] for module in data: fits = [] for i in xrange(3): fits.append(self.__getStatus(module.mayInstall(vehicle, i)[1])) buyPrice = module.getBuyPrice() if items.shop.isEnabledBuyingGoldEqsForCredits: prices = module.buyPrices.getSum().price else: prices = module.buyPrices.itemPrice.price inventoryCount = module.inventoryCount index = None if module in selectedItems: index = selectedItems.index(module) priceCurrency = currencies[index] or Currency.CREDITS if inventoryCount and module not in installedItems: inventoryCount -= 1 else: priceCurrency = buyPrice.getCurrency(byWeight=True) action = None if buyPrice.isActionPrice(): action = packItemActionTooltipData(module) modules.append({ 'id': str(module.intCD), 'name': module.userName, 'desc': module.fullDescription, 'target': module.getTarget(vehicle), 'compactDescr': module.intCD, 'prices': prices.toMoneyTuple(), 'currency': priceCurrency, 'icon': module.icon, 'index': index, 'inventoryCount': module.inventoryCount, 'vehicleCount': len(module.getInstalledVehicles(inventoryVehicles)), 'count': inventoryCount, 'fits': fits, 'userCredits': money.toDict(), 'actionPriceData': action, 'moduleLabel': module.getGUIEmblemID() }) vehicle.equipment.setRegularConsumables(installedItems) installed = [] for e in installedItems: if e is not None: installed.append(e.intCD) installed.append(None) setup = [] for e in selectedItems: if e is not None: setup.append(e.intCD) setup.append(None) self.__seveCurrentLayout(eId1=eId1, currency1=currency1, eId2=eId2, currency2=currency2, eId3=eId3, currency3=currency3) self._setEquipment(installed, setup, modules) return
def _getItemPriceActionData(self, vehicle): return packItemActionTooltipData( vehicle) if vehicle.buyPrices.itemPrice.isActionPrice() else None
def _getItemActionData(self, item): if item.sellPrice != item.defaultSellPrice and not item.isRented: return packItemActionTooltipData(item, False) else: return None
def _getItemPriceActionData(self, vehicle): if vehicle.buyPrice != vehicle.defaultPrice: return packItemActionTooltipData(vehicle) else: return None
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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = packItemActionTooltipData(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 = Money(gold=removePrice) defRemovePrice = Money(gold=items.shop.defaults.paidRemovalCost) removeAction = None if removePrices != defRemovePrice: removeAction = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True, removePrices, 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 _getItemPriceActionData(self, vehicle): if vehicle.buyPrice != vehicle.defaultPrice: return packItemActionTooltipData(vehicle) else: return None
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) sellPrice = vehicle.sellPrice sellForGold = sellPrice.gold > 0 priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR priceTextValue = _ms(DIALOGS.VEHICLESELLDIALOG_PRICE_SIGN_ADD) + _ms(BigWorld.wg_getIntegralFormat(sellPrice.gold if sellForGold else sellPrice.credits)) currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS 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 sellPrice != vehicle.defaultSellPrice: vehicleAction = packItemActionTooltipData(vehicle, False) if vehicle.isElite: description = TOOLTIPS.tankcaruseltooltip_vehicletype_elite(vehicle.type) else: description = DIALOGS.vehicleselldialog_vehicletype(vehicle.type) levelStr = text_styles.concatStylesWithSpace(text_styles.stats(int2roman(vehicle.level)), text_styles.main(_ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_LEVEL))) restoreController = getRestoreController() tankmenGoingToBuffer, deletedTankmen = restoreController.getTankmenDeletedBySelling(vehicle) deletedCount = len(deletedTankmen) if deletedCount > 0: recoveryBufferFull = True deletedStr = formatDeletedTankmanStr(deletedTankmen[0]) maxCount = restoreController.getMaxTankmenBufferLength() currCount = len(restoreController.getDismissedTankmen()) if deletedCount == 1: crewTooltip = text_styles.concatStylesToMultiLine(text_styles.middleTitle(_ms(TOOLTIPS.VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main(_ms(TOOLTIPS.VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_BODY, maxVal=maxCount, curVal=currCount, sourceName=tankmenGoingToBuffer[-1].fullUserName, targetInfo=deletedStr))) else: crewTooltip = text_styles.concatStylesToMultiLine(text_styles.middleTitle(_ms(TOOLTIPS.VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main(_ms(TOOLTIPS.DISMISSTANKMANDIALOG_BUFFERISFULLMULTIPLE_BODY, deletedStr=deletedStr, extraCount=deletedCount - 1, maxCount=maxCount, currCount=currCount))) else: crewTooltip = None recoveryBufferFull = False barracksDropDownData = [{'label': _ms(MENU.BARRACKS_BTNUNLOAD)}, {'label': _ms(MENU.BARRACKS_BTNDISSMISS)}] sellVehicleData = {'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': sellPrice, 'priceTextValue': priceTextValue, 'priceTextColor': priceTextColor, 'currencyIcon': currencyIcon, 'action': vehicleAction, 'hasCrew': vehicle.hasCrew, 'isRented': vehicle.isRented, 'description': description, 'levelStr': levelStr, 'priceLabel': _ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_EMPTYSELLPRICE), 'crewLabel': _ms(DIALOGS.VEHICLESELLDIALOG_CREW_LABEL), 'crewTooltip': crewTooltip, 'barracksDropDownData': barracksDropDownData, 'crewRecoveryBufferFull': recoveryBufferFull} onVehicleOptionalDevices = [] for o in vehicle.optDevices: if o is not None: action = None if o.sellPrice != o.defaultSellPrice: action = packItemActionTooltipData(o, False) data = {'intCD': o.intCD, 'isRemovable': o.isRemovable, 'userName': o.userName, 'sellPrice': o.sellPrice, 'toInventory': True, 'action': action} onVehicleOptionalDevices.append(data) onVehicleoShells = [] for shell in vehicle.shells: if shell is not None: action = None if shell.sellPrice != shell.defaultSellPrice: action = packItemActionTooltipData(shell, False) data = {'intCD': shell.intCD, 'count': shell.count, 'sellPrice': shell.sellPrice, 'userName': shell.userName, 'kind': shell.type, 'toInventory': shell in otherVehsShells or shell.isPremium, 'action': action} onVehicleoShells.append(data) onVehicleEquipments = [] for equipmnent in vehicle.eqs: if equipmnent is not None: action = None if equipmnent.sellPrice != equipmnent.defaultSellPrice: action = packItemActionTooltipData(equipmnent, False) data = {'intCD': equipmnent.intCD, 'userName': equipmnent.userName, 'sellPrice': equipmnent.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 = packItemActionTooltipData(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 = Money(gold=removePrice) defRemovePrice = Money(gold=items.shop.defaults.paidRemovalCost) removeAction = None if removePrices != defRemovePrice: removeAction = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True, removePrices, defRemovePrice) settings = self.getDialogSettings() isSlidingComponentOpened = settings['isOpened'] self.as_setDataS({'accountGold': items.stats.gold, 'sellVehicleVO': sellVehicleData, 'optionalDevicesOnVehicle': onVehicleOptionalDevices, 'shellsOnVehicle': onVehicleoShells, 'equipmentsOnVehicle': onVehicleEquipments, 'modulesInInventory': inInventoryModules, 'shellsInInventory': inInventoryShells, 'removeActionPrice': removeAction, 'removePrice': removePrice, 'isSlidingComponentOpened': isSlidingComponentOpened}) return
def __getSellVehicleData(self): sellCurrency = self.__vehicleSellPrice.getCurrency(byWeight=True) sellForGold = sellCurrency == Currency.GOLD priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR add = backport.text( R.strings.dialogs.vehicleSellDialog.price.sign.add()) priceTextValue = add + backport.getIntegralFormat( self.__vehicleSellPrice.getSignValue(sellCurrency)) currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS vehicleAction = None if self.__vehicle.sellPrices.itemPrice.isActionPrice(): vehicleAction = packItemActionTooltipData(self.__vehicle, False) vehType = self.__vehicle.type if self.__vehicle.isElite: description = backport.text( R.strings.tooltips.tankCaruselTooltip.vehicleType.elite.dyn( vehType.replace('-', '_'))()) else: description = backport.text( R.strings.dialogs.vehicleSellDialog.vehicleType.dyn( vehType.replace('-', '_'))()) levelText = backport.text( R.strings.dialogs.vehicleSellDialog.vehicle.level()) levelStr = text_styles.concatStylesWithSpace( text_styles.stats(int2roman(self.__vehicle.level)), text_styles.main(levelText)) hasCrew, crewTooltip = self.__getCrewData() barracksDropDownData = [] for buttons in _BARRACKS_DROP_DOWN_DATA_PROVIDER: barracksDropDownData.append({ key: backport.text(value) for key, value in buttons.iteritems() }) return { 'intCD': self.__vehicle.intCD, 'userName': self.__vehicle.userName, 'icon': self.__vehicle.icon, 'level': self.__vehicle.level, 'isElite': self.__vehicle.isElite, 'isPremium': self.__vehicle.isPremium, 'hasNationGroup': self.__vehicle.hasNationGroup, 'type': vehType, 'nationID': self.__vehicle.nationID, 'sellPrice': self.__vehicleSellPrice.toMoneyTuple(), 'priceTextValue': priceTextValue, 'priceTextColor': priceTextColor, 'currencyIcon': currencyIcon, 'action': vehicleAction, 'hasCrew': hasCrew, 'isRented': self.__vehicle.isRented, 'description': description, 'levelStr': levelStr, 'priceLabel': backport.text( R.strings.dialogs.vehicleSellDialog.vehicle.emptySellPrice()), 'crewLabel': backport.text(R.strings.dialogs.vehicleSellDialog.crew.label()), 'inNationGroupDescription': backport.text( R.strings.dialogs.vehicleSellDialog.message.multinational()), 'crewTooltip': crewTooltip, 'barracksDropDownData': barracksDropDownData }