Exemplo n.º 1
0
def getRecoveryStatusText(restoreInfo):
    price, timeLeft = restoreInfo
    if price.credits == 0:
        restoreConfig = g_itemsCache.items.shop.tankmenRestoreConfig
        creditsDuration = restoreConfig.creditsDuration - restoreConfig.freeDuration
        text = makeString(
            TOOLTIPS.BARRACKS_TANKMEN_RECOVERY_FREE_BODY,
            totalLeftValue=formatRecoveryLeftValue(timeLeft),
            freeLeftValue=formatRecoveryLeftValue(timeLeft - creditsDuration),
            price=moneyWithIcon(restoreConfig.cost),
            withMoneyLeftValue=formatRecoveryLeftValue(creditsDuration))
    else:
        text = makeString(TOOLTIPS.BARRACKS_TANKMEN_RECOVERY_GOLD_BODY,
                          totalLeftValue=formatRecoveryLeftValue(timeLeft),
                          price=moneyWithIcon(price))
    return text_styles.main(text)
Exemplo n.º 2
0
def getRecoveryStatusText(restoreInfo):
    price, timeLeft = restoreInfo
    if not price:
        itemsCache = dependency.instance(IItemsCache)
        restoreConfig = itemsCache.items.shop.tankmenRestoreConfig
        duration = restoreConfig.billableDuration - restoreConfig.freeDuration
        text = makeString(TOOLTIPS.BARRACKS_TANKMEN_RECOVERY_FREE_BODY,
                          totalLeftValue=formatRecoveryLeftValue(timeLeft),
                          freeLeftValue=formatRecoveryLeftValue(timeLeft -
                                                                duration),
                          price=moneyWithIcon(restoreConfig.cost),
                          withMoneyLeftValue=formatRecoveryLeftValue(duration))
    else:
        text = makeString(TOOLTIPS.BARRACKS_TANKMEN_RECOVERY_GOLD_BODY,
                          totalLeftValue=formatRecoveryLeftValue(timeLeft),
                          price=moneyWithIcon(price))
    return text_styles.main(text)
Exemplo n.º 3
0
    def _getByuContentData(self, vehicle, stats, isTradeIn):
        shop = self.itemsCache.items.shop
        shopDefaults = shop.defaults
        tankMenCount = len(vehicle.crew)
        vehiclePricesActionData = self._getItemPriceActionData(vehicle)
        ammoPrice = ITEM_PRICE_EMPTY
        for shell in vehicle.gun.defaultAmmo:
            ammoPrice += shell.buyPrices.itemPrice * shell.defaultCount

        ammoActionPriceData = None
        if ammoPrice.isActionPrice():
            ammoActionPriceData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.AMMO, str(vehicle.intCD), True, ammoPrice.price, ammoPrice.defPrice)
        slotPrice = shop.getVehicleSlotsPrice(stats.vehicleSlots)
        slotDefaultPrice = shopDefaults.getVehicleSlotsPrice(stats.vehicleSlots)
        slotActionPriceData = None
        if slotPrice != slotDefaultPrice:
            slotActionPriceData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'slotsPrices', True, Money(gold=slotPrice), Money(gold=slotDefaultPrice))
        tankmenTotalLabel = i18n.makeString(DIALOGS.BUYVEHICLEWINDOW_TANKMENTOTALLABEL, count=str(tankMenCount))
        studyData = []
        for index, (tCost, defTCost, typeID) in enumerate(zip(shop.tankmanCostWithGoodyDiscount, shopDefaults.tankmanCost, ('free', 'school', 'academy'))):
            if tCost['isPremium']:
                currency = Currency.GOLD
            else:
                currency = Currency.CREDITS
            price = tCost[currency] * tankMenCount
            defPrice = defTCost[currency] * tankMenCount
            totalPrice = Money.makeFrom(currency, price)
            totalDefPrice = Money.makeFrom(currency, defPrice)
            if typeID == 'free':
                formatedPrice = i18n.makeString(MENU.TANKMANTRAININGWINDOW_FREE_PRICE)
            else:
                formatedPrice = moneyWithIcon(totalPrice, currType=currency)
            studyPriceActionData = None
            if price != defPrice:
                studyPriceActionData = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, '%sTankmanCost' % currency, True, totalPrice, totalDefPrice)
            studyData.insert(0, {'id': typeID,
             'price': price,
             'crewType': index,
             'actionPrice': studyPriceActionData,
             'label': '%d%% - %s' % (tCost['roleLevel'], formatedPrice)})

        initData = {'tankmenTotalLabel': tankmenTotalLabel,
         'vehiclePrices': self._getVehiclePrice(vehicle).toMoneyTuple(),
         'vehiclePricesActionData': vehiclePricesActionData,
         'isRentable': vehicle.isRentable,
         'rentDataDD': self._getRentData(vehicle, vehiclePricesActionData),
         'ammoPrice': ammoPrice.price.getSignValue(Currency.CREDITS),
         'ammoActionPriceData': ammoActionPriceData,
         'slotPrice': slotPrice,
         'slotActionPriceData': slotActionPriceData,
         'isStudyDisabled': vehicle.hasCrew,
         'isNoAmmo': not vehicle.hasShells,
         'studyData': studyData,
         'nation': self.nationID}
        initData.update(self._getContentFields(vehicle))
        if isTradeIn:
            initData.update(self.__getTradeInContentFields(vehicle))
        return initData
 def __setTradeOffVehicle(self, _=None):
     self.tradeInVehicleToSell = self.tradeIn.getSelectedVehicleToSell()
     tradeOffVehicleHtml = moneyWithIcon(self.tradeInVehicleToSell.tradeOffPrice, currType=Currency.GOLD)
     tradeOffVehicleStatus = i18n.makeString(DIALOGS.BUYVEHICLEWINDOW_TRADEIN_INFO_SAVING, cost=tradeOffVehicleHtml)
     tradeOffVehicleVo = makeVehicleVO(self.tradeInVehicleToSell)
     tradeOffVehicleVo['actionPrice'] = self._getItemPriceActionData(self.tradeInVehicleToSell)
     tradeOffData = {'vehicleVo': tradeOffVehicleVo,
      'price': self.tradeInVehicleToSell.tradeOffPrice.getSignValue(Currency.GOLD),
      'status': tradeOffVehicleStatus}
     self.as_updateTradeOffVehicleS(tradeOffData)
     self.as_setTradeInWarningMessagegeS(i18n.makeString(DIALOGS.TRADEINCONFIRMATION_MESSAGE, vehName=self.tradeInVehicleToSell.userName, addition=''))
Exemplo n.º 5
0
 def getDisplayableData(self, *args, **kwargs):
     vehicle = self.context.buildItem(*args, **kwargs)
     tradeInInfo = self.tradeIn.getTradeInInfo(vehicle)
     if tradeInInfo is None:
         discount = i18n.makeString(TOOLTIPS.TRADE_NODISCOUNT)
     else:
         discountValue = moneyWithIcon(tradeInInfo.maxDiscountPrice, currType=Currency.GOLD)
         if tradeInInfo.hasMultipleTradeOffs:
             discountValue = i18n.makeString(TOOLTIPS.TRADE_SEVERALDISCOUNTS, discountValue=discountValue)
         discount = i18n.makeString(TOOLTIPS.TRADE_DISCOUNT, discountValue=discountValue)
     return {'header': i18n.makeString(TOOLTIPS.TRADE_HEADER),
      'body': i18n.makeString(TOOLTIPS.TRADE_BODY, discount=discount)}
Exemplo n.º 6
0
 def getDisplayableData(self, tradeInVehicleCD, tradeOffVehicleCD):
     if tradeInVehicleCD < 0:
         return {}
     tradeInVehicle = self.context.buildItem(tradeInVehicleCD)
     itemPrice = tradeInVehicle.buyPrices.itemPrice
     bodyParts = []
     if tradeInVehicle.buyPrices.itemPrice.isActionPrice():
         bodyParts.append(i18n.makeString(TOOLTIPS.TRADE_VEHICLE_OLDPRICE, gold=moneyWithIcon(itemPrice.defPrice, currType=Currency.GOLD)))
         bodyParts.append(i18n.makeString(TOOLTIPS.TRADE_VEHICLE_NEWPRICE, gold=moneyWithIcon(itemPrice.price, currType=Currency.GOLD)))
     else:
         bodyParts.append(i18n.makeString(TOOLTIPS.TRADE_VEHICLE_PRICE, gold=moneyWithIcon(itemPrice.price, currType=Currency.GOLD)))
     if tradeOffVehicleCD < 0:
         tradeOffVehicleName = i18n.makeString(TOOLTIPS.TRADE_VEHICLE_NOVEHICLE)
         resultPrice = itemPrice.price
     else:
         tradeOffVehicle = self.context.buildItem(tradeOffVehicleCD)
         tradeOffVehicleName = tradeOffVehicle.userName
         resultPrice = itemPrice.price - tradeOffVehicle.tradeOffPrice
     bodyParts.append(i18n.makeString(TOOLTIPS.TRADE_VEHICLE_TOCHANGE, vehicleName=text_styles.playerOnline(tradeOffVehicleName)))
     return {'header': i18n.makeString(TOOLTIPS.TRADE_VEHICLE_HEADER, vehicleName=tradeInVehicle.userName),
      'body': '\n'.join(bodyParts),
      'result': i18n.makeString(TOOLTIPS.TRADE_VEHICLE_RESULT, gold=moneyWithIcon(resultPrice, currType=Currency.GOLD))}
Exemplo n.º 7
0
 def itemWrapper(self, packedItem):
     item, _, _ = packedItem
     vo = super(ShopTradeInVehicleTab, self).itemWrapper(packedItem)
     tradeInPrice = ''
     tradeInInfo = self.tradeIn.getTradeInInfo(item)
     if tradeInInfo is not None:
         tradeInPrice = moneyWithIcon(tradeInInfo.maxDiscountPrice,
                                      currType=Currency.GOLD)
         if tradeInInfo.hasMultipleTradeOffs:
             tradeInPrice = i18n.makeString(
                 MENU.SHOP_MENU_VEHICLE_TRADEINVEHICLE_PRICE,
                 discountValue=tradeInPrice)
     vo['tradeInPrice'] = tradeInPrice
     vo['isInTradeIn'] = True
     return vo
Exemplo n.º 8
0
 def packCouponData(self, itemsPack, price):
     labelWithDiscount = _ms(
         text_styles.mainBig(
             backport.text(R.strings.vehicle_preview.buyingPanel.
                           frontlinePack.couponLabel())),
         value=moneyWithIcon(getCouponDiscountForItemPack(itemsPack,
                                                          price)))
     return {
         'isSelected':
         True,
         'label':
         labelWithDiscount,
         'icon':
         backport.image(
             R.images.gui.maps.shop.rewards.c_48x48.frontline_coupon()),
         'tooltip':
         TOOLTIPS_CONSTANTS.FRONTLINE_COUPON,
         'tooltipBonusesData':
         getCouponBonusesForItemPack(itemsPack)
     }
Exemplo n.º 9
0
 def __getNoInfoData(self, totalCount=0, filteredCount=0):
     hasNoInfoData = filteredCount < 1
     noInfoData = None
     if hasNoInfoData:
         if self.filter[
                 'location'] == BARRACKS_CONSTANTS.LOCATION_FILTER_DISMISSED:
             if totalCount < 1:
                 tankmenRestoreConfig = self.itemsCache.items.shop.tankmenRestoreConfig
                 freeDays = tankmenRestoreConfig.freeDuration / time_utils.ONE_DAY
                 billableDays = tankmenRestoreConfig.billableDuration / time_utils.ONE_DAY - freeDays
                 noInfoData = {
                     'title':
                     text_styles.highTitle(
                         MENU.BARRACKS_NORECOVERYTANKMEN_TITLE),
                     'message':
                     text_styles.main(
                         _ms(MENU.BARRACKS_NORECOVERYTANKMEN_MESSAGE,
                             price=moneyWithIcon(tankmenRestoreConfig.cost),
                             totalDays=freeDays + billableDays,
                             freeDays=freeDays,
                             paidDays=billableDays))
                 }
             else:
                 noInfoData = {
                     'message':
                     text_styles.main(
                         MENU.BARRACKS_NOFILTEREDRECOVERYTANKMEN_MESSAGE)
                 }
         elif self.filter[
                 'location'] == BARRACKS_CONSTANTS.LOCATION_FILTER_NOT_RECRUITED:
             noInfoData = {
                 'title':
                 text_styles.highTitle(
                     MENU.BARRACKS_NONOTRECRUITEDTANKMEN_TITLE),
                 'message':
                 text_styles.main(
                     MENU.BARRACKS_NONOTRECRUITEDTANKMEN_MESSAGE)
             }
     return (hasNoInfoData, noInfoData)
Exemplo n.º 10
0
    def __showDismissedTankmen(self, criteria):
        tankmen = self.restore.getDismissedTankmen()
        tankmenList = list()
        for tankman in tankmen:
            if not criteria(tankman):
                continue
            skillsList = []
            for skill in tankman.skills:
                skillsList.append({'tankmanID': tankman.invID,
                 'id': str(tankman.skills.index(skill)),
                 'name': skill.userName,
                 'desc': skill.description,
                 'icon': skill.icon,
                 'level': skill.level,
                 'active': skill.isEnable and skill.isActive})

            newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
            if newSkillsCount > 0:
                skillsList.append({'buy': True,
                 'buyCount': newSkillsCount - 1,
                 'tankmanID': tankman.invID,
                 'level': lastNewSkillLvl})
            restoreInfo = getTankmenRestoreInfo(tankman)
            actionBtnTooltip = makeTooltip(TOOLTIPS.BARRACKS_TANKMEN_RECOVERYBTN_HEADER, getRecoveryStatusText(restoreInfo))
            tankmanData = _packTankmanData(tankman)
            tankmanData.update({'isRankNameVisible': False,
             'recoveryPeriodText': _makeRecoveryPeriodText(restoreInfo),
             'actionBtnLabel': MENU.BARRACKS_BTNRECOVERY,
             'actionBtnTooltip': actionBtnTooltip,
             'skills': skillsList,
             'isSkillsVisible': True})
            tankmenList.append(tankmanData)

        tankmenCountStr = _ms(MENU.BARRACKS_DISMISSEDTANKMENCOUNT, curValue=len(tankmenList), total=len(tankmen))
        placeCount = self.restore.getMaxTankmenBufferLength()
        placeCountStr = _ms(MENU.BARRACKS_RECOVERYCOUNT, total=placeCount, info=icons.info())
        noInfoData = None
        hasNoInfoData = len(tankmenList) == 0
        if hasNoInfoData:
            if len(tankmen) == 0:
                tankmenRestoreConfig = g_itemsCache.items.shop.tankmenRestoreConfig
                freeDays = tankmenRestoreConfig.freeDuration / time_utils.ONE_DAY
                creditsDays = tankmenRestoreConfig.creditsDuration / time_utils.ONE_DAY - freeDays
                noInfoData = {'title': text_styles.highTitle(MENU.BARRACKS_NORECOVERYTANKMEN_TITLE),
                 'message': text_styles.main(_ms(MENU.BARRACKS_NORECOVERYTANKMEN_MESSAGE, price=moneyWithIcon(tankmenRestoreConfig.cost), totalDays=freeDays + creditsDays, freeDays=freeDays, paidDays=creditsDays))}
            else:
                noInfoData = {'message': text_styles.main(MENU.BARRACKS_NOFILTEREDRECOVERYTANKMEN_MESSAGE)}
        placesCountTooltip = makeTooltip(TOOLTIPS.BARRACKS_PLACESCOUNT_DISMISS_HEADER, _ms(TOOLTIPS.BARRACKS_PLACESCOUNT_DISMISS_BODY, placeCount=placeCount))
        self.as_setTankmenS({'tankmenCount': text_styles.playerOnline(tankmenCountStr),
         'placesCount': text_styles.playerOnline(placeCountStr),
         'placesCountTooltip': placesCountTooltip,
         'tankmenData': tankmenList,
         'hasNoInfoData': hasNoInfoData,
         'noInfoData': noInfoData})
        return
Exemplo n.º 11
0
    def __showDismissedTankmen(self, criteria):
        tankmen = getRestoreController().getDismissedTankmen()
        tankmenList = list()
        for tankman in tankmen:
            if not criteria(tankman):
                continue
            skillsList = []
            for skill in tankman.skills:
                skillsList.append({'tankmanID': tankman.invID,
                 'id': str(tankman.skills.index(skill)),
                 'name': skill.userName,
                 'desc': skill.description,
                 'icon': skill.icon,
                 'level': skill.level,
                 'active': skill.isEnable and skill.isActive})

            newSkillsCount, lastNewSkillLvl = tankman.newSkillCount
            if newSkillsCount > 0:
                skillsList.append({'buy': True,
                 'buyCount': newSkillsCount - 1,
                 'tankmanID': tankman.invID,
                 'level': lastNewSkillLvl})
            restoreInfo = getTankmenRestoreInfo(tankman)
            actionBtnTooltip = makeTooltip(TOOLTIPS.BARRACKS_TANKMEN_RECOVERYBTN_HEADER, getRecoveryStatusText(restoreInfo))
            tankmanData = _packTankmanData(tankman)
            tankmanData.update({'isRankNameVisible': False,
             'recoveryPeriodText': _makeRecoveryPeriodText(restoreInfo),
             'actionBtnLabel': MENU.BARRACKS_BTNRECOVERY,
             'actionBtnTooltip': actionBtnTooltip,
             'skills': skillsList,
             'isSkillsVisible': True})
            tankmenList.append(tankmanData)

        tankmenCountStr = _ms(MENU.BARRACKS_DISMISSEDTANKMENCOUNT, curValue=len(tankmenList), total=len(tankmen))
        placeCount = getRestoreController().getMaxTankmenBufferLength()
        placeCountStr = _ms(MENU.BARRACKS_RECOVERYCOUNT, total=placeCount, info=icons.info())
        noInfoData = None
        hasNoInfoData = len(tankmenList) == 0
        if hasNoInfoData:
            if len(tankmen) == 0:
                tankmenRestoreConfig = g_itemsCache.items.shop.tankmenRestoreConfig
                freeDays = tankmenRestoreConfig.freeDuration / time_utils.ONE_DAY
                creditsDays = tankmenRestoreConfig.creditsDuration / time_utils.ONE_DAY - freeDays
                noInfoData = {'title': text_styles.highTitle(MENU.BARRACKS_NORECOVERYTANKMEN_TITLE),
                 'message': text_styles.main(_ms(MENU.BARRACKS_NORECOVERYTANKMEN_MESSAGE, price=moneyWithIcon(tankmenRestoreConfig.cost), totalDays=freeDays + creditsDays, freeDays=freeDays, paidDays=creditsDays))}
            else:
                noInfoData = {'message': text_styles.main(MENU.BARRACKS_NOFILTEREDRECOVERYTANKMEN_MESSAGE)}
        placesCountTooltip = makeTooltip(TOOLTIPS.BARRACKS_PLACESCOUNT_DISMISS_HEADER, _ms(TOOLTIPS.BARRACKS_PLACESCOUNT_DISMISS_BODY, placeCount=placeCount))
        self.as_setTankmenS({'tankmenCount': text_styles.playerOnline(tankmenCountStr),
         'placesCount': text_styles.playerOnline(placeCountStr),
         'placesCountTooltip': placesCountTooltip,
         'tankmenData': tankmenList,
         'hasNoInfoData': hasNoInfoData,
         'noInfoData': noInfoData})
        return
Exemplo n.º 12
0
def getRecoveryStatusText(restoreInfo):
    price, timeLeft = restoreInfo
    if price.credits == 0:
        restoreConfig = g_itemsCache.items.shop.tankmenRestoreConfig
        creditsDuration = restoreConfig.creditsDuration - restoreConfig.freeDuration
        text = makeString(TOOLTIPS.BARRACKS_TANKMEN_RECOVERY_FREE_BODY, totalLeftValue=formatRecoveryLeftValue(timeLeft), freeLeftValue=formatRecoveryLeftValue(timeLeft - creditsDuration), price=moneyWithIcon(restoreConfig.cost), withMoneyLeftValue=formatRecoveryLeftValue(creditsDuration))
    else:
        text = makeString(TOOLTIPS.BARRACKS_TANKMEN_RECOVERY_GOLD_BODY, totalLeftValue=formatRecoveryLeftValue(timeLeft), price=moneyWithIcon(price))
    return text_styles.main(text)