コード例 #1
0
 def __makeRentBlock(self, price, currencySetting, days, percent=0):
     _int = BigWorld.wg_getIntegralFormat
     settings = _getCurrencySetting(currencySetting)
     if settings is None:
         return
     else:
         valueFormatted = settings.textStyle(_int(price))
         settingsFrame = settings.frame
         if settingsFrame in Currency.ALL:
             newPrice = MONEY_UNDEFINED.replace(settingsFrame, price)
         else:
             newPrice = Money(credits=price)
         if days == 1:
             text = text_styles.main(
                 _ms(TOOLTIPS.ACTIONPRICE_RENTPRICE_1DAY,
                     value=text_styles.expText(percent)))
         elif days == 3:
             text = text_styles.main(
                 _ms(TOOLTIPS.ACTIONPRICE_RENTPRICE_3DAY,
                     value=text_styles.expText(percent)))
         else:
             text = text_styles.main(
                 _ms(TOOLTIPS.ACTIONPRICE_RENTPRICE_DAYS,
                     days=days,
                     value=text_styles.expText(percent)))
         return formatters.packActionTextParameterBlockData(
             name=text,
             value=valueFormatted,
             icon=_getCurrencySetting(currencySetting).frame,
             padding=formatters.packPadding(left=20, bottom=-20),
             currency=newPrice.getCurrency())
コード例 #2
0
    def __setData(self, *args):
        items = g_itemsCache.items
        tankman = items.getTankman(self.tmanInvID)
        if tankman is None:
            self.onWindowClose()
            return
        else:
            dropSkillsCost = []
            for k in sorted(items.shop.dropSkillsCost.keys()):
                skillCost = items.shop.dropSkillsCost[k]
                defaultSkillCots = items.shop.defaults.dropSkillsCost[k]
                price = Money(**skillCost)
                defaultPrice = Money(**defaultSkillCots)
                action = None
                if price != defaultPrice:
                    key = '{}DropSkillsCost'.format(price.getCurrency(byWeight=True))
                    action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, key, True, price, defaultPrice)
                skillCost['action'] = action
                dropSkillsCost.append(skillCost)

            skills_count = list(tankmen.ACTIVE_SKILLS)
            availableSkillsCount = len(skills_count) - len(tankman.skills)
            hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(tankman.skills))
            self.as_setDataS({'money': items.stats.money,
             'tankman': packTankman(tankman, isCountPermanentSkills=False),
             'dropSkillsCost': dropSkillsCost,
             'hasNewSkills': hasNewSkills,
             'newSkills': tankman.newSkillCount,
             'defaultSavingMode': 0,
             'texts': self.__getTexts()})
            return
コード例 #3
0
 def _makePriceBlock(self,
                     price,
                     currencySetting,
                     percent=0,
                     valueWidth=-1):
     _int = BigWorld.wg_getIntegralFormat
     hasAction = percent != 0
     settings = _getCurrencySetting(currencySetting)
     if settings is None:
         return
     else:
         valueFormatted = settings.textStyle(_int(price))
         if hasAction:
             settingsFrame = settings.frame
             if settingsFrame in Currency.ALL:
                 newPrice = MONEY_UNDEFINED.replace(settingsFrame, price)
             else:
                 newPrice = Money(credits=price)
             return formatters.packActionTextParameterBlockData(
                 name=text_styles.main(
                     _ms(TOOLTIPS.ACTIONPRICE_BUYPRICE_ACTIONPRICE,
                         value=text_styles.expText(percent))),
                 value=valueFormatted,
                 icon=_getCurrencySetting(currencySetting).frame,
                 padding=formatters.packPadding(left=20, bottom=-20),
                 currency=newPrice.getCurrency(),
                 valueWidth=valueWidth)
         return formatters.packTextParameterWithIconBlockData(
             name=text_styles.main(self._getDefaultPriceLabelConst()),
             value=valueFormatted,
             icon=settings.frame,
             valueWidth=valueWidth)
         return
コード例 #4
0
def formatActionPrices(oldPrice, newPrice, isBuying, checkGold=False):
    oldPrice = Money.makeFromMoneyTuple(oldPrice)
    if not oldPrice.isDefined():
        oldPrice = Money(credits=0)
    newPrice = Money.makeFromMoneyTuple(newPrice)
    if not newPrice.isDefined():
        newPrice = Money.makeFrom(oldPrice.getCurrency(), 0)
    return (_getFormattedPrice(oldPrice, isBuying, checkGold),
            _getFormattedPrice(newPrice, isBuying, checkGold))
コード例 #5
0
 def __prepareVMData(self):
     if self.__dynPrice:
         currency, price = first(
             ((c, v) for c, v in self.__dynPrice.iteritems()))
         userCurrency = _getUserDynCurrency(currency)
         mayObtain = _mayObtainForDynCurrency(currency, price)
     else:
         money = Money(**self.__ordPrice)
         currency = money.getCurrency()
         price = money.get(currency, 0)
         userCurrency = _getUserMoney(currency)
         mayObtain = currency == Currency.GOLD or mayObtainForMoney(
             money) or mayObtainWithMoneyExchange(money)
     status = StyleBuyingStatus.BPNOTPASSED if not self.__battlePass.isCompleted(
     ) else (StyleBuyingStatus.AVAILABLE
             if mayObtain else StyleBuyingStatus.NOTENOUGHMONEY)
     return (currency, int(price), userCurrency, self.__level or 0, status)
コード例 #6
0
    def getTankmanCostWithDefaults(self):
        from gui.shared.tooltips import ACTION_TOOLTIPS_TYPE
        from gui.shared.tooltips.formatters import packActionTooltipData
        shopPrices = self.tankmanCost
        defaultPrices = self.defaults.tankmanCost
        action = []
        tmanCost = []
        for idx, price in enumerate(shopPrices):
            data = price.copy()
            shopPrice = Money(**price)
            defaultPrice = Money(**defaultPrices[idx])
            actionData = None
            if shopPrice != defaultPrice:
                key = '{}TankmanCost'.format(shopPrice.getCurrency(byWeight=True))
                actionData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, key, True, shopPrice, defaultPrice)
            tmanCost.append(data)
            action.append(actionData)

        return (tmanCost, action)
コード例 #7
0
    def __setData(self, *args):
        items = self.itemsCache.items
        tankman = items.getTankman(self.tmanInvID)
        if tankman is None:
            self.onWindowClose()
            return
        else:
            dropSkillsCost = []
            for k in sorted(items.shop.dropSkillsCost.keys()):
                skillCost = items.shop.dropSkillsCost[k]
                defaultSkillCots = items.shop.defaults.dropSkillsCost[k]
                price = Money(**skillCost)
                defaultPrice = Money(**defaultSkillCots)
                action = None
                if price != defaultPrice:
                    key = '{}DropSkillsCost'.format(
                        price.getCurrency(byWeight=True))
                    action = packActionTooltipData(
                        ACTION_TOOLTIPS_TYPE.ECONOMICS, key, True, price,
                        defaultPrice)
                skillCost['action'] = action
                dropSkillsCost.append(skillCost)

            skills_count = tankmen.getSkillsConfig().getNumberOfActiveSkills()
            lenSkills = len(tankman.skills)
            availableSkillsCount = skills_count - lenSkills
            hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (
                tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL
                or not lenSkills)
            tankmanData = packTankman(tankman, isCountPermanentSkills=False)
            repackTankmanWithSkinData(tankman, tankmanData)
            self.as_setDataS({
                'tankman': tankmanData,
                'dropSkillsCost': dropSkillsCost,
                'hasNewSkills': hasNewSkills,
                'newSkills': tankman.newSkillCount,
                'defaultSavingMode': 0,
                'texts': self.__getTexts()
            })
            self.as_updateRetrainButtonsDataS(packDropSkill(tankman))
            return
コード例 #8
0
    def getTankmanCostWithDefaults(self):
        """
        @return: tankman studying cost
                        tmanCost, action -  ( tmanCostType, ), ( actionData, ) where
                        tmanCostType = {
                                        'roleLevel' : minimal role level after operation,
                                        'credits' : cost in credits,
                                        'defCredits' : cost in credits,
                                        'gold' : default cost in gold,
                                        'defGold' : default cost in gold,
                                        'baseRoleLoss' : float in [0, 1], fraction of role to drop,
                                        'classChangeRoleLoss' : float in [0, 1], fraction of role to drop
                                        additionally if
                                                classes of self.vehicleTypeID and newVehicleTypeID are different,
                                        'isPremium' : tankman becomes premium,
                                        }.
                                List is sorted by role level.
                        actionData = Action data for each level of retraining
        """
        from gui.shared.tooltips import ACTION_TOOLTIPS_TYPE
        from gui.shared.tooltips.formatters import packActionTooltipData
        shopPrices = self.tankmanCost
        defaultPrices = self.defaults.tankmanCost
        action = []
        tmanCost = []
        for idx, price in enumerate(shopPrices):
            data = price.copy()
            shopPrice = Money(**price)
            defaultPrice = Money(**defaultPrices[idx])
            actionData = None
            if shopPrice != defaultPrice:
                key = '{}TankmanCost'.format(
                    shopPrice.getCurrency(byWeight=True))
                actionData = packActionTooltipData(
                    ACTION_TOOLTIPS_TYPE.ECONOMICS, key, True, shopPrice,
                    defaultPrice)
            tmanCost.append(data)
            action.append(actionData)

        return (tmanCost, action)
コード例 #9
0
    def getTankmanCostWithDefaults(self):
        """
        @return: tankman studying cost
                        tmanCost, action -  ( tmanCostType, ), ( actionData, ) where
                        tmanCostType = {
                                        'roleLevel' : minimal role level after operation,
                                        'credits' : cost in credits,
                                        'defCredits' : cost in credits,
                                        'gold' : default cost in gold,
                                        'defGold' : default cost in gold,
                                        'baseRoleLoss' : float in [0, 1], fraction of role to drop,
                                        'classChangeRoleLoss' : float in [0, 1], fraction of role to drop
                                        additionally if
                                                classes of self.vehicleTypeID and newVehicleTypeID are different,
                                        'isPremium' : tankman becomes premium,
                                        }.
                                List is sorted by role level.
                        actionData = Action data for each level of retraining
        """
        from gui.shared.tooltips import ACTION_TOOLTIPS_TYPE
        from gui.shared.tooltips.formatters import packActionTooltipData
        shopPrices = self.tankmanCost
        defaultPrices = self.defaults.tankmanCost
        action = []
        tmanCost = []
        for idx, price in enumerate(shopPrices):
            data = price.copy()
            shopPrice = Money(**price)
            defaultPrice = Money(**defaultPrices[idx])
            actionData = None
            if shopPrice != defaultPrice:
                key = '{}TankmanCost'.format(shopPrice.getCurrency(byWeight=True))
                actionData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, key, True, shopPrice, defaultPrice)
            tmanCost.append(data)
            action.append(actionData)

        return (tmanCost, action)
コード例 #10
0
ファイル: vehicle.py プロジェクト: webiumsk/WOT-0.9.15.1
 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
     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.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 and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
             price = self.vehicle.buyPrice
             money = g_itemsCache.items.stats.money
             actionPrc = self.vehicle.actionPrc
             defaultPrice = self.vehicle.defaultPrice
             currency = price.getCurrency()
             buyPriceText = price.get(currency)
             oldPrice = defaultPrice.get(currency)
             neededValue = price.get(currency) - money.get(currency)
             neededValue = neededValue if neededValue > 0 else None
             if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                 neededValue = None
             block.append(makePriceBlock(buyPriceText, CURRENCY_SETTINGS.getBuySetting(currency), neededValue, oldPrice, actionPrc, 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'])
                 money = g_itemsCache.items.stats.money
                 currency = minRentPriceValue.getCurrency()
                 price = minRentPriceValue.get(currency)
                 oldPrice = minDefaultRentPriceValue.get(currency)
                 neededValue = minRentPriceValue.get(currency) - money.get(currency)
                 neededValue = neededValue if neededValue > 0 else None
                 block.append(makePriceBlock(price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth))
         if rentals and not self.vehicle.isPremiumIGR:
             rentFormatter = RentLeftFormatter(self.vehicle.rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', 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)
コード例 #11
0
ファイル: tooltipsvehicle.py プロジェクト: Difrex/wotsdk
 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)
コード例 #12
0
ファイル: __init__.py プロジェクト: webiumsk/WOT-0.9.15.1
class FittingItem(GUIItem, HasIntCD):

    class TARGETS(object):
        CURRENT = 1
        IN_INVENTORY = 2
        OTHER = 3

    def __init__(self, intCompactDescr, proxy = None, isBoughtForCredits = False):
        GUIItem.__init__(self, proxy)
        HasIntCD.__init__(self, intCompactDescr)
        self.defaultPrice = ZERO_MONEY
        self._buyPrice = ZERO_MONEY
        self.sellPrice = ZERO_MONEY
        self.defaultSellPrice = ZERO_MONEY
        self.altPrice = None
        self.defaultAltPrice = None
        self.sellActionPrc = 0
        self.isHidden = False
        self.inventoryCount = 0
        self.sellForGold = False
        self.isUnlocked = False
        self.isBoughtForCredits = isBoughtForCredits
        self.rentInfo = RentalInfoProvider()
        if proxy is not None and proxy.isSynced():
            self.defaultPrice = proxy.shop.defaults.getItemPrice(self.intCompactDescr)
            if self.defaultPrice is None:
                self.defaultPrice = ZERO_MONEY
            self._buyPrice, self.isHidden, self.sellForGold = proxy.shop.getItem(self.intCompactDescr)
            if self._buyPrice is None:
                self._buyPrice = ZERO_MONEY
            self.defaultSellPrice = Money(*BigWorld.player().shop.getSellPrice(self.defaultPrice, proxy.shop.defaults.sellPriceModifiers(intCompactDescr), self.itemTypeID))
            self.sellPrice = Money(*BigWorld.player().shop.getSellPrice(self.buyPrice, proxy.shop.sellPriceModifiers(intCompactDescr), self.itemTypeID))
            self.inventoryCount = proxy.inventory.getItems(self.itemTypeID, self.intCompactDescr)
            if self.inventoryCount is None:
                self.inventoryCount = 0
            self.isUnlocked = self.intCD in proxy.stats.unlocks
            self.isInitiallyUnlocked = self.intCD in proxy.stats.initialUnlocks
            self.altPrice = self._getAltPrice(self.buyPrice, proxy.shop)
            self.defaultAltPrice = self._getAltPrice(self.defaultPrice, proxy.shop.defaults)
            self.sellActionPrc = -1 * getActionPrc(self.sellPrice, self.defaultSellPrice)
        return

    def _getAltPrice(self, buyPrice, proxy):
        return None

    @property
    def buyPrice(self):
        return self._buyPrice

    @property
    def rentOrBuyPrice(self):
        price = self.altPrice or self.buyPrice
        minRentPricePackage = self.getRentPackage()
        if minRentPricePackage:
            return minRentPricePackage['rentPrice']
        return price

    @property
    def actionPrc(self):
        return getActionPrc(self.altPrice or self.buyPrice, self.defaultAltPrice or self.defaultPrice)

    @property
    def isSecret(self):
        return False

    @property
    def isPremium(self):
        return self.buyPrice.isSet(Currency.GOLD)

    @property
    def isPremiumIGR(self):
        return False

    @property
    def isRentable(self):
        return False

    @property
    def isRented(self):
        return False

    @property
    def descriptor(self):
        return vehicles.getDictDescr(self.intCompactDescr)

    @property
    def isRemovable(self):
        return True

    @property
    def minRentPrice(self):
        return None

    @property
    def rentLeftTime(self):
        return 0

    def isPreviewAllowed(self):
        return False

    @property
    def userType(self):
        return getTypeInfoByName(self.itemTypeName)['userString']

    @property
    def userName(self):
        return self.descriptor.get('userString', '')

    @property
    def longUserName(self):
        return self.userType + ' ' + self.userName

    @property
    def shortUserName(self):
        return self.descriptor.get('shortUserString', '')

    @property
    def shortDescription(self):
        return getShortDescr(self.descriptor.get('description', ''))

    @property
    def fullDescription(self):
        return stripShortDescrTags(self.descriptor.get('description', ''))

    @property
    def name(self):
        return self.descriptor.get('name', '')

    @property
    def level(self):
        return self.descriptor.get('level', 0)

    @property
    def isInInventory(self):
        return self.inventoryCount > 0

    def _getShortInfo(self, vehicle = None, expanded = False):
        try:
            description = i18n.makeString('#menu:descriptions/' + self.itemTypeName + ('Full' if expanded else ''))
            vehicleDescr = vehicle.descriptor if vehicle is not None else None
            params = params_helper.getParameters(self, vehicleDescr)
            formattedParametersDict = dict(formatters.getFormattedParamsList(self.descriptor, params))
            if self.itemTypeName == vehicles._VEHICLE:
                formattedParametersDict['caliber'] = BigWorld.wg_getIntegralFormat(self.descriptor.gun['shots'][0]['shell']['caliber'])
            result = description % formattedParametersDict
            return result
        except Exception:
            LOG_CURRENT_EXCEPTION()
            return ''

        return

    def getShortInfo(self, vehicle = None, expanded = False):
        if not GUI_SETTINGS.technicalInfo:
            return ''
        return self._getShortInfo(vehicle, expanded)

    def getParams(self, vehicle = None):
        return dict(params_helper.get(self, vehicle.descriptor if vehicle is not None else None))

    def getRentPackage(self, days = None):
        return None

    def getGUIEmblemID(self):
        return 'notFound'

    @property
    def icon(self):
        return _ICONS_MASK % {'type': self.itemTypeName,
         'subtype': '',
         'unicName': self.name.replace(':', '-')}

    @property
    def iconSmall(self):
        return _ICONS_MASK % {'type': self.itemTypeName,
         'subtype': 'small/',
         'unicName': self.name.replace(':', '-')}

    def getBuyPriceCurrency(self):
        if self.altPrice is not None:
            if self.altPrice.gold and not self.isBoughtForCredits:
                return Currency.GOLD
        elif self.buyPrice.gold:
            return Currency.GOLD
        return Currency.CREDITS

    def getSellPriceCurrency(self):
        return self.sellPrice.getCurrency()

    def isInstalled(self, vehicle, slotIdx = None):
        return False

    def mayInstall(self, vehicle, slotIdx = None):
        return vehicle.descriptor.mayInstallComponent(self.intCD)

    def mayRemove(self, vehicle):
        return (True, '')

    def mayRent(self, money):
        return (False, '')

    def mayRentOrBuy(self, money):
        return self.mayPurchase(money)

    def mayPurchaseWithExchange(self, money, exchangeRate):
        price = self.altPrice or self.buyPrice
        money = money.exchange(Currency.GOLD, Currency.CREDITS, exchangeRate)
        return price <= money

    def isPurchaseEnabled(self, money, exchangeRate):
        canBuy, buyReason = self.mayPurchase(money)
        canRentOrBuy, rentReason = self.mayRentOrBuy(money)
        canBuyWithExchange = self.mayPurchaseWithExchange(money, exchangeRate)
        return canRentOrBuy or canBuy or canBuyWithExchange and buyReason == 'credits_error'

    def mayPurchase(self, money):
        if getattr(BigWorld.player(), 'isLongDisconnectedFromCenter', False):
            return (False, 'center_unavailable')
        if self.itemTypeID not in (GUI_ITEM_TYPE.EQUIPMENT, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL) and not self.isUnlocked:
            return (False, 'unlock_error')
        if self.isHidden:
            return (False, 'isHidden')
        price = self.altPrice or self.buyPrice
        if not price:
            return (True, '')
        for c in price.getSetCurrencies():
            if money.get(c) >= price.get(c):
                return (True, '')

        return (False, '%s_error' % Currency.BY_WEIGHT[-1])

    def getTarget(self, vehicle):
        if self.isInstalled(vehicle):
            return self.TARGETS.CURRENT
        if self.isInInventory:
            return self.TARGETS.IN_INVENTORY
        return self.TARGETS.OTHER

    def getConflictedEquipments(self, vehicle):
        return ()

    def getInstalledVehicles(self, vehs):
        return set()

    def _sortByType(self, other):
        return 0

    def __cmp__(self, other):
        if other is None:
            return 1
        res = HasIntCD.__cmp__(self, other)
        if res:
            return res
        res = self._sortByType(other)
        if res:
            return res
        res = self.level - other.level
        if res:
            return res
        res = self.buyPrice.gold - other.buyPrice.gold
        if res:
            return res
        res = self.buyPrice.credits - other.buyPrice.credits
        if res:
            return res
        else:
            return cmp(self.userName, other.userName)

    def __eq__(self, other):
        if other is None:
            return False
        else:
            return self.intCompactDescr == other.intCompactDescr

    def __repr__(self):
        return '%s<intCD:%d, type:%s, nation:%d>' % (self.__class__.__name__,
         self.intCD,
         self.itemTypeName,
         self.nationID)
コード例 #13
0
ファイル: __init__.py プロジェクト: webiumsk/WOT-0.9.15.1
class FittingItem(GUIItem, HasIntCD):
    class TARGETS(object):
        CURRENT = 1
        IN_INVENTORY = 2
        OTHER = 3

    def __init__(self, intCompactDescr, proxy=None, isBoughtForCredits=False):
        GUIItem.__init__(self, proxy)
        HasIntCD.__init__(self, intCompactDescr)
        self.defaultPrice = ZERO_MONEY
        self._buyPrice = ZERO_MONEY
        self.sellPrice = ZERO_MONEY
        self.defaultSellPrice = ZERO_MONEY
        self.altPrice = None
        self.defaultAltPrice = None
        self.sellActionPrc = 0
        self.isHidden = False
        self.inventoryCount = 0
        self.sellForGold = False
        self.isUnlocked = False
        self.isBoughtForCredits = isBoughtForCredits
        self.rentInfo = RentalInfoProvider()
        if proxy is not None and proxy.isSynced():
            self.defaultPrice = proxy.shop.defaults.getItemPrice(
                self.intCompactDescr)
            if self.defaultPrice is None:
                self.defaultPrice = ZERO_MONEY
            self._buyPrice, self.isHidden, self.sellForGold = proxy.shop.getItem(
                self.intCompactDescr)
            if self._buyPrice is None:
                self._buyPrice = ZERO_MONEY
            self.defaultSellPrice = Money(*BigWorld.player().shop.getSellPrice(
                self.defaultPrice,
                proxy.shop.defaults.sellPriceModifiers(intCompactDescr),
                self.itemTypeID))
            self.sellPrice = Money(*BigWorld.player().shop.getSellPrice(
                self.buyPrice, proxy.shop.sellPriceModifiers(intCompactDescr),
                self.itemTypeID))
            self.inventoryCount = proxy.inventory.getItems(
                self.itemTypeID, self.intCompactDescr)
            if self.inventoryCount is None:
                self.inventoryCount = 0
            self.isUnlocked = self.intCD in proxy.stats.unlocks
            self.isInitiallyUnlocked = self.intCD in proxy.stats.initialUnlocks
            self.altPrice = self._getAltPrice(self.buyPrice, proxy.shop)
            self.defaultAltPrice = self._getAltPrice(self.defaultPrice,
                                                     proxy.shop.defaults)
            self.sellActionPrc = -1 * getActionPrc(self.sellPrice,
                                                   self.defaultSellPrice)
        return

    def _getAltPrice(self, buyPrice, proxy):
        return None

    @property
    def buyPrice(self):
        return self._buyPrice

    @property
    def rentOrBuyPrice(self):
        price = self.altPrice or self.buyPrice
        minRentPricePackage = self.getRentPackage()
        if minRentPricePackage:
            return minRentPricePackage['rentPrice']
        return price

    @property
    def actionPrc(self):
        return getActionPrc(self.altPrice or self.buyPrice,
                            self.defaultAltPrice or self.defaultPrice)

    @property
    def isSecret(self):
        return False

    @property
    def isPremium(self):
        return self.buyPrice.isSet(Currency.GOLD)

    @property
    def isPremiumIGR(self):
        return False

    @property
    def isRentable(self):
        return False

    @property
    def isRented(self):
        return False

    @property
    def descriptor(self):
        return vehicles.getDictDescr(self.intCompactDescr)

    @property
    def isRemovable(self):
        return True

    @property
    def minRentPrice(self):
        return None

    @property
    def rentLeftTime(self):
        return 0

    def isPreviewAllowed(self):
        return False

    @property
    def userType(self):
        return getTypeInfoByName(self.itemTypeName)['userString']

    @property
    def userName(self):
        return self.descriptor.get('userString', '')

    @property
    def longUserName(self):
        return self.userType + ' ' + self.userName

    @property
    def shortUserName(self):
        return self.descriptor.get('shortUserString', '')

    @property
    def shortDescription(self):
        return getShortDescr(self.descriptor.get('description', ''))

    @property
    def fullDescription(self):
        return stripShortDescrTags(self.descriptor.get('description', ''))

    @property
    def name(self):
        return self.descriptor.get('name', '')

    @property
    def level(self):
        return self.descriptor.get('level', 0)

    @property
    def isInInventory(self):
        return self.inventoryCount > 0

    def _getShortInfo(self, vehicle=None, expanded=False):
        try:
            description = i18n.makeString('#menu:descriptions/' +
                                          self.itemTypeName +
                                          ('Full' if expanded else ''))
            vehicleDescr = vehicle.descriptor if vehicle is not None else None
            params = params_helper.getParameters(self, vehicleDescr)
            formattedParametersDict = dict(
                formatters.getFormattedParamsList(self.descriptor, params))
            if self.itemTypeName == vehicles._VEHICLE:
                formattedParametersDict[
                    'caliber'] = BigWorld.wg_getIntegralFormat(
                        self.descriptor.gun['shots'][0]['shell']['caliber'])
            result = description % formattedParametersDict
            return result
        except Exception:
            LOG_CURRENT_EXCEPTION()
            return ''

        return

    def getShortInfo(self, vehicle=None, expanded=False):
        if not GUI_SETTINGS.technicalInfo:
            return ''
        return self._getShortInfo(vehicle, expanded)

    def getParams(self, vehicle=None):
        return dict(
            params_helper.get(
                self, vehicle.descriptor if vehicle is not None else None))

    def getRentPackage(self, days=None):
        return None

    def getGUIEmblemID(self):
        return 'notFound'

    @property
    def icon(self):
        return _ICONS_MASK % {
            'type': self.itemTypeName,
            'subtype': '',
            'unicName': self.name.replace(':', '-')
        }

    @property
    def iconSmall(self):
        return _ICONS_MASK % {
            'type': self.itemTypeName,
            'subtype': 'small/',
            'unicName': self.name.replace(':', '-')
        }

    def getBuyPriceCurrency(self):
        if self.altPrice is not None:
            if self.altPrice.gold and not self.isBoughtForCredits:
                return Currency.GOLD
        elif self.buyPrice.gold:
            return Currency.GOLD
        return Currency.CREDITS

    def getSellPriceCurrency(self):
        return self.sellPrice.getCurrency()

    def isInstalled(self, vehicle, slotIdx=None):
        return False

    def mayInstall(self, vehicle, slotIdx=None):
        return vehicle.descriptor.mayInstallComponent(self.intCD)

    def mayRemove(self, vehicle):
        return (True, '')

    def mayRent(self, money):
        return (False, '')

    def mayRentOrBuy(self, money):
        return self.mayPurchase(money)

    def mayPurchaseWithExchange(self, money, exchangeRate):
        price = self.altPrice or self.buyPrice
        money = money.exchange(Currency.GOLD, Currency.CREDITS, exchangeRate)
        return price <= money

    def isPurchaseEnabled(self, money, exchangeRate):
        canBuy, buyReason = self.mayPurchase(money)
        canRentOrBuy, rentReason = self.mayRentOrBuy(money)
        canBuyWithExchange = self.mayPurchaseWithExchange(money, exchangeRate)
        return canRentOrBuy or canBuy or canBuyWithExchange and buyReason == 'credits_error'

    def mayPurchase(self, money):
        if getattr(BigWorld.player(), 'isLongDisconnectedFromCenter', False):
            return (False, 'center_unavailable')
        if self.itemTypeID not in (
                GUI_ITEM_TYPE.EQUIPMENT, GUI_ITEM_TYPE.OPTIONALDEVICE,
                GUI_ITEM_TYPE.SHELL) and not self.isUnlocked:
            return (False, 'unlock_error')
        if self.isHidden:
            return (False, 'isHidden')
        price = self.altPrice or self.buyPrice
        if not price:
            return (True, '')
        for c in price.getSetCurrencies():
            if money.get(c) >= price.get(c):
                return (True, '')

        return (False, '%s_error' % Currency.BY_WEIGHT[-1])

    def getTarget(self, vehicle):
        if self.isInstalled(vehicle):
            return self.TARGETS.CURRENT
        if self.isInInventory:
            return self.TARGETS.IN_INVENTORY
        return self.TARGETS.OTHER

    def getConflictedEquipments(self, vehicle):
        return ()

    def getInstalledVehicles(self, vehs):
        return set()

    def _sortByType(self, other):
        return 0

    def __cmp__(self, other):
        if other is None:
            return 1
        res = HasIntCD.__cmp__(self, other)
        if res:
            return res
        res = self._sortByType(other)
        if res:
            return res
        res = self.level - other.level
        if res:
            return res
        res = self.buyPrice.gold - other.buyPrice.gold
        if res:
            return res
        res = self.buyPrice.credits - other.buyPrice.credits
        if res:
            return res
        else:
            return cmp(self.userName, other.userName)

    def __eq__(self, other):
        if other is None:
            return False
        else:
            return self.intCompactDescr == other.intCompactDescr

    def __repr__(self):
        return '%s<intCD:%d, type:%s, nation:%d>' % (
            self.__class__.__name__, self.intCD, self.itemTypeName,
            self.nationID)
コード例 #14
0
ファイル: tooltipsvehicle.py プロジェクト: aevitas/wotsdk
 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)