def __getItemRentInfo(self, item): """ Get formatted vehicle rent info :param item: <Vehicle> :return: <str> """ if item.isRented: formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR) return formatter.getRentLeftStr( '#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _=None: ''.join( [makeString(key % countType), ': ', str(count)])) elif item.isRentable and item.isRentAvailable: minRentPricePackage = item.getRentPackage() priceText = '' discountText = '' if minRentPricePackage: minRentPriceValue = minRentPricePackage['rentPrice'] actionPrc = item.getRentPackageActionPrc( minRentPricePackage['days']) currency = minRentPriceValue.getCurrency() price = minRentPriceValue.getSignValue(currency) priceText = makeHtmlString( 'html_templates:lobby/quests/actions', currency, {'value': price}) if actionPrc != 0: discountText = makeString( '#menu:shop/menu/vehicle/rent/discount', discount=text_styles.gold('{} %'.format(actionPrc))) rentText = makeString('#menu:shop/menu/vehicle/rent/available', price=priceText) return '{} {}'.format(rentText, discountText) else: return ''
def _buildVehicle(self, item): vo = super(_RentVehiclesDataProvider, self)._buildVehicle(item) rentText = RentLeftFormatter(item.rentInfo, item.isPremiumIGR).getRentLeftStr() or _ms(MENU.STORE_VEHICLESTATES_RENTALISOVER) vo.update({'isMoneyEnough': True, 'enabled': item.canSell and item.rentalIsOver and not item.isTelecomRent, 'rentText': rentText, 'rentIcon': RES_ICONS.MAPS_ICONS_LIBRARY_CLOCKICON_1, 'contextMenuId': CONTEXT_MENU_HANDLER_TYPE.STORAGE_VEHICLES_RENTED_ITEM}) return vo
def _getItemRentLeftTime(self, item): if item.isRented: formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR) return formatter.getRentLeftStr( '#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _=None: ''.join( [makeString(key % countType), ': ', str(count)])) else: return None
def __getRootStatusStr(root): return text_styles.concatStylesToSingleLine( icons.makeImageTag(backport.image( R.images.gui.maps.icons.library.ClockIcon_1()), width=38, height=38, vSpace=-14), RentLeftFormatter(root.rentInfo).getRentLeftStr( strForSpecialTimeFormat=backport.text( R.strings.menu.research.status.rentLeft())) ) if root.isRented and not root.rentalIsOver and not root.isTelecom and not root.isPremiumIGR else ''
def __getItemRentInfo(self, item): """ Get formatted vehicle rent info :param item: <Vehicle> :return: <str> """ if item.isRented: formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR) return formatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: ''.join([makeString(key % countType), ': ', str(count)])) elif item.isRentable and item.isRentAvailable: return makeString('#menu:shop/menu/vehicle/rent/available') else: return ''
def updateVehicles(self, vehicles=None, updateFallout=True): isSet = vehicles is None filterCriteria = REQ_CRITERIA.INVENTORY if vehicles is not None: filterCriteria |= REQ_CRITERIA.IN_CD_LIST(vehicles) items = g_itemsCache.items filteredVehs = items.getVehicles(filterCriteria) if vehicles is None: vehicles = filteredVehs.keys() isSuitablePredicate = lambda vehIntCD: True if self.preQueueFunctional.getQueueType( ) == constants.QUEUE_TYPE.HISTORICAL: battle = self.preQueueFunctional.getItemData() if battle is not None: isSuitablePredicate = battle.canParticipateWith hasEmptySlots = self.__multiselectionMode and len( self.__falloutCtrl.getEmptySlots()) > 0 vehsData = {} for intCD in vehicles: vehicle = filteredVehs.get(intCD) if vehicle is not None: vState, vStateLvl = vehicle.getState() isSuitableVeh = vState != Vehicle.VEHICLE_STATE.BATTLE and not isSuitablePredicate( vehicle.intCD) isSuitableVeh |= self.__multiselectionMode and not vehicle.isFalloutAvailable if isSuitableVeh: vState, vStateLvl = Vehicle.VEHICLE_STATE.NOT_SUITABLE, Vehicle.VEHICLE_STATE_LEVEL.WARNING canSelect, tooltip = self.__falloutCtrl.canSelectVehicle( vehicle) rentInfoStr = RentLeftFormatter( vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr() vehsData[intCD] = self._getVehicleData(vehicle, vState, vStateLvl, rentInfoStr, hasEmptySlots, canSelect, tooltip) LOG_DEBUG('Updating carousel vehicles: ', vehsData if not isSet else 'full sync') self.as_updateVehiclesS(vehsData, isSet) self.showVehicles() isVehTypeLock = sum( (len(v) for v in items.stats.vehicleTypeLocks.itervalues())) isGlobalVehLock = sum( (len(v) for v in items.stats.globalVehicleLocks.itervalues())) if self.__updateVehiclesTimerId is None and (isVehTypeLock or isGlobalVehLock): self.__updateVehiclesTimerId = BigWorld.callback( self.UPDATE_LOCKS_PERIOD, self.updateLockTimers) LOG_DEBUG('Lock timer updated') if updateFallout: self._updateFallout()
def _getRentStatus(self, item): status = '' statusLevel = '' if item.isRented: if item.rentalIsOver: if item.isPremiumIGR: status = i18n.makeString('#menu:currentVehicleStatus/igrRentalIsOver') else: status = i18n.makeString('#menu:currentVehicleStatus/rentalIsOver') statusLevel = InventoryVehicle.STATE_LEVEL.CRITICAL elif not item.isPremiumIGR: status = RentLeftFormatter(item.rentInfo).getRentLeftStr() statusLevel = InventoryVehicle.STATE_LEVEL.RENTED return (status, statusLevel)
def _getVehicleDataVO(self, vehicle): rentInfoText = RentLeftFormatter( vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr() vState, vStateLvl = vehicle.getState() smallStatus, largeStatus = _getStatusStrings( vState, vStateLvl, substitute=rentInfoText, ctx={'icon': icons.premiumIgrSmall()}) if vehicle.dailyXPFactor > 1: bonusImage = getButtonsAssetPath('bonus_x{}'.format( vehicle.dailyXPFactor)) else: bonusImage = '' label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName return { 'id': vehicle.invID, 'infoText': largeStatus, 'smallInfoText': smallStatus, 'clanLock': vehicle.clanLock, 'lockBackground': vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL, 'icon': vehicle.icon, 'iconSmall': vehicle.iconSmall, 'label': labelStyle(label), 'level': vehicle.level, 'premium': vehicle.isPremium, 'favorite': vehicle.isFavorite, 'nation': vehicle.nationID, 'xpImgSource': bonusImage, 'tankType': '{}_elite'.format(vehicle.type) if vehicle.isElite else vehicle.type, 'rentLeft': rentInfoText }
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 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 _getRentStatus(item): status = '' statusLevel = '' if item.isRented and not item.isTelecom: if item.rentalIsOver: if item.isPremiumIGR: status = i18n.makeString( MENU.CURRENTVEHICLESTATUS_IGRRENTALISOVER) else: status = i18n.makeString( MENU.CURRENTVEHICLESTATUS_RENTALISOVER) statusLevel = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL elif not item.isPremiumIGR: status = RentLeftFormatter(item.rentInfo).getRentLeftStr() statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED elif item.isRentable and item.isRentAvailable: status = i18n.makeString(MENU.CURRENTVEHICLESTATUS_ISRENTABLE) statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED return (status, statusLevel)
def getStatus(self): status, statusLevel = ('', '') item = self.__item if item is not None and item.itemTypeID == GUI_ITEM_TYPE.VEHICLE: if item.isRented and not item.isTelecom: if item.rentalIsOver: if item.isPremiumIGR: status = i18n.makeString( MENU.CURRENTVEHICLESTATUS_IGRRENTALISOVER) else: status = i18n.makeString( MENU.CURRENTVEHICLESTATUS_RENTALISOVER) statusLevel = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL elif not item.isPremiumIGR: status = RentLeftFormatter(item.rentInfo).getRentLeftStr() statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED elif item.isRentable and item.isRentAvailable: status = i18n.makeString(MENU.CURRENTVEHICLESTATUS_ISRENTABLE) statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED elif item.canTradeIn: status = i18n.makeString(MENU.TRADE_IN) statusLevel = Vehicle.VEHICLE_STATE_LEVEL.INFO return (status, statusLevel)
def getVehicleDataVO(vehicle): rentInfoText = RentLeftFormatter(vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr() vState, vStateLvl = vehicle.getState() if vehicle.isRotationApplied(): if vState in (Vehicle.VEHICLE_STATE.AMMO_NOT_FULL, Vehicle.VEHICLE_STATE.LOCKED): vState = Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED smallStatus, largeStatus = getStatusStrings(vState, vStateLvl, substitute=rentInfoText, ctx={'icon': icons.premiumIgrSmall(), 'battlesLeft': getBattlesLeft(vehicle)}) if vehicle.dailyXPFactor > 1: bonusImage = getButtonsAssetPath('bonus_x{}'.format(vehicle.dailyXPFactor)) else: bonusImage = '' label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName return {'id': vehicle.invID, 'intCD': vehicle.intCD, 'infoText': largeStatus, 'smallInfoText': smallStatus, 'clanLock': vehicle.clanLock, 'lockBackground': _isLockedBackground(vState, vStateLvl), 'icon': vehicle.icon, 'iconAlt': getIconPath('noImage'), 'iconSmall': vehicle.iconSmall, 'iconSmallAlt': getSmallIconPath('noImage'), 'label': labelStyle(label), 'level': vehicle.level, 'premium': vehicle.isPremium, 'favorite': vehicle.isFavorite, 'nation': vehicle.nationID, 'xpImgSource': bonusImage, 'tankType': '{}_elite'.format(vehicle.type) if vehicle.isElite else vehicle.type, 'rentLeft': rentInfoText, 'clickEnabled': vehicle.isInInventory, 'alpha': 1, 'infoImgSrc': getVehicleStateIcon(vState), 'isCritInfo': vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL}
def _getVehicleDataVO(self, vehicle): rentInfoStr = RentLeftFormatter(vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr() vState, vStateLvl = vehicle.getState() infoText = _getStatusString(vState, vStateLvl) return { 'id': vehicle.invID, 'showInfoText': bool(infoText), 'infoText': infoText, 'clanLock': vehicle.clanLock, 'lockBackground': vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL, 'tankIconData': { 'image': vehicle.icon, 'label': vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName, 'level': vehicle.level, 'elite': vehicle.isElite, 'premium': vehicle.isPremium, 'favorite': vehicle.isFavorite, 'nation': vehicle.nationID, 'doubleXPReceived': vehicle.dailyXPFactor, 'tankType': vehicle.type, 'rentLeft': rentInfoStr } }
def construct(self): xp = self.configuration.xp dailyXP = self.configuration.dailyXP buyPrice = self.configuration.buyPrice sellPrice = self.configuration.sellPrice unlockPrice = self.configuration.unlockPrice techTreeNode = self.configuration.node minRentPrice = self.configuration.minRentPrice rentals = self.configuration.rentals futureRentals = self.configuration.futureRentals paddings = formatters.packPadding(left=-4) neededValue = 0 actionPrc = 0 if buyPrice and sellPrice: LOG_ERROR( 'You are not allowed to use buyPrice and sellPrice at the same time' ) return else: block = [] isUnlocked = self.vehicle.isUnlocked isInInventory = self.vehicle.isInInventory isNextToUnlock = False parentCD = None if techTreeNode is not None: isNextToUnlock = bool( int(techTreeNode.state) & NODE_STATE_FLAGS.NEXT_2_UNLOCK) parentCD = techTreeNode.unlockProps.parentID if xp: xpValue = self.vehicle.xp if xpValue: xPText = text_styles.expText(_int(xpValue)) icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TOOLTIPS.VEHICLE_XP), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=paddings)) if dailyXP: attrs = g_itemsCache.items.stats.attributes if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0: dailyXPText = text_styles.main( text_styles.expText('x' + _int(self.vehicle.dailyXPFactor))) block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main( TOOLTIPS.VEHICLE_DAILYXPFACTOR), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=paddings)) if unlockPrice: isAvailable, cost, need = getUnlockPrice( self.vehicle.intCD, parentCD) if cost > 0: neededValue = None if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None: neededValue = need block.append( makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, valueWidth=self._valueWidth)) if buyPrice: if self.vehicle.isRestorePossible(): price = self.vehicle.restorePrice defaultPrice = price currency = price.getCurrency() buyPriceText = price.get(currency) oldPrice = defaultPrice.get(currency) neededValue = _getNeedValue(price, currency) if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block.append( makePriceBlock(buyPriceText, CURRENCY_SETTINGS.RESTORE_PRICE, neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth)) if self.vehicle.hasLimitedRestore(): timeKey, formattedTime = getTimeLeftInfo( self.vehicle.restoreInfo.getRestoreTimeLeft(), None) block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main( '#tooltips:vehicle/restoreLeft/%s' % timeKey), value=text_styles.main(formattedTime), icon=ICON_TEXT_FRAMES.ALERT if timeKey == 'hours' else ICON_TEXT_FRAMES.EMPTY, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4))) elif not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom): price = self.vehicle.buyPrice actionPrc = self.vehicle.actionPrc defaultPrice = self.vehicle.defaultPrice currency = price.getCurrency() buyPriceText = price.get(currency) oldPrice = defaultPrice.get(currency) neededValue = _getNeedValue(price, currency) if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block.append( makePriceBlock( buyPriceText, CURRENCY_SETTINGS.getBuySetting(currency), neededValue, oldPrice, 0, valueWidth=self._valueWidth)) if sellPrice and not self.vehicle.isTelecom: sellPrice = self.vehicle.sellPrice if sellPrice.isSet(Currency.GOLD): sellPriceText = text_styles.gold(_int(sellPrice.gold)) sellPriceIcon = ICON_TEXT_FRAMES.GOLD else: sellPriceText = text_styles.credits(_int( sellPrice.credits)) sellPriceIcon = ICON_TEXT_FRAMES.CREDITS block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=paddings)) if minRentPrice and not self.vehicle.isPremiumIGR: minRentPricePackage = self.vehicle.getRentPackage() if minRentPricePackage: minRentPriceValue = Money( *minRentPricePackage['rentPrice']) minDefaultRentPriceValue = Money( *minRentPricePackage['defaultRentPrice']) actionPrc = self.vehicle.getRentPackageActionPrc( minRentPricePackage['days']) currency = minRentPriceValue.getCurrency() price = minRentPriceValue.get(currency) oldPrice = minDefaultRentPriceValue.get(currency) neededValue = _getNeedValue(minRentPriceValue, currency) block.append( makePriceBlock( price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth)) if not self.vehicle.isRented or self.vehicle.rentalIsOver: block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main( '#tooltips:vehicle/rentAvailable'), value='', icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=paddings)) if rentals and not self.vehicle.isPremiumIGR: if futureRentals: rentLeftKey = '#tooltips:vehicle/rentLeftFuture/%s' rentInfo = RentalInfoProvider(time=self._rentExpiryTime, isRented=True) else: rentLeftKey = '#tooltips:vehicle/rentLeft/%s' rentInfo = self.vehicle.rentInfo rentFormatter = RentLeftFormatter(rentInfo) rentLeftInfo = rentFormatter.getRentLeftStr( rentLeftKey, formatter=lambda key, countType, count, _=None: { 'left': count, 'descr': i18n.makeString(key % countType) }) if rentLeftInfo: block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(rentLeftInfo['descr']), value=text_styles.main(rentLeftInfo['left']), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4, bottom=-16))) notEnoughMoney = neededValue > 0 hasAction = actionPrc > 0 return (block, notEnoughMoney or hasAction)
def getVehicleDataVO(vehicle): lowTierMMController = dependency.instance(ILowTierMMController) rentInfoText = RentLeftFormatter(vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr() vState, vStateLvl = vehicle.getState() if vehicle.isRotationApplied(): if vState in (Vehicle.VEHICLE_STATE.AMMO_NOT_FULL, Vehicle.VEHICLE_STATE.LOCKED): vState = Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED if not vehicle.activeInNationGroup: vState = Vehicle.VEHICLE_STATE.NOT_PRESENT customStateExt = '' if vState in (Vehicle.VEHICLE_STATE.RENTABLE, Vehicle.VEHICLE_STATE.RENTABLE_AGAIN): rentPackagesInfo = vehicle.getRentPackagesInfo if rentPackagesInfo.seasonType: customStateExt = '/' + SEASON_NAME_BY_TYPE.get( rentPackagesInfo.seasonType) smallStatus, largeStatus = getStatusStrings(vState + customStateExt, vStateLvl, substitute=rentInfoText, ctx={ 'icon': icons.premiumIgrSmall(), 'battlesLeft': getBattlesLeft(vehicle) }) smallHoverStatus, largeHoverStatus = smallStatus, largeStatus if vState == Vehicle.VEHICLE_STATE.RENTABLE: smallHoverStatus, largeHoverStatus = getStatusStrings( vState + '/hover', vStateLvl, substitute=rentInfoText, ctx={ 'icon': icons.premiumIgrSmall(), 'battlesLeft': getBattlesLeft(vehicle) }) if vehicle.dailyXPFactor > 1: bonusImage = getButtonsAssetPath('bonus_x{}'.format( vehicle.dailyXPFactor)) else: bonusImage = '' label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName tankType = '{}_elite'.format( vehicle.type) if vehicle.isElite else vehicle.type current, maximum = vehicle.getCrystalsEarnedInfo() isCrystalsLimitReached = current == maximum return { 'id': vehicle.invID, 'intCD': vehicle.intCD, 'infoText': largeStatus, 'infoHoverText': largeHoverStatus, 'smallInfoText': smallStatus, 'smallInfoHoverText': smallHoverStatus, 'clanLock': vehicle.clanLock, 'lockBackground': _isLockedBackground(vState, vStateLvl), 'icon': vehicle.icon, 'iconAlt': getIconPath('noImage'), 'iconSmall': vehicle.iconSmall, 'iconSmallAlt': getSmallIconPath('noImage'), 'label': labelStyle(label), 'level': vehicle.level, 'premium': vehicle.isPremium, 'favorite': vehicle.isFavorite, 'giveaway': vehicle.isLowTierEvent and lowTierMMController.isEnabled(), 'nation': vehicle.nationID, 'xpImgSource': bonusImage, 'tankType': tankType, 'rentLeft': rentInfoText, 'clickEnabled': vehicle.isInInventory and vehicle.activeInNationGroup or vehicle.isRentPromotion, 'alpha': 1, 'infoImgSrc': getVehicleStateIcon(vState), 'additionalImgSrc': getVehicleStateAddIcon(vState), 'isCritInfo': vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL, 'isRentPromotion': vehicle.isRentPromotion and not vehicle.isRented, 'isNationChangeAvailable': vehicle.hasNationGroup, 'isEarnCrystals': vehicle.isEarnCrystals, 'isCrystalsLimitReached': isCrystalsLimitReached, 'isUseRightBtn': True, 'tooltip': TOOLTIPS_CONSTANTS.CAROUSEL_VEHICLE }
def _getValue(self): result = [] vehicle = self._tooltip.item configuration = self._tooltip.context.getStatsConfiguration(vehicle) xp = configuration.xp dailyXP = configuration.dailyXP unlockPrice = configuration.unlockPrice buyPrice = configuration.buyPrice sellPrice = configuration.sellPrice techTreeNode = configuration.node minRentPrice = configuration.minRentPrice rentals = configuration.rentals if buyPrice and sellPrice: LOG_ERROR( 'You are not allowed to use buyPrice and sellPrice at the same time' ) return isUnlocked = vehicle.isUnlocked isInInventory = vehicle.isInInventory isRented = vehicle.isRented isNextToUnlock = False parentCD = None if techTreeNode is not None: isNextToUnlock = bool( int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK) parentCD = techTreeNode.unlockProps.parentID if xp: xpValue = vehicle.xp if xpValue: result.append(('xp', xpValue)) if dailyXP: attrs = g_itemsCache.items.stats.attributes if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and vehicle.dailyXPFactor: result.append(('dailyXPFactor', vehicle.dailyXPFactor)) if unlockPrice: isAvailable, cost, need = getUnlockPrice(vehicle.intCD, parentCD) unlockPriceStat = [cost] if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None: unlockPriceStat.append(need) if cost > 0: result.append(('unlock_price', unlockPriceStat)) if buyPrice and not (vehicle.isDisabledForBuy or vehicle.isPremiumIGR): price = vehicle.buyPrice needed = (0, 0) if not isInInventory and (isNextToUnlock or isUnlocked) or isRented: credits, gold = g_itemsCache.items.stats.money creditsNeeded = price[0] - credits if price[0] else 0 goldNeeded = price[1] - gold if price[1] else 0 needed = (max(0, creditsNeeded), max(0, goldNeeded)) result.append(('buy_price', (price, needed))) result.append(('def_buy_price', vehicle.defaultPrice)) result.append(('action_prc', vehicle.actionPrc)) if sellPrice: result.append(('sell_price', vehicle.sellPrice)) result.append(('def_sell_price', vehicle.defaultSellPrice)) result.append(('action_prc', vehicle.sellActionPrc)) if minRentPrice and not vehicle.isPremiumIGR: minRentPricePackage = vehicle.getRentPackage() if minRentPricePackage: minRentPriceValue = minRentPricePackage['rentPrice'] minDefaultRentPriceValue = minRentPricePackage[ 'defaultRentPrice'] rentActionPrc = vehicle.getRentPackageActionPrc( minRentPricePackage['days']) credits, gold = g_itemsCache.items.stats.money enoughGoldForRent = gold - minRentPriceValue[1] >= 0 enoughCreditsForRent = credits - minRentPriceValue[0] >= 0 result.append(('minRentalsPrice', (minRentPriceValue, (enoughCreditsForRent, enoughGoldForRent)))) result.append(('defRentPrice', minDefaultRentPriceValue)) result.append(('rentActionPrc', rentActionPrc)) if rentals and not vehicle.isPremiumIGR: rentFormatter = RentLeftFormatter(vehicle.rentInfo) rentLeftInfo = rentFormatter.getRentLeftStr( '#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _=None: { 'left': count, 'descr': i18n.makeString(key % countType) }) if rentLeftInfo: result.append(('rentals', rentLeftInfo)) return result
def updateVehicles(self, vehicles=None, filterCriteria=None, updateFallout=True): isSet = vehicles is None and filterCriteria is None filterCriteria = filterCriteria or REQ_CRITERIA.INVENTORY if vehicles is not None: filterCriteria |= REQ_CRITERIA.IN_CD_LIST(vehicles) items = g_itemsCache.items filteredVehs = items.getVehicles(filterCriteria) if vehicles is None: vehicles = filteredVehs.keys() hasEmptySlots = self.__multiselectionMode and len( self.__falloutCtrl.getEmptySlots()) > 0 hasRequiredVehicles = self.__falloutCtrl.getConfig( ).hasRequiredVehicles() vehsData = {} multiselectionsData = {} for intCD in vehicles: vehicle = filteredVehs.get(intCD) vehData = None if vehicle is not None: vState, vStateLvl = vehicle.getState() isNotSuitableVeh = not self.__falloutCtrl.isSuitableVeh( vehicle) if isNotSuitableVeh: vState, vStateLvl = Vehicle.VEHICLE_STATE.NOT_SUITABLE, Vehicle.VEHICLE_STATE_LEVEL.WARNING rentInfoStr = RentLeftFormatter( vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr() vehData = self._getVehicleData(vehicle, vState, vStateLvl, rentInfoStr) multiselectionsData[intCD] = self.__packMultiselectionFlags( self.__multiselectionMode and vehicle.isFalloutSelected, self.__falloutCtrl.canSelectVehicle(vehicle), hasRequiredVehicles and hasEmptySlots or vehicle.isFalloutSelected) vehsData[intCD] = vehData LOG_DEBUG('Updating carousel vehicles: {0}'.format( vehsData if not isSet else 'full sync')) self.as_updateVehiclesS(vehsData, isSet) self.as_setMultiselectionButtonLabelsS( FALLOUT.TANKCAROUSELSLOT_ACTIVATEBUTTON, FALLOUT.TANKCAROUSELSLOT_DEACTIVATEBUTTON, self.__falloutCtrl.carouselSelectionButtonTooltip()) self.as_updateMultiselectionDataS(multiselectionsData) isVehTypeLock = sum( (len(v) for v in items.stats.vehicleTypeLocks.itervalues())) isGlobalVehLock = sum( (len(v) for v in items.stats.globalVehicleLocks.itervalues())) if self.__updateVehiclesTimerId is None and (isVehTypeLock or isGlobalVehLock): self.__updateVehiclesTimerId = BigWorld.callback( _UPDATE_LOCKS_PERIOD, self.updateLockTimers) LOG_DEBUG('Lock timer updated') self._initializeFilters() if self.__multiselectionMode and updateFallout and not isSet: self._updateFallout() else: self.showVehicles() return