def __getConfirmator(self, withoutBenefits, period, price): if withoutBenefits: return plugins.HtmlMessageConfirmator( 'buyPremWithoutBenefitsConfirmation', 'html_templates:lobby/dialogs', 'confirmBuyPremWithoutBenefeits', { 'days': text_styles.stats(period), Currency.GOLD: text_styles.concatStylesWithSpace( text_styles.gold(backport.getGoldFormat(price)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) }) localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation' return plugins.MessageConfirmator( localKey, ctx={ 'days': text_styles.stats(period), Currency.GOLD: text_styles.concatStylesWithSpace( text_styles.gold(backport.getGoldFormat(price)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) })
def _getState(self, resToExchange): if resToExchange <= 0: return (CONFIRM_EXCHANGE_DIALOG_TYPES.EXCHANGE_NOT_NEEED_STATE, text_styles.success(self._makeString(I18N_EXCHANGENONEEDTEXT_KEY))) if not self._isEnoughGold(resToExchange): goldToExchange = self._getGoldToExchange(resToExchange) fmtGold = ''.join((text_styles.gold(backport.getGoldFormat(goldToExchange)), icons.gold())) return (CONFIRM_EXCHANGE_DIALOG_TYPES.NOT_ENOUGH_GOLD_STATE, text_styles.error(self._makeString(I18N_GOLDNOTENOUGHTEXT_KEY, {'gold': fmtGold}))) return (CONFIRM_EXCHANGE_DIALOG_TYPES.NORMAL_STATE, '')
def makePercentLabel(value): formatted = backport.getGoldFormat(int(value)) template = 'percent' if value < 0: formatted = markValueAsError(formatted) template = 'negative_percent' return makeHtmlString('html_templates:lobby/battle_results', template, {'value': formatted})
def makeGoldLabel(value, canBeFaded=False): formatted = backport.getGoldFormat(value) if canBeFaded and not value: template = 'gold_small_inactive_label' else: template = 'gold_small_label' return makeHtmlString('html_templates:lobby/battle_results', template, {'value': formatted})
def __makeConfirmator(self): xpLimit = self.itemsCache.items.shop.freeXPConversionLimit extra = {'resultCurrencyAmount': backport.getIntegralFormat(self.xp), 'primaryCurrencyAmount': backport.getGoldFormat(self.gold)} if self.__freeConversion: sourceKey = 'XP_EXCHANGE_FOR_FREE' extra['freeXPLimit'] = backport.getIntegralFormat(xpLimit) else: sourceKey = 'XP_EXCHANGE_FOR_GOLD' return plugins.HtmlMessageConfirmator('exchangeXPConfirmation', 'html_templates:lobby/dialogs', 'confirmExchangeXP', extra, sourceKey=sourceKey)
def __getControlQuestion(self, usingGold=False): if usingGold: currencyFormatter = backport.getGoldFormat( long(self.__controlNumber)) else: currencyFormatter = backport.getIntegralFormat( long(self.__controlNumber)) question = makeHtmlString('html_templates:lobby/dialogs', 'vehicleSellQuestion', {'controlNumber': currencyFormatter}) return question
def makeCreditsLabel(value, canBeFaded=False, isDiff=False, useBigIcon=False): formatted = backport.getGoldFormat(int(round(value))) if value < 0: formatted = markValueAsError(formatted) if isDiff: formatted = _DIFF_FORMAT.format(formatted) if useBigIcon: template = 'credits_label' elif canBeFaded and not value: template = 'credits_small_inactive_label' else: template = 'credits_small_label' return makeHtmlString('html_templates:lobby/battle_results', template, {'value': formatted})
def __init__(self, gold, withConfirm=True): self.gold = gold self.credits = int(gold) * self.itemsCache.items.shop.exchangeRate super(GoldToCreditsExchanger, self).__init__() if withConfirm: self.addPlugin( plugins.HtmlMessageConfirmator( 'exchangeGoldConfirmation', 'html_templates:lobby/dialogs', 'confirmExchange', { 'primaryCurrencyAmount': backport.getGoldFormat(self.gold), 'resultCurrencyAmount': backport.getIntegralFormat(self.credits) })) self.addPlugin(plugins.MoneyValidator(Money(gold=self.gold)))
def _packBuyBerthsSlot(itemsCache=None): berths = itemsCache.items.stats.tankmenBerthsCount berthPrice, berthCount = itemsCache.items.shop.getTankmanBerthPrice(berths) defaultBerthPrice, _ = itemsCache.items.shop.defaults.getTankmanBerthPrice( berths) action = None if berthPrice != defaultBerthPrice: action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'berthsPrices', True, berthPrice, defaultBerthPrice) return { 'buy': True, 'price': backport.getGoldFormat(berthPrice.getSignValue(Currency.GOLD)), 'actionPriceData': action, 'count': berthCount }
def _getDiscountSection(self, discount, bonuses): discount = discount or 0 formattedDiscount = makeHtmlString( 'html_templates:lobby/quests/actions', Currency.GOLD, {'value': backport.getGoldFormat(long(discount))}) discountBlock = formatters.packTextBlockData( padding=formatters.packPadding(left=50), text=_ms(text_styles.main(TOOLTIPS.FRONTLINEPACKPREVIEW_DISCOUNT), value=formattedDiscount)) return formatters.packBuildUpBlockData( blocks=[ discountBlock, self._getGiftBlock(), self._getBonusSection(bonuses) ], gap=25, layout=BLOCKS_TOOLTIP_TYPES.LAYOUT_VERTICAL, align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER)
def __getRentButtonLabel(rootNode): btnLabel = '' if NODE_STATE.isRentAvailable(rootNode.getState()): minRentPrice, currency = rootNode.getRentInfo() if currency == Currency.CREDITS: btnLabel = text_styles.concatStylesWithSpace( backport.text( R.strings.menu.research.labels.button.rent()), text_styles.credits( backport.getIntegralFormat(minRentPrice.credits)), icons.credits()) elif currency == Currency.GOLD: btnLabel = text_styles.concatStylesWithSpace( backport.text( R.strings.menu.research.labels.button.rent()), text_styles.gold(backport.getGoldFormat( minRentPrice.gold)), icons.gold()) return btnLabel
def __setPremiumBonusData(self): value = '' icon = backport.image( R.images.gui.maps.icons.premacc.battleResult.premium()) piggyBankConfig = self.__lobbyContext.getServerSettings( ).getPiggyBankConfig() piggyBankMaxAmount = piggyBankConfig.get('creditsThreshold', 0) period = piggyBankConfig.get('cycleLength', time_utils.ONE_DAY) periodInDays = ceil(period / time_utils.ONE_DAY) bonusConfig = self.__lobbyContext.getServerSettings( ).getAdditionalBonusConfig() multiplier = premacc_helpers.validateAdditionalBonusMultiplier( bonusConfig.get('bonusFactor', 1)) if not self.__itemsCache.items.stats.isActivePremium( PREMIUM_TYPE.PLUS): if self.__itemsCache.items.stats.isActivePremium( PREMIUM_TYPE.BASIC): value = backport.text( R.strings.battle_results.common.details.premiumPlus.dyn( self.__adsCase)(), bonusCredits=text_styles.concatStylesToSingleLine( text_styles.credits( backport.getGoldFormat(piggyBankMaxAmount)), icons.makeImageTag(backport.image( R.images.gui.maps.icons.library.CreditsIcon_2()), vSpace=-5)), durationInDays=periodInDays, multiplier=multiplier) iconName = 'bonus_x{}'.format( multiplier ) if self.__adsCase == 'bonus' else self.__adsCase icon = backport.image( R.images.gui.maps.icons.premacc.battleResult.dyn(iconName) ()) elif self.__creditsDiff < 0 or self.__xpDiff < 0: value = backport.text(R.strings.battle_results.common.details. premiumPlus.premium()) else: value = backport.text( R.strings.battle_results.common.premiumBonus()) self.premiumBonusStr = value self.backgroundIcon = icon
def _getGoldToExchangeTxt(self, resToExchange): if resToExchange > 0: goldToExchange = self._getGoldToExchange(resToExchange) fmtGold = ''.join((text_styles.gold(backport.getGoldFormat(goldToExchange)), icons.gold())) return text_styles.main(self._makeString(I18N_NEEDGOLDTEXT_KEY, {'gold': fmtGold}))
def setRecord(self, result, reusable): intVal = reusable.personal.getBaseCreditsRecords().getRecord('credits') strVal = backport.getGoldFormat(intVal) self.addNextComponent(base.DirectStatsItem('value', intVal)) self.addNextComponent(base.DirectStatsItem('str', strVal))
def getGoldFormat(cls, value): return backport.getGoldFormat(value)
def _getValue(self, value): return backport.getGoldFormat(long(value))
def _successHandler(self, code, ctx=None): return makeI18nSuccess(sysMsgKey='exchangeXP/success', gold=backport.getGoldFormat(self.gold), xp=backport.getIntegralFormat(self.xp), type=SM_TYPE.FinancialTransactionWithGold)
def _successHandler(self, code, ctx=None): return makeI18nSuccess(sysMsgKey='exchange/success', gold=backport.getGoldFormat(self.gold), credits=formatPrice( Money(credits=self.credits)), type=SM_TYPE.FinancialTransactionWithGold)