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(BigWorld.wg_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(BigWorld.wg_getGoldFormat(price)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) })
def __getConfirmator(self, withoutBenefits, period, price): if withoutBenefits: return plugins.HtmlMessageConfirmator('buyPremWithoutBenefitsConfirmation', 'html_templates:lobby/dialogs', 'confirmBuyPremWithoutBenefeits', {'days': int(period), 'gold': BigWorld.wg_getGoldFormat(price)}) else: localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation' return plugins.MessageConfirmator(localKey, ctx={'days': int(period), 'gold': BigWorld.wg_getGoldFormat(price)})
def __getConfirmator(self, withoutBenefits, period, price): if withoutBenefits: return plugins.HtmlMessageConfirmator( "buyPremWithoutBenefitsConfirmation", "html_templates:lobby/dialogs", "confirmBuyPremWithoutBenefeits", {"days": int(period), "gold": BigWorld.wg_getGoldFormat(price)}, ) else: localKey = "premiumContinueConfirmation" if self.wasPremium else "premiumBuyConfirmation" return plugins.MessageConfirmator( localKey, ctx={"days": int(period), "gold": BigWorld.wg_getGoldFormat(price)} )
def __onChangeVehicleCamouflage(self, price, kind, resultID): if resultID < 0: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SERVER_ERROR) self.onCustomizationChangeFailed(message) return else: item = self.currentItemsByKind.get(kind) g_tankActiveCamouflage[g_currentVehicle.item.intCD] = kind item['id'] = item.get('newItemID') item['lifeCycle'] = None item['newItemID'] = None if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind: self._itemsDP.currentItemID = item['id'] cost, isGold = price if cost == 0: key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_FREE typeValue = SystemMessages.SM_TYPE.Information str = i18n.makeString(key) else: if isGold: key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_GOLD fCost = BigWorld.wg_getGoldFormat(cost) typeValue = SystemMessages.SM_TYPE.CustomizationForGold else: key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_CREDITS fCost = BigWorld.wg_getIntegralFormat(cost) typeValue = SystemMessages.SM_TYPE.CustomizationForCredits str = i18n.makeString(key, fCost) self.onCustomizationChangeSuccess(str, typeValue) return
def __getControlQuestion(self, usingGold = False): if usingGold: currencyFormatter = BigWorld.wg_getGoldFormat(long(self.controlNumber)) else: currencyFormatter = BigWorld.wg_getIntegralFormat(long(self.controlNumber)) question = makeHtmlString('html_templates:lobby/dialogs', 'vehicleSellQuestion', {'controlNumber': currencyFormatter}) return question
def __onChangeVehicleInscription(self, resultID, price): if resultID < 0: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_CHANGE_SERVER_ERROR) self.onCustomizationChangeFailed(message) return self._currentItemID = self._newItemID self._currentLifeCycle = None self._newItemID = None self._itemsDP.currentItemID = self._currentItemID cost, isGold = price if cost == 0: key = SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_CHANGE_SUCCESS_FREE type = SystemMessages.SM_TYPE.Information str = i18n.makeString(key) else: if isGold: key = SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_CHANGE_SUCCESS_GOLD fCost = BigWorld.wg_getGoldFormat(cost) type = SystemMessages.SM_TYPE.CustomizationForGold else: key = SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_CHANGE_SUCCESS_CREDITS fCost = BigWorld.wg_getIntegralFormat(cost) type = SystemMessages.SM_TYPE.CustomizationForCredits str = i18n.makeString(key, fCost) self.onCustomizationChangeSuccess(str, type)
def _successHandler(self, code, ctx=None): return makeI18nSuccess( "exchange/success", gold=BigWorld.wg_getGoldFormat(self.gold), credits=formatPrice((self.credits, 0)), type=SM_TYPE.FinancialTransactionWithGold, )
def _populate(self): super(IconPriceDialog, self)._populate() self.as_setPriceLabelS( i18n.makeString( DIALOGS.REMOVECONFIRMATIONNOTREMOVABLEGOLD_MESSAGEPRICE)) self.as_setMessagePriceS( BigWorld.wg_getGoldFormat(self._meta.getMessagePrice()), 'gold')
def getShellsLayoutFormatedPrice(self, intCD, colorManager, checkMoney=True, joinString=False): userCredits = g_itemsCache.items.stats.credits userGold = g_itemsCache.items.stats.gold creditsColor = colorManager.getColorScheme("textColorCredits").get("rgb") goldColor = colorManager.getColorScheme("textColorGold").get("rgb") errorColor = colorManager.getColorScheme("textColorError").get("rgb") result = [] for c, g in self.getShellsLayoutPrice(intCD): priceLabel = "" if g: params = { "value": BigWorld.wg_getGoldFormat(g), "color": goldColor if not checkMoney or userGold >= g else errorColor, "icon": getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2), } priceLabel += makeHtmlString("html_templates:lobby/historicalBattles/ammoStatus", "priceLabel", params) if c: params = { "value": BigWorld.wg_getIntegralFormat(c), "color": creditsColor if not checkMoney or userCredits >= c else errorColor, "icon": getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2), } priceLabel += makeHtmlString("html_templates:lobby/historicalBattles/ammoStatus", "priceLabel", params) result.append(priceLabel) if joinString: return i18n.makeString("#historical_battles:ammoPreset/priceConcat").join(result) return result
def _successHandler(self, code, ctx=None): return makeI18nSuccess( "exchangeXP/success", gold=BigWorld.wg_getGoldFormat(self.gold), xp=BigWorld.wg_getIntegralFormat(self.xp), type=SM_TYPE.FinancialTransactionWithGold, )
def __updateTankmen(self, *args): tankmen = g_itemsCache.items.getTankmen().values() slots = g_itemsCache.items.stats.tankmenBerthsCount berths = g_itemsCache.items.stats.tankmenBerthsCount berthPrice = g_itemsCache.items.shop.getTankmanBerthPrice(berths) defaultBerthPrice = g_itemsCache.items.shop.defaults.getTankmanBerthPrice(berths) tankmenList = list() tankmenInBarracks = 0 for tankman in sorted(tankmen, TankmenComparator(g_itemsCache.items.getVehicle)): if not tankman.isInTank: tankmenInBarracks += 1 slot, vehicleID, vehicleInnationID, vehicle = (None, None, None, None) if tankman.isInTank: vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID) vehicleID = vehicle.invID vehicleInnationID = vehicle.innationID if vehicle is None: LOG_ERROR('Cannot find vehicle for tankman: ', tankman, tankman.descriptor.role, tankman.vehicle.name, tankman.firstname, tankman.lastname) continue slot = tankman.vehicleSlotIdx if self.filter['nation'] != -1 and tankman.nationID != self.filter['nation'] or self.filter['role'] != 'None' and tankman.descriptor.role != self.filter['role'] or self.filter['tankType'] != 'None' and tankman.vehicleNativeType != self.filter['tankType'] or self.filter['location'] == 'tanks' and tankman.isInTank != True or self.filter['location'] == 'barracks' and tankman.isInTank == True or self.filter['nationID'] is not None and (self.filter['location'] != str(vehicleInnationID) or self.filter['nationID'] != str(tankman.nationID)): continue isLocked, msg = self.getTankmanLockMessage(vehicle) if tankman.isInTank else (False, '') tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) isInCurrentTank = tankmanVehicle.invID == g_currentVehicle.invID if tankman.isInTank and g_currentVehicle.isPresent() else False tankmenList.append({'firstname': tankman.firstUserName, 'lastname': tankman.lastUserName, 'rank': tankman.rankUserName, 'specializationLevel': tankman.realRoleLevel[0], 'role': tankman.roleUserName, 'vehicleType': tankmanVehicle.shortUserName, 'iconFile': tankman.icon, 'rankIconFile': tankman.iconRank, 'roleIconFile': '%s/%s' % (Tankman.ROLE_ICON_PATH_BIG, tankman.iconRole), 'contourIconFile': tankmanVehicle.iconContour, 'tankmanID': tankman.invID, 'nationID': tankman.nationID, 'typeID': tankmanVehicle.innationID, 'slot': slot, 'roleType': tankman.descriptor.role, 'tankType': tankmanVehicle.type, 'inTank': tankman.isInTank, 'inCurrentTank': isInCurrentTank, 'vehicleID': vehicleID, 'compact': str(tankman.invID), 'locked': isLocked, 'lockMessage': msg, 'vehicleBroken': vehicle.repairCost > 0 if tankman.isInTank else None, 'isInSelfVehicleClass': vehicle.type == tankmanVehicle.type if tankman.isInTank else True, 'isInSelfVehicleType': vehicle.shortUserName == tankmanVehicle.shortUserName if tankman.isInTank else True}) action = None if berthPrice[0] != defaultBerthPrice[0]: action = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS, 'key': 'berthsPrices', 'isBuying': True, 'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT), 'newPrice': (0, berthPrice[0]), 'oldPrice': (0, defaultBerthPrice[0])} self.as_setTankmenS(len(tankmen), slots, tankmenInBarracks, BigWorld.wg_getGoldFormat(berthPrice[0]), action, berthPrice[1], tankmenList)
def makePercentLabel(value): formatted = BigWorld.wg_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 __showSuccessSysMsg(self, gold, vcoin): SystemMessages.g_instance.pushMessage( i18n.makeString('#system_messages:ebank/response/success') % { 'gold': BigWorld.wg_getGoldFormat(gold), 'vcoin': BigWorld.wg_getIntegralFormat(vcoin) }, type=SystemMessages.SM_TYPE.FinancialTransactionWithGold)
def makeGoldLabel(value, canBeFaded = False): formatted = BigWorld.wg_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 __onChangeVehicleEmblem(self, resultID, price): if resultID < 0: message = i18n.makeString( SYSTEM_MESSAGES.CUSTOMIZATION_EMBLEM_CHANGE_SERVER_ERROR) self.onCustomizationChangeFailed(message) return else: self._currentItemID = self._newItemID self._currentLifeCycle = (round(time.time()), 0) self._newItemID = None self._itemsDP.currentItemID = self._currentItemID cost, isGold = price if cost == 0: key = SYSTEM_MESSAGES.CUSTOMIZATION_EMBLEM_CHANGE_SUCCESS_FREE type = SystemMessages.SM_TYPE.Information str = i18n.makeString(key) else: if isGold: key = SYSTEM_MESSAGES.CUSTOMIZATION_EMBLEM_CHANGE_SUCCESS_GOLD fCost = BigWorld.wg_getGoldFormat(cost) type = SystemMessages.SM_TYPE.CustomizationForGold else: key = SYSTEM_MESSAGES.CUSTOMIZATION_EMBLEM_CHANGE_SUCCESS_CREDITS fCost = BigWorld.wg_getIntegralFormat(cost) type = SystemMessages.SM_TYPE.CustomizationForCredits str = i18n.makeString(key, fCost) self.onCustomizationChangeSuccess(str, type) return
def __init__(self, tankman, firstNameID, firstNameGroup, lastNameID, lastNameGroup, iconID, iconGroup): hasUniqueData = self.__hasUniqueData(tankman, firstNameID, lastNameID, iconID) isFemale = tankman.descriptor.isFemale if isFemale: price = self.itemsCache.items.shop.passportFemaleChangeCost else: price = self.itemsCache.items.shop.passportChangeCost super(TankmanChangePassport, self).__init__( tankman, (plugins.TankmanChangePassportValidator(tankman), plugins.MessageConfirmator( 'replacePassport/unique' if hasUniqueData else 'replacePassportConfirmation', ctx={ Currency.GOLD: text_styles.concatStylesWithSpace( text_styles.gold(BigWorld.wg_getGoldFormat(price)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) }))) self.firstNameID = firstNameID self.firstNameGroup = firstNameGroup self.lastNameID = lastNameID self.lastNameGroup = lastNameGroup self.iconID = iconID self.iconGroup = iconGroup self.isFemale = isFemale self.isPremium = tankman.descriptor.isPremium self.price = price
def __onChangeVehicleCamouflage(self, price, kind, resultID): if resultID < 0: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SERVER_ERROR) self.onCustomizationChangeFailed(message) return else: item = self.currentItemsByKind.get(kind) g_tankActiveCamouflage[g_currentVehicle.item.intCD] = kind item['id'] = item.get('newItemID') item['lifeCycle'] = None item['newItemID'] = None if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind: self._itemsDP.currentItemID = item['id'] cost, isGold = price if isGold: key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_GOLD fCost = BigWorld.wg_getGoldFormat(cost) typeValue = SystemMessages.SM_TYPE.CustomizationForGold else: key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_CREDITS fCost = BigWorld.wg_getIntegralFormat(cost) typeValue = SystemMessages.SM_TYPE.CustomizationForCredits str = i18n.makeString(key, fCost) self.onCustomizationChangeSuccess(str, typeValue) return
def __getGoldToExchangeTxt(self, resToExchange): if resToExchange > 0: goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = ''.join( (text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return text_styles.main( self._makeString(I18N_NEEDGOLDTEXT_KEY, {'gold': fmtGold}))
def __getConfirmator(self, withoutBenefits, period, price): if withoutBenefits: return plugins.HtmlMessageConfirmator( 'buyPremWithoutBenefitsConfirmation', 'html_templates:lobby/dialogs', 'confirmBuyPremWithoutBenefeits', { 'days': int(period), 'gold': BigWorld.wg_getGoldFormat(price) }) else: localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation' return plugins.MessageConfirmator( localKey, ctx={ 'days': int(period), 'gold': BigWorld.wg_getGoldFormat(price) })
def __init__(self, period, price, arenaUniqueID = 0): self.wasPremium = g_itemsCache.items.stats.isPremium localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation' super(PremiumAccountBuyer, self).__init__((plugins.MessageConfirmator(localKey, ctx={'days': int(period), 'gold': BigWorld.wg_getGoldFormat(price)}), plugins.MoneyValidator((0, price)))) self.premiumPrice = price self.period = period self.arenaUniqueID = arenaUniqueID
def __makeConfirmator(self): xpLimit = self.itemsCache.items.shop.freeXPConversionLimit extra = {'resultCurrencyAmount': BigWorld.wg_getIntegralFormat(self.xp), 'primaryCurrencyAmount': BigWorld.wg_getGoldFormat(self.gold)} if self.__freeConversion: sourceKey = 'XP_EXCHANGE_FOR_FREE' extra['freeXPLimit'] = BigWorld.wg_getIntegralFormat(xpLimit) else: sourceKey = 'XP_EXCHANGE_FOR_GOLD' return plugins.HtmlMessageConfirmator('exchangeXPConfirmation', 'html_templates:lobby/dialogs', 'confirmExchangeXP', extra, sourceKey=sourceKey)
def __makeConfirmator(self): xpLimit = g_itemsCache.items.shop.freeXPConversionLimit extra = {'resultCurrencyAmount': BigWorld.wg_getIntegralFormat(self.xp), 'primaryCurrencyAmount': BigWorld.wg_getGoldFormat(self.gold)} if self.__freeConversion: sourceKey = 'XP_EXCHANGE_FOR_FREE' extra['freeXPLimit'] = BigWorld.wg_getIntegralFormat(xpLimit) else: sourceKey = 'XP_EXCHANGE_FOR_GOLD' return plugins.HtmlMessageConfirmator('exchangeXPConfirmation', 'html_templates:lobby/dialogs', 'confirmExchangeXP', extra, sourceKey=sourceKey)
def __getGoldToExchangeTxt(self, resToExchange): """ :param resToExchange: <int> resource for exchange :return: formatted needed gold to exchange text """ if resToExchange > 0: goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = "".join((text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return text_styles.main(self._makeString(I18N_NEEDGOLDTEXT_KEY, {"gold": fmtGold})) return ""
def __getControlQuestion(self, usingGold=False): if usingGold: currencyFormatter = BigWorld.wg_getGoldFormat( long(self.__controlNumber)) else: currencyFormatter = BigWorld.wg_getIntegralFormat( long(self.__controlNumber)) question = makeHtmlString('html_templates:lobby/dialogs', 'vehicleSellQuestion', {'controlNumber': currencyFormatter}) return question
def makeCreditsLabel(value, canBeFaded = False, isDiff = False): formatted = BigWorld.wg_getGoldFormat(int(value)) if value < 0: formatted = markValueAsError(formatted) if isDiff: formatted = _DIFF_FORMAT.format(formatted) if 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 __onWalletChanged(self, status): self.as_goldResponseS( BigWorld.wg_getGoldFormat(g_itemsCache.items.stats.actualGold), MENU.HEADERBUTTONS_BTNLABEL_BUY_GOLD, TOOLTIPS.HEADER_REFILL, TOOLTIP_TYPES.COMPLEX) self.as_setFreeXPS( BigWorld.wg_getIntegralFormat( g_itemsCache.items.stats.actualFreeXP), MENU.HEADERBUTTONS_BTNLABEL_GATHERING_EXPERIENCE, g_itemsCache.items.shop.isXPConversionActionActive, TOOLTIPS.HEADER_XP_GATHERING, TOOLTIP_TYPES.COMPLEX) self.as_setWalletStatusS(status)
def __init__(self, gold): self.gold = gold self.credits = int(gold) * g_itemsCache.items.shop.exchangeRate super(GoldToCreditsExchanger, self).__init__(plugins=(plugins.HtmlMessageConfirmator( 'exchangeGoldConfirmation', 'html_templates:lobby/dialogs', 'confirmExchange', { 'primaryCurrencyAmount': BigWorld.wg_getGoldFormat(self.gold), 'resultCurrencyAmount': BigWorld.wg_getIntegralFormat(self.credits) }), plugins.MoneyValidator(Money(gold=self.gold))))
def formatDiscount(discountVal, discountType): multiplier = "+" if discountVal < 0 else "" if discountType == DISCOUNT_TYPE.GOLD: return makeHtmlString( "html_templates:lobby/quests/actions", "gold", {"value": multiplier + BigWorld.wg_getGoldFormat(abs(long(discountVal)))}, ) return makeHtmlString( "html_templates:lobby/quests/actions", discountType, {"value": multiplier + BigWorld.wg_getIntegralFormat(abs(int(discountVal)))}, )
def __getDurationStr(self, period, cost, hasAction, isEnoughMoney): priceStr = '' if not hasAction: key = 'gold' if isEnoughMoney else 'goldAlert' priceStr = makeHtmlString( 'html_templates:lobby/dialogs/premium', key, ctx={'value': BigWorld.wg_getGoldFormat(cost)}) duration = i18n.makeString(PREMIUM_PACKET_LOCAL_KEY % period) ctx = {'duration': duration, 'price': priceStr} return makeHtmlString('html_templates:lobby/dialogs/premium', 'duration', ctx=ctx)
def __getGoldToExchangeTxt(self, resToExchange): """ :param resToExchange: <int> resource for exchange :return: formatted needed gold to exchange text """ if resToExchange > 0: goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = ''.join( (text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return text_styles.main( self._makeString(I18N_NEEDGOLDTEXT_KEY, {'gold': fmtGold})) return ''
def formatDiscount(discountVal, discountType): multiplier = '+' if discountVal < 0 else '' if discountType == DISCOUNT_TYPE.GOLD: return makeHtmlString( 'html_templates:lobby/quests/actions', 'gold', { 'value': multiplier + BigWorld.wg_getGoldFormat(abs(long(discountVal))) }) return makeHtmlString( 'html_templates:lobby/quests/actions', discountType, { 'value': multiplier + BigWorld.wg_getIntegralFormat(abs(int(discountVal))) })
def __premiumBuyRequest(self, days, price): stats = yield StatsRequester().request() if account_helpers.isPremiumAccount(stats.attributes): dialogId = 'premiumContinueConfirmation' else: dialogId = 'premiumBuyConfirmation' isOk = yield DialogsInterface.showDialog(I18nConfirmDialogMeta(dialogId, messageCtx={'days': int(days), 'gold': BigWorld.wg_getGoldFormat(price)})) if isOk and days: if stats.gold < price: self.__systemErrorMessage(SYSTEM_MESSAGES.PREMIUM_NOT_ENOUGH_GOLD, days, SystemMessages.SM_TYPE.Warning) else: self.__upgradeToPremium(days) self.destroy()
def _packBuyBerthsSlot(): berths = g_itemsCache.items.stats.tankmenBerthsCount berthPrice, berthCount = g_itemsCache.items.shop.getTankmanBerthPrice(berths) defaultBerthPrice, _ = g_itemsCache.items.shop.defaults.getTankmanBerthPrice(berths) gold = g_itemsCache.items.stats.money.gold action = None if berthPrice != defaultBerthPrice: action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'berthsPrices', True, berthPrice, defaultBerthPrice) enoughGold = berthPrice.gold <= gold return {'buy': True, 'price': BigWorld.wg_getGoldFormat(berthPrice.gold), 'enoughGold': enoughGold, 'actionPriceData': action, 'count': berthCount}
def formatPrice(price, reverse = False): outPrice = [] credits, gold = price[:2] if credits != 0 or gold == 0: cname = makeString('#menu:price/credits') + ': ' cformatted = BigWorld.wg_getIntegralFormat(credits) outPrice.extend([cformatted, ' ', cname] if reverse else [cname, ' ', cformatted]) if gold != 0: outPrice.append(', ') if gold != 0: gname = makeString('#menu:price/gold') + ': ' gformatted = BigWorld.wg_getGoldFormat(gold) outPrice.extend([gformatted, ' ', gname] if reverse else [gname, ' ', gformatted]) return ''.join(outPrice)
def __makeConfirmator(self): xpLimit = g_itemsCache.items.shop.freeXPConversionLimit extra = { "resultCurrencyAmount": BigWorld.wg_getIntegralFormat(self.xp), "primaryCurrencyAmount": BigWorld.wg_getGoldFormat(self.gold), } if self.__freeConversion: sourceKey = "XP_EXCHANGE_FOR_FREE" extra["freeXPLimit"] = BigWorld.wg_getIntegralFormat(xpLimit) else: sourceKey = "XP_EXCHANGE_FOR_GOLD" return plugins.HtmlMessageConfirmator( "exchangeXPConfirmation", "html_templates:lobby/dialogs", "confirmExchangeXP", extra, sourceKey=sourceKey )
def __init__(self, period, price, arenaUniqueID=0): self.wasPremium = g_itemsCache.items.stats.isPremium localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation' super(PremiumAccountBuyer, self).__init__( (plugins.MessageConfirmator(localKey, ctx={ 'days': int(period), 'gold': BigWorld.wg_getGoldFormat(price) }), plugins.MoneyValidator( (0, price)))) self.premiumPrice = price self.period = period self.arenaUniqueID = arenaUniqueID
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(BigWorld.wg_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 __init__(self, gold): self.gold = gold self.credits = int(gold) * g_itemsCache.items.shop.exchangeRate super(GoldToCreditsExchanger, self).__init__( plugins=( plugins.HtmlMessageConfirmator( "exchangeGoldConfirmation", "html_templates:lobby/dialogs", "confirmExchange", { "primaryCurrencyAmount": BigWorld.wg_getGoldFormat(self.gold), "resultCurrencyAmount": BigWorld.wg_getIntegralFormat(self.credits), }, ), plugins.MoneyValidator((0, self.gold)), ) )
def getShellsLayoutFormatedPrice(self, intCD, colorManager, checkMoney=True, joinString=False): userCredits = g_itemsCache.items.stats.credits userGold = g_itemsCache.items.stats.gold creditsColor = colorManager.getColorScheme('textColorCredits').get( 'rgb') goldColor = colorManager.getColorScheme('textColorGold').get('rgb') errorColor = colorManager.getColorScheme('textColorError').get('rgb') result = [] for c, g in self.getShellsLayoutPrice(intCD): priceLabel = '' if g: params = { 'value': BigWorld.wg_getGoldFormat(g), 'color': goldColor if not checkMoney or userGold >= g else errorColor, 'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2) } priceLabel += makeHtmlString( 'html_templates:lobby/historicalBattles/ammoStatus', 'priceLabel', params) if c: params = { 'value': BigWorld.wg_getIntegralFormat(c), 'color': creditsColor if not checkMoney or userCredits >= c else errorColor, 'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2) } priceLabel += makeHtmlString( 'html_templates:lobby/historicalBattles/ammoStatus', 'priceLabel', params) result.append(priceLabel) if joinString: return i18n.makeString( '#historical_battles:ammoPreset/priceConcat').join(result) return result
def _packBuyBerthsSlot(itemsCache=None): berths = itemsCache.items.stats.tankmenBerthsCount berthPrice, berthCount = itemsCache.items.shop.getTankmanBerthPrice(berths) defaultBerthPrice, _ = itemsCache.items.shop.defaults.getTankmanBerthPrice( berths) gold = itemsCache.items.stats.money.gold action = None if berthPrice != defaultBerthPrice: action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'berthsPrices', True, berthPrice, defaultBerthPrice) enoughGold = berthPrice.gold <= gold return { 'buy': True, 'price': BigWorld.wg_getGoldFormat(berthPrice.getSignValue(Currency.GOLD)), 'enoughGold': enoughGold or isIngameShopEnabled(), 'actionPriceData': action, 'count': berthCount }
def __getState(self, resToExchange): """ Gets state and reason for exchange possibility :param resToExchange: <int> resource for exchange :return: <tuple(state:<int>, reason<str>)> """ 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(BigWorld.wg_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 __premiumBuyRequest(self, days, price): stats = yield StatsRequesterr().request() if account_helpers.isPremiumAccount(stats.attributes): dialogId = 'premiumContinueConfirmation' else: dialogId = 'premiumBuyConfirmation' isOk = yield DialogsInterface.showDialog( I18nConfirmDialogMeta(dialogId, messageCtx={ 'days': int(days), 'gold': BigWorld.wg_getGoldFormat(price) })) if isOk and days: if stats.gold < price: self.__systemErrorMessage( SYSTEM_MESSAGES.PREMIUM_NOT_ENOUGH_GOLD, days, SystemMessages.SM_TYPE.Warning) else: self.__upgradeToPremium(days) self.destroy()
def __getState(self, resToExchange): """ Gets state and reason for exchange possibility :param resToExchange: <int> resource for exchange :return: <tuple(state:<int>, reason<str>)> """ if resToExchange <= 0: return ( CONFIRM_EXCHANGE_DIALOG_TYPES.EXCHANGE_NOT_NEEED_STATE, text_styles.success(self._makeString(I18N_EXCHANGENONEEDTEXT_KEY)), ) elif not self.__isEnoughGold(resToExchange): goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = "".join((text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return ( CONFIRM_EXCHANGE_DIALOG_TYPES.NOT_ENOUGH_GOLD_STATE, text_styles.error(self._makeString(I18N_GOLDNOTENOUGHTEXT_KEY, {"gold": fmtGold})), ) else: return (CONFIRM_EXCHANGE_DIALOG_TYPES.NORMAL_STATE, "")
def __onCustomizationChange(self, price, cType, resultID): if resultID < 0: message = _ms(_INSTALLATION_MESSAGE[cType]['error']) sysMessageType = SystemMessages.SM_TYPE.Error else: cost, isGold = price if cost <= 0: message = _ms(_INSTALLATION_MESSAGE[cType]['free']) sysMessageType = SystemMessages.SM_TYPE.Information else: if isGold: key = _INSTALLATION_MESSAGE[cType]['successGold'] fCost = BigWorld.wg_getGoldFormat(cost) sysMessageType = SystemMessages.SM_TYPE.CustomizationForGold else: key = _INSTALLATION_MESSAGE[cType]['successCredits'] fCost = BigWorld.wg_getIntegralFormat(cost) sysMessageType = SystemMessages.SM_TYPE.CustomizationForCredits message = _ms(key, fCost) SystemMessages.pushMessage(message, type=sysMessageType) self.__synchronizeDossierIfRequired()
def _getValue(self, value): return BigWorld.wg_getGoldFormat(long(value))
def __onWalletChanged(self, status): self.as_goldResponseS(BigWorld.wg_getGoldFormat(g_itemsCache.items.stats.actualGold), MENU.HEADERBUTTONS_BTNLABEL_BUY_GOLD, TOOLTIPS.HEADER_REFILL, TOOLTIP_TYPES.COMPLEX) self.as_setFreeXPS(BigWorld.wg_getIntegralFormat(g_itemsCache.items.stats.actualFreeXP), MENU.HEADERBUTTONS_BTNLABEL_GATHERING_EXPERIENCE, g_itemsCache.items.shop.isXPConversionActionActive, TOOLTIPS.HEADER_XP_GATHERING, TOOLTIP_TYPES.COMPLEX) self.as_setWalletStatusS(status)
def __setGold(self, gold): self.as_goldResponseS(BigWorld.wg_getGoldFormat(gold), MENU.HEADERBUTTONS_BTNLABEL_BUY_GOLD, TOOLTIPS.HEADER_REFILL, TOOLTIP_TYPES.COMPLEX)
def formatGoldPrice(gold, reverse = False): outPrice = [] gname = makeString('#menu:price/gold') + ': ' gformatted = BigWorld.wg_getGoldFormat(gold) outPrice.extend([gformatted, ' ', gname] if reverse else [gname, ' ', gformatted]) return ''.join(outPrice)
def __updateTankmen(self, *args): tankmen = g_itemsCache.items.getTankmen().values() slots = g_itemsCache.items.stats.tankmenBerthsCount berths = g_itemsCache.items.stats.tankmenBerthsCount berthPrice = g_itemsCache.items.shop.getTankmanBerthPrice(berths) defaultBerthPrice = g_itemsCache.items.shop.defaults.getTankmanBerthPrice(berths) tankmenList = list() tankmenInBarracks = 0 tankmenInSlots = 0 action = None if berthPrice[0] != defaultBerthPrice[0]: action = { "type": ACTION_TOOLTIPS_TYPE.ECONOMICS, "key": "berthsPrices", "isBuying": True, "state": (None, ACTION_TOOLTIPS_STATE.DISCOUNT), "newPrice": (0, berthPrice[0]), "oldPrice": (0, defaultBerthPrice[0]), } tankmenList.append( { "buy": True, "price": BigWorld.wg_getGoldFormat(berthPrice[0]), "actionPriceData": action, "count": berthPrice[1], } ) for tankman in sorted(tankmen, TankmenComparator(g_itemsCache.items.getVehicle)): if not tankman.isInTank: tankmenInBarracks += 1 slot, vehicleID, vehicleInnationID, vehicle = (None, None, None, None) if tankman.isInTank: vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID) vehicleID = vehicle.invID vehicleInnationID = vehicle.innationID if vehicle is None: LOG_ERROR( "Cannot find vehicle for tankman: ", tankman, tankman.descriptor.role, tankman.vehicle.name, tankman.firstname, tankman.lastname, ) continue slot = tankman.vehicleSlotIdx if ( self.filter["nation"] != -1 and tankman.nationID != self.filter["nation"] or self.filter["role"] != "None" and tankman.descriptor.role != self.filter["role"] or self.filter["tankType"] != "None" and tankman.vehicleNativeType != self.filter["tankType"] or self.filter["location"] == "tanks" and tankman.isInTank != True or self.filter["location"] == "barracks" and tankman.isInTank == True or self.filter["nationID"] is not None and ( self.filter["location"] != str(vehicleInnationID) or self.filter["nationID"] != str(tankman.nationID) ) ): continue isLocked, msg = self.getTankmanLockMessage(vehicle) if tankman.isInTank else (False, "") tankmanVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) isInCurrentTank = ( tankmanVehicle.invID == g_currentVehicle.invID if tankman.isInTank and g_currentVehicle.isPresent() else False ) tankmenList.append( { "firstname": tankman.firstUserName, "lastname": tankman.lastUserName, "rank": tankman.rankUserName, "specializationLevel": tankman.realRoleLevel[0], "role": tankman.roleUserName, "vehicleType": tankmanVehicle.shortUserName, "iconFile": tankman.icon, "rankIconFile": tankman.iconRank, "roleIconFile": Tankman.getRoleBigIconPath(tankman.descriptor.role), "contourIconFile": tankmanVehicle.iconContour, "tankmanID": tankman.invID, "nationID": tankman.nationID, "typeID": tankmanVehicle.innationID, "slot": slot, "roleType": tankman.descriptor.role, "tankType": tankmanVehicle.type, "inTank": tankman.isInTank, "inCurrentTank": isInCurrentTank, "vehicleID": vehicleID, "compact": str(tankman.invID), "locked": isLocked, "lockMessage": msg, "vehicleBroken": vehicle.repairCost > 0 if tankman.isInTank else None, "isInSelfVehicleClass": vehicle.type == tankmanVehicle.type if tankman.isInTank else True, "isInSelfVehicleType": vehicle.shortUserName == tankmanVehicle.shortUserName if tankman.isInTank else True, } ) tankmenInSlots = len(tankmenList) - 1 if tankmenInBarracks < slots: tankmenList.insert(1, {"empty": True, "freePlaces": slots - tankmenInBarracks}) self.as_setTankmenS(len(tankmen), tankmenInSlots, slots, tankmenInBarracks, tankmenList) return
def __getGoldValueWithIcon(self, gold): formattedGold = BigWorld.wg_getGoldFormat(gold) return TextManager.getText(TEXT_MANAGER_STYLES.GOLD_TEXT, formattedGold) + TextManager.getIcon(TextIcons.GOLD)
def formatDiscount(discountVal, discountType): multiplier = '+' if discountVal < 0 else '' if discountType == DISCOUNT_TYPE.GOLD: return makeHtmlString('html_templates:lobby/quests/actions', 'gold', {'value': multiplier + BigWorld.wg_getGoldFormat(abs(long(discountVal)))}) return makeHtmlString('html_templates:lobby/quests/actions', discountType, {'value': multiplier + BigWorld.wg_getIntegralFormat(abs(int(discountVal)))})
def getGoldFormat(cls, value): return BigWorld.wg_getGoldFormat(value)
def __showSuccessSysMsg(self, gold, vcoin): SystemMessages.g_instance.pushMessage(i18n.makeString('#system_messages:ebank/response/success') % {'gold': BigWorld.wg_getGoldFormat(gold), 'vcoin': BigWorld.wg_getIntegralFormat(vcoin)}, type=SystemMessages.SM_TYPE.FinancialTransactionWithGold)
def __getGoldValueWithIcon(self, gold): return ''.join( text_styles.gold(BigWorld.wg_getGoldFormat(gold)) + icons.gold())
def formatValue(self): return BigWorld.wg_getGoldFormat(self._value)
def __getDurationStr(self, period, cost, hasAction, isEnoughMoney): priceStr = '' if not hasAction: key = 'gold' if isEnoughMoney else 'goldAlert' priceStr = makeHtmlString('html_templates:lobby/dialogs/premium', key, ctx={'value': BigWorld.wg_getGoldFormat(cost)}) duration = i18n.makeString(PREMIUM_PACKET_LOCAL_KEY % period) ctx = {'duration': duration, 'price': priceStr} return makeHtmlString('html_templates:lobby/dialogs/premium', 'duration', ctx=ctx)