Beispiel #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())
Beispiel #2
0
 def _makePriceBlock(self, price, text, currencyType, neededValue = None, oldPrice = None, percent = 0):
     needFormatted = ''
     oldPriceText = ''
     hasAction = percent != 0
     if currencyType == ICON_TEXT_FRAMES.CREDITS:
         valueFormatted = text_styles.credits(_int(price))
         icon = icons.credits()
         if neededValue is not None:
             needFormatted = text_styles.credits(_int(neededValue))
         if hasAction:
             oldPriceText = text_styles.concatStylesToSingleLine(icons.credits(), text_styles.credits(_int(oldPrice)))
     elif currencyType == ICON_TEXT_FRAMES.GOLD:
         valueFormatted = text_styles.gold(_int(price))
         icon = icons.gold()
         if neededValue is not None:
             needFormatted = text_styles.gold(_int(neededValue))
         if hasAction:
             oldPriceText = text_styles.concatStylesToSingleLine(icons.gold(), text_styles.gold(_int(oldPrice)))
     elif currencyType == ICON_TEXT_FRAMES.XP:
         valueFormatted = text_styles.expText(_int(price))
         icon = icons.xp()
         if neededValue is not None:
             needFormatted = text_styles.expText(_int(neededValue))
     else:
         LOG_ERROR('Unsupported currency type "' + currencyType + '"!')
         return
     neededText = ''
     if neededValue is not None:
         neededText = text_styles.concatStylesToSingleLine(text_styles.main('( '), text_styles.error(TOOLTIPS.VEHICLE_GRAPH_BODY_NOTENOUGH), ' ', needFormatted, ' ', icon, text_styles.main(' )'))
     text = text_styles.concatStylesWithSpace(text_styles.main(text), neededText)
     if hasAction:
         actionText = text_styles.main(_ms(TOOLTIPS.VEHICLE_ACTION_PRC, actionPrc=text_styles.stats(str(percent) + '%'), oldPrice=oldPriceText))
         text = text_styles.concatStylesToMultiLine(text, actionText)
     return formatters.packTextParameterWithIconBlockData(name=text, value=valueFormatted, icon=currencyType, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=20))
 def _buildTooltip(self, peripheryID):
     if not self.getTimeLeft():
         tooltipStr = text_styles.expText(
             backport.text(R.strings.mapbox.primeTimeView.endOfCycle(),
                           server=self.getName()))
     else:
         timeStr = text_styles.neutral(
             backport.getTillTimeStringByRClass(
                 self.getTimeLeft(),
                 R.strings.menu.Time.timeValueShort.noLeadingZeroes))
         if self._getIsAvailable():
             tooltipStr = text_styles.expText(
                 backport.text(
                     R.strings.mapbox.primeTimeView.serverTooltip(),
                     server=self.getName(),
                     time=timeStr))
         else:
             tooltipStr = text_styles.expText(
                 backport.text(R.strings.mapbox.primeTimeView.
                               serverUnavailableTooltip(),
                               time=timeStr,
                               server=self.getName()))
     return {
         'tooltip': tooltipStr,
         'specialArgs': [],
         'specialAlias': None,
         'isSpecial': None
     }
Beispiel #4
0
 def _buildTooltip(self, peripheryID):
     if not self.getTimeLeft():
         tooltipStr = text_styles.expText(
             backport.text(R.strings.epic_battle.primeTime.endOfCycle(),
                           server=self.getName()))
     else:
         timeStr = text_styles.neutral(
             time_formatters.getTillTimeByResource(
                 self.getTimeLeft(), R.strings.menu.Time.timeValueShort))
         if self._getIsAvailable():
             tooltipStr = text_styles.expText(
                 backport.text(
                     R.strings.epic_battle.primeTime.serverTooltip(),
                     server=self.getName(),
                     time=timeStr))
         else:
             tooltipStr = text_styles.expText(
                 backport.text(R.strings.epic_battle.primeTime.
                               serverUnavailableTooltip(),
                               time=timeStr))
     return {
         'tooltip': tooltipStr,
         'specialArgs': [],
         'specialAlias': None,
         'isSpecial': None
     }
Beispiel #5
0
 def _makeMeta(self):
     item = g_itemsCache.items.getItemByCD(self._unlockCtx.unlockCD)
     xpCost = BigWorld.wg_getIntegralFormat(self._costCtx['xpCost'])
     freeXp = BigWorld.wg_getIntegralFormat(self._costCtx['freeXP'])
     ctx = {'xpCost': text_styles.expText(xpCost),
      'freeXP': text_styles.expText(freeXp),
      'typeString': item.userType,
      'userString': item.userName}
     if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         key = 'confirmUnlockVehicle'
     else:
         key = 'confirmUnlockItem'
     return dialogs.I18nConfirmDialogMeta('confirmUnlock', meta=dialogs.HtmlMessageLocalDialogMeta('html_templates:lobby/dialogs', key, ctx=ctx))
Beispiel #6
0
 def _makeMeta(self):
     item = self.itemsCache.items.getItemByCD(self._unlockCtx.unlockCD)
     xpCost = BigWorld.wg_getIntegralFormat(self._costCtx['xpCost'])
     freeXp = BigWorld.wg_getIntegralFormat(self._costCtx['freeXP'])
     ctx = {'xpCost': text_styles.expText(xpCost),
      'freeXP': text_styles.expText(freeXp),
      'typeString': item.userType,
      'userString': item.userName}
     if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         key = 'confirmUnlockVehicle'
     else:
         key = 'confirmUnlockItem'
     return dialogs.I18nConfirmDialogMeta('confirmUnlock', meta=dialogs.HtmlMessageLocalDialogMeta('html_templates:lobby/dialogs', key, ctx=ctx))
 def _getUnlockDiscountBlock(percentValue, xpValue, title, showPlus=False):
     if percentValue == 100:
         discountPadding = 8 if showPlus else 19
     elif percentValue < 10:
         discountPadding = 30 if showPlus else 41
     else:
         discountPadding = 19 if showPlus else 30
     percentStr = ''.join(('+' if showPlus else '', str(percentValue), '%'))
     discountValueStr = text_styles.concatStylesToSingleLine(
         text_styles.bonusLocalText(percentStr),
         text_styles.main(
             i18n.makeString(TOOLTIPS.VEHICLE_TEXTDELIMITER_OR).join(
                 ('  ', ' '))), icons.xpCost(),
         text_styles.expText(backport.getIntegralFormat(xpValue)))
     blockPadding = -discountPadding - (0 if showPlus else -10)
     imgPadding = -79 - (3 if percentValue < 10 else 0)
     return formatters.packImageTextBlockData(
         title=text_styles.main(title),
         desc=discountValueStr,
         img=backport.image(R.images.gui.maps.icons.blueprints.
                            blueprintScreen.discountShine()),
         txtGap=-6,
         imgPadding=formatters.packPadding(top=0, right=imgPadding),
         txtPadding=formatters.packPadding(left=discountPadding),
         padding=formatters.packPadding(top=4, left=blockPadding,
                                        bottom=-6),
         blockWidth=300)
Beispiel #8
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
 def _prepareData(self, serverList, serverInfo):
     isSingleServer = len(serverList) == 1
     return {
         'warningIconSrc':
         self._getWarningIcon(),
         'status':
         self.__getStatusTitle(),
         'serversText':
         text_styles.expText(
             self._getServerText(serverList, serverInfo, True)),
         'serversDDEnabled':
         not isSingleServer,
         'serverDDVisible':
         not isSingleServer,
         'timeText':
         text_styles.expText(self.__getTimeText(serverInfo))
     }
 def _prepareData(self, serverList, serverInfo):
     isSingleServer = len(serverList) == 1
     return {
         'warningIconSrc':
         self._getWarningIcon(),
         'status':
         text_styles.grandTitle(self.__getStatusText()),
         'serversText':
         text_styles.expText(self._getServerText(serverList, serverInfo)),
         'serversDDEnabled':
         not isSingleServer,
         'serverDDVisible':
         not isSingleServer,
         'timeText':
         text_styles.expText(self.__getTimeText(serverInfo)),
         'showAlertBG':
         not self.__eventProgression.hasAvailablePrimeTimeServers()
     }
 def _buildTooltip(self, peripheryID):
     if not self.getTimeLeft():
         tooltipStr = text_styles.expText(
             _ms(EPIC_BATTLE.PRIMETIME_ENDOFCYCLE, server=self.getName()))
     else:
         timeStr = text_styles.neutral(
             time_utils.getTillTimeString(self.getTimeLeft(),
                                          MENU.TIME_TIMEVALUESHORT))
         if self._getIsAvailable():
             tooltipStr = text_styles.expText(
                 _ms(EPIC_BATTLE.PRIMETIME_SERVERTOOLTIP,
                     server=self.getName(),
                     time=timeStr))
         else:
             tooltipStr = text_styles.expText(
                 _ms(EPIC_BATTLE.PRIMETIME_SERVERUNAVAILABLETOOLTIP,
                     time=timeStr))
     return {
         'tooltip': tooltipStr,
         'specialArgs': [],
         'specialAlias': None,
         'isSpecial': None
     }
Beispiel #12
0
    def __packGiftNameBlocks(cls, shortName, giftsNames, isOfferEnabled):
        rOffer = R.strings.tooltips.battlePassOffer
        blocks = [
            formatters.packTextBlockData(text=text_styles.highTitle(
                backport.text(rOffer.title.dyn(shortName)())))
        ]
        if isOfferEnabled:
            if shortName in ('brochure_gift', 'guide_gift', 'blueprint_gift'):
                blocks.append(
                    formatters.packTextBlockData(text=text_styles.gold(
                        backport.text(rOffer.allNations()))))
                if shortName == 'blueprint_gift':
                    information = backport.text(rOffer.blueprintInfo())
                else:
                    experience = first(giftsNames)
                    experienceText = text_styles.expText(
                        backport.getIntegralFormat(experience))
                    information = backport.text(rOffer.crewBookInfo(),
                                                exp=experienceText)
                blocks.append(
                    formatters.packTextBlockData(
                        text=text_styles.main(information)))
            else:
                insertEtc = False
                if len(giftsNames) > cls._MAX_GIFTS_COUNT:
                    giftsNames = giftsNames[:cls._MAX_GIFTS_COUNT - 1]
                    insertEtc = True
                for gift in giftsNames:
                    giftName = backport.text(rOffer.point(), item=gift)
                    blocks.append(
                        formatters.packTextBlockData(
                            text=text_styles.main(giftName)))

                if insertEtc:
                    blocks.append(
                        formatters.packTextBlockData(text=text_styles.stats(
                            backport.text(rOffer.etc()))))
        else:
            blocks.append(
                formatters.packImageTextBlockData(
                    title=text_styles.main(backport.text(rOffer.error())),
                    img=backport.image(
                        R.images.gui.maps.icons.library.alertIcon1())))
        return formatters.packBuildUpBlockData(
            blocks,
            padding=formatters.packPadding(left=-1),
            linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE
        )
 def __packMainBlock(cls, item):
     strPath = R.strings.tooltips.selectableCrewbook
     blocks = [
         formatters.packTextBlockData(text=text_styles.highTitle(
             backport.text(strPath.dyn(item.name).title())))
     ]
     blocks.append(
         formatters.packTextBlockData(
             text=text_styles.gold(backport.text(strPath.allNations()))))
     crewbook, _ = first(item.options.getItems())
     experienceText = text_styles.expText(
         backport.getIntegralFormat(crewbook.getXP()))
     information = backport.text(strPath.info(), exp=experienceText)
     blocks.append(
         formatters.packTextBlockData(text=text_styles.main(information)))
     return formatters.packBuildUpBlockData(
         blocks,
         padding=formatters.packPadding(left=-1),
         linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE
     )
 def __getHeaderBlock(self, item, name, level, count, isPlayerLegionary):
     reserveIcon = R.images.gui.maps.icons.reserveTypes.dyn(
         self.__getReserveIconName(name, level))()
     countStr = text_styles.main(
         backport.text(
             R.strings.fortifications.reserves.tooltip.inStorage(),
             count=text_styles.expText(
                 count))) if not isPlayerLegionary else ''
     return formatters.packImageTextBlockData(
         title=text_styles.highTitle(item.shortUserName),
         desc='\n'.join([
             text_styles.neutral(
                 backport.text(
                     R.strings.fortifications.reserves.tooltip.level(),
                     level=int2roman(level))), countStr
         ]),
         img=backport.image(reserveIcon),
         imgPadding=formatters.packPadding(left=5, right=10),
         imgAtLeft=True,
         txtAlign='left',
         linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_IMAGETEXT_BLOCK_LINKAGE,
         padding=formatters.packPadding(top=6),
         blockWidth=500)
Beispiel #15
0
def _getValue(base, self):
    valueStr = '0'
    if self._btnType == CURRENCIES_CONSTANTS.GOLD:
        valueStr = text_styles.gold(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualGold, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.CREDITS:
        valueStr = text_styles.credits(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualCredits, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.CRYSTAL:
        valueStr = text_styles.crystal(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualCrystal, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.EVENT_COIN:
        valueStr = text_styles.eventCoin(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualEventCoin, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.FREE_XP:
        valueStr = text_styles.expText(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualFreeXP, 0)))
    return valueStr
Beispiel #16
0
 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)
Beispiel #17
0
 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
     if buyPrice and sellPrice:
         LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
         return
     else:
         priceBlock = []
         isUnlocked = self.vehicle.isUnlocked
         isInInventory = self.vehicle.isInInventory
         isRented = self.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 = 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
                 priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_XP)), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         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)))
                 priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_DAILYXPFACTOR)), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         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 = self._makePriceBlock(cost, _ms(TOOLTIPS.VEHICLE_UNLOCK_PRICE), ICON_TEXT_FRAMES.XP, neededValue)
                 priceBlock.append(block)
         if buyPrice and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
             price = self.vehicle.buyPrice
             credits, gold = g_itemsCache.items.stats.money
             creditsBuyPrice = price[0]
             goldBuyPrice = price[1]
             creditsNeeded = creditsBuyPrice - credits if creditsBuyPrice else 0
             goldNeeded = goldBuyPrice - gold if goldBuyPrice else 0
             neededValue = None
             actionPrc = self.vehicle.actionPrc
             defaultPrice = self.vehicle.defaultPrice
             if goldBuyPrice == 0:
                 currencyType = ICON_TEXT_FRAMES.CREDITS
                 buyPriceText = creditsBuyPrice
                 oldPrice = defaultPrice[0]
                 if creditsNeeded > 0:
                     neededValue = creditsNeeded
             else:
                 currencyType = ICON_TEXT_FRAMES.GOLD
                 buyPriceText = goldBuyPrice
                 oldPrice = defaultPrice[1]
                 if goldNeeded > 0:
                     neededValue = goldNeeded
             text = _ms(TOOLTIPS.VEHICLE_BUY_PRICE)
             if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                 neededValue = None
             block = self._makePriceBlock(buyPriceText, text, currencyType, neededValue, oldPrice, actionPrc)
             priceBlock.append(block)
         if sellPrice and not self.vehicle.isTelecom:
             creditsPrice = self.vehicle.sellPrice[0]
             goldPrice = self.vehicle.sellPrice[1]
             if goldPrice == 0:
                 sellPriceText = text_styles.credits(_int(creditsPrice))
                 sellPriceIcon = ICON_TEXT_FRAMES.CREDITS
             else:
                 sellPriceText = text_styles.gold(_int(goldPrice))
                 sellPriceIcon = ICON_TEXT_FRAMES.GOLD
             priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_SELL_PRICE)), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         if minRentPrice and not self.vehicle.isPremiumIGR:
             minRentPricePackage = self.vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = minRentPricePackage['rentPrice']
                 minDefaultRentPriceValue = minRentPricePackage['defaultRentPrice']
                 rentActionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage['days'])
                 credits, gold = g_itemsCache.items.stats.money
                 creditsPrice = minRentPriceValue[0]
                 goldPrice = minRentPriceValue[1]
                 enoughCreditsForRent = credits - creditsPrice >= 0
                 enoughGoldForRent = gold - goldPrice >= 0
                 neededValue = None
                 if goldPrice == 0:
                     price = creditsPrice
                     oldPrice = minDefaultRentPriceValue[0]
                     currencyType = ICON_TEXT_FRAMES.CREDITS
                     if not enoughCreditsForRent:
                         neededValue = credits - creditsPrice
                 else:
                     price = goldPrice
                     oldPrice = minDefaultRentPriceValue[1]
                     currencyType = ICON_TEXT_FRAMES.GOLD
                     if not enoughGoldForRent:
                         neededValue = gold - goldPrice
                 text = _ms(TOOLTIPS.VEHICLE_MINRENTALSPRICE)
                 block = self._makePriceBlock(price, text, currencyType, neededValue, oldPrice, rentActionPrc)
                 priceBlock.append(block)
         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:
                 priceBlock.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=self.leftPadding, right=self.rightPadding)))
         return priceBlock
 def _constructHeader(self, skillLevel, level):
     block = []
     if level:
         romanLvl = int2roman(level)
         desc = backport.text(R.strings.epic_battle.metaAbilityScreen.Ability_level(), lvl=text_styles.expText(romanLvl))
         descFormatter = text_styles.main
     else:
         desc = backport.text(R.strings.epic_battle.metaAbilityScreen.Ability_not_unlocked())
         descFormatter = text_styles.standard
     block.append(formatters.packTitleDescBlock(title=text_styles.highTitle(skillLevel.name), desc=descFormatter(desc), gap=-5))
     block.append(formatters.packImageBlockData(img=backport.image(R.images.gui.maps.icons.epicBattles.skills.c_176x176.dyn(skillLevel.icon)()), padding=formatters.packPadding(left=123, top=10)))
     return block
Beispiel #19
0
 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)
Beispiel #20
0
 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)