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

            skills_count = list(tankmen.ACTIVE_SKILLS)
            availableSkillsCount = len(skills_count) - len(tankman.skills)
            hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(tankman.skills))
            self.as_setDataS({'money': items.stats.money,
             'tankman': packTankman(tankman, isCountPermanentSkills=False),
             'dropSkillsCost': dropSkillsCost,
             'hasNewSkills': hasNewSkills,
             'newSkills': tankman.newSkillCount,
             'defaultSavingMode': 0,
             'texts': self.__getTexts()})
            return
示例#2
0
 def __getInitialData(self):
     money = g_itemsCache.items.stats.money
     shop = g_itemsCache.items.shop
     upgradeParams = shop.tankmanCost
     defUpgradeParams = shop.defaults.tankmanCost
     schoolUpgradePrice = round(upgradeParams[1]['credits'])
     schoolUpgradeDefPrice = round(defUpgradeParams[1]['credits'])
     schoolUpgradeAction = None
     if schoolUpgradePrice != schoolUpgradeDefPrice:
         schoolUpgradeAction = packActionTooltipData(
             ACTION_TOOLTIPS_TYPE.ECONOMICS, 'creditsTankmanCost', True,
             Money(credits=schoolUpgradePrice),
             Money(credits=schoolUpgradeDefPrice))
     academyUpgradePrice = round(upgradeParams[2]['gold'])
     academyUpgradeDefPrice = round(defUpgradeParams[2]['gold'])
     academyUpgradeAction = None
     if academyUpgradePrice != academyUpgradeDefPrice:
         academyUpgradeAction = packActionTooltipData(
             ACTION_TOOLTIPS_TYPE.ECONOMICS, 'goldTankmanCost', True,
             Money(gold=academyUpgradePrice),
             Money(gold=academyUpgradeDefPrice))
     data = {
         'credits': money.credits,
         'gold': money.gold,
         'schoolUpgradePrice': schoolUpgradePrice,
         'schoolUpgradeActionPriceData': schoolUpgradeAction,
         'academyUpgradePrice': academyUpgradePrice,
         'academyUpgradeActionPriceData': academyUpgradeAction,
         'data': self._initData,
         'menuEnabled': self._menuEnabled
     }
     self.flashObject.as_initData(data)
     return
示例#3
0
 def _getSlotPrice(self):
     shop = self.itemsCache.items.shop
     stats = self.itemsCache.items.stats
     price = Money(gold=shop.getVehicleSlotsPrice(stats.vehicleSlots))
     defPrice = Money(
         gold=shop.defaults.getVehicleSlotsPrice(stats.vehicleSlots))
     return ItemPrice(price, defPrice)
示例#4
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     if tankman.descriptor.isFemale:
         shopPrice = items.shop.passportFemaleChangeCost
         defaultPrice = items.shop.defaults.passportFemaleChangeCost
     else:
         shopPrice = items.shop.passportChangeCost
         defaultPrice = items.shop.defaults.passportChangeCost
     action = None
     if shopPrice != defaultPrice:
         action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                        'passportChangeCost', True,
                                        Money(gold=shopPrice),
                                        Money(gold=defaultPrice))
     callback({
         'money':
         items.stats.money,
         'passportChangeCost':
         shopPrice,
         'action':
         action,
         'firstnames':
         self.__getDocGroupValues(tankman, config, 'firstNames'),
         'lastnames':
         self.__getDocGroupValues(tankman, config, 'lastNames'),
         'icons':
         self.__getDocGroupValues(tankman,
                                  config,
                                  'icons',
                                  sortNeeded=False)
     })
     return
示例#5
0
 def _getRecruitPrice(self, tmanCostTypeIdx):
     upgradeCost = self.itemsCache.items.shop.tankmanCost[tmanCostTypeIdx]
     if tmanCostTypeIdx == 1:
         return Money(credits=upgradeCost[Currency.CREDITS])
     if tmanCostTypeIdx == 2:
         return Money(gold=upgradeCost[Currency.GOLD])
     return MONEY_UNDEFINED
示例#6
0
 def __getRecruitPrice(self, tmanCostTypeIdx):
     upgradeCost = g_itemsCache.items.shop.tankmanCost[tmanCostTypeIdx]
     if tmanCostTypeIdx == 1:
         return Money(credits=upgradeCost['credits'])
     if tmanCostTypeIdx == 2:
         return Money(gold=upgradeCost['gold'])
     return ZERO_MONEY
示例#7
0
    def _successHandler(self, code, ctx=None):
        additionalMessages = []
        if len(ctx.get('shells', [])):
            totalPrice = ZERO_MONEY
            for shellCompDescr, price, count in ctx.get('shells', []):
                price = Money(*price)
                shell = g_itemsCache.items.getItemByCD(shellCompDescr)
                additionalMessages.append(
                    makeI18nSuccess('shell_buy/success',
                                    name=shell.userName,
                                    count=count,
                                    money=formatPrice(price),
                                    type=self.__getSysMsgType(price)))
                totalPrice += price

            additionalMessages.append(
                makeI18nSuccess('layout_apply/success_money_spent',
                                money=formatPrice(totalPrice),
                                type=self.__getSysMsgType(totalPrice)))
        if len(ctx.get('eqs', [])):
            for eqCompDescr, price, count in ctx.get('eqs', []):
                price = Money(*price)
                equipment = g_itemsCache.items.getItemByCD(eqCompDescr)
                additionalMessages.append(
                    makeI18nSuccess('artefact_buy/success',
                                    kind=equipment.userType,
                                    name=equipment.userName,
                                    count=count,
                                    money=formatPrice(price),
                                    type=self.__getSysMsgType(price)))

        return makeSuccess(auxData=additionalMessages)
示例#8
0
 def __getInitialData(self):
     money = self.itemsCache.items.stats.money
     shop = self.itemsCache.items.shop
     upgradeParams = shop.tankmanCost
     defUpgradeParams = shop.defaults.tankmanCost
     schoolUpgradePrice = round(upgradeParams[1]['credits'])
     schoolUpgradeDefPrice = round(defUpgradeParams[1]['credits'])
     schoolUpgradeAction = None
     if schoolUpgradePrice != schoolUpgradeDefPrice:
         schoolUpgradeAction = packActionTooltipData(
             ACTION_TOOLTIPS_TYPE.ECONOMICS, 'creditsTankmanCost', True,
             Money(credits=schoolUpgradePrice),
             Money(credits=schoolUpgradeDefPrice))
     academyUpgradePrice = round(upgradeParams[2]['gold'])
     academyUpgradeDefPrice = round(defUpgradeParams[2]['gold'])
     academyUpgradeAction = None
     if academyUpgradePrice != academyUpgradeDefPrice:
         academyUpgradeAction = packActionTooltipData(
             ACTION_TOOLTIPS_TYPE.ECONOMICS, 'goldTankmanCost', True,
             Money(gold=academyUpgradePrice),
             Money(gold=academyUpgradeDefPrice))
     data = {
         Currency.CREDITS: money.getSignValue(Currency.CREDITS),
         Currency.GOLD: money.getSignValue(Currency.GOLD),
         'schoolUpgradePrice': schoolUpgradePrice,
         'schoolUpgradeActionPriceData': schoolUpgradeAction,
         'academyUpgradePrice': academyUpgradePrice,
         'academyUpgradeActionPriceData': academyUpgradeAction,
         'data': self._initData,
         'menuEnabled': self._menuEnabled
     }
     self.as_initDataS(data)
     self.as_setRecruitButtonsEnableStateS(
         *self.__getRetrainButtonsEnableFlags())
     return
示例#9
0
    def getTankmanCostItemPrices(self):
        result = []
        defaultCost = self.defaults.tankmanCost
        countItems = len(defaultCost)
        if countItems == len(self.tankmanCostWithGoodyDiscount):
            for idx in xrange(countItems):
                commanderLevelsPrices = {}
                commanderLevelsDefPrices = {}
                for currency in Currency.ALL:
                    defPriceCurrency = defaultCost[idx].get(currency, None)
                    if defPriceCurrency:
                        commanderLevelsPrices[
                            currency] = self.tankmanCostWithGoodyDiscount[
                                idx].get(currency, None)
                        commanderLevelsDefPrices[currency] = defPriceCurrency

                price = Money(**commanderLevelsPrices)
                defPrice = Money(**commanderLevelsDefPrices)
                itemPrice = ItemPrice(price=price, defPrice=defPrice)
                result.append(itemPrice)

        else:
            _logger.error(
                'len(self.tankmanCost) must be equal to len(self.tankmanCostWithGoodyDiscount)'
            )
        return result
示例#10
0
 def _initialize(self, *args, **kwargs):
     super(BuyVehicleView, self)._initialize()
     self._blur = GUI.WGUIBackgroundBlur()
     self._blur.enable = True
     self.__addListeners()
     isElite = self.__vehicle.isElite
     vehType = self.__vehicle.type.replace('-', '_')
     isRestoreAvailable = self.__vehicle.isRestoreAvailable()
     with self.viewModel.transaction() as model:
         model.setTankType(
             '{}_elite'.format(vehType) if isElite else vehType)
         vehicleTooltip = i18n.makeString(
             getTypeUserName(self.__vehicle.type, isElite))
         noCrewLabelPath = R.strings.store.buyVehicleWindow.checkBox
         model.setVehicleNameTooltip(vehicleTooltip)
         model.setNation(nations.NAMES[self.__vehicle.nationID])
         model.setNoCrewCheckboxLabel(
             noCrewLabelPath.restore.withoutCrew
             if isRestoreAvailable else noCrewLabelPath.buy.withoutCrew)
         model.setTankLvl(int2roman(self.__vehicle.level))
         model.setTankName(self.__vehicle.shortUserName)
         model.setCountCrew(len(self.__vehicle.crew))
         model.setBuyVehicleIntCD(self.__vehicle.intCD)
         model.setIsToggleBtnVisible(self.__isTradeIn()
                                     and self.__vehicle.hasRentPackages)
         model.setIsElite(isElite)
         model.setIsRentVisible(self.__isRentVisible)
         model.setIsInBootcamp(self.__isBootcampBuyVehicle())
         model.setIsMovingTextEnabled(constants.IS_CHINA
                                      and GUI_SETTINGS.movingText.show)
         if self.__vehicle.hasCrew:
             model.setWithoutCommanderAltText(
                 R.strings.store.buyVehicleWindow.crewInVehicle)
         equipmentBlock = model.equipmentBlock
         equipmentBlock.setIsRentVisible(self.__isRentVisible)
         equipmentBlock.setTradeInIsEnabled(self.__isTradeIn())
         emtySlotAvailable = self.itemsCache.items.inventory.getFreeSlots(
             self.__stats.vehicleSlots) > 0
         equipmentBlock.setEmtySlotAvailable(emtySlotAvailable)
         equipmentBlock.setIsRestore(isRestoreAvailable)
         if self.__vehicle.hasRentPackages and not isRestoreAvailable:
             self.__selectedRentIdx = 0
             self.__selectedRentTerm = self.__vehicle.rentPackages[
                 self.__selectedRentIdx]['days']
         tankPriceArray = model.tankPrice.getItems()
         self.__addVMsInActionPriceList(tankPriceArray,
                                        self.__vehicle.buyPrices.itemPrice)
         self.__updateTankPrice()
         self.__updateCommanderCards()
         self.__updateSlotPrice()
         self.__updateAmmoPrice()
         self.__updateTradeInInfo()
         self.__updateRentInfo()
         self.__updateBuyBtnLabel()
         totalPriceArray = equipmentBlock.totalPrice.getItems()
         self.__addVMsInActionPriceList(
             totalPriceArray,
             ItemPrice(price=Money(credits=0, gold=0),
                       defPrice=Money(credits=0, gold=0)))
         self.__updateTotalPrice()
示例#11
0
 def __getAction(self, cost, defaultCost, period):
     if cost != defaultCost:
         return packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                      'premiumPacket%dCost' % period, True,
                                      Money(gold=cost),
                                      Money(gold=defaultCost))
     else:
         return None
示例#12
0
    def __getConversionPrice(self, xp):
        def computeCost(xp, rate, cost):
            return round(cost * xp / rate)

        rate, cost = self.itemsCache.items.shop.freeXPConversionWithDiscount
        defRate, defCost = self.itemsCache.items.shop.defaults.freeXPConversion
        return ItemPrice(Money(gold=computeCost(xp, rate, cost)),
                         Money(gold=computeCost(xp, defRate, defCost)))
示例#13
0
 def __getSlotPrice(self):
     if self.__frozenSlotPrice is not None:
         return self.__frozenSlotPrice
     else:
         price = self.itemsCache.items.shop.getVehicleSlotsPrice(self.itemsCache.items.stats.vehicleSlots)
         if self.__hasDiscounts:
             self.__frozenSlotPrice = Money(gold=price)
         return Money(gold=price)
示例#14
0
 def __getPriceWithDiscount(price, resourceData):
     resourceType, _, _ = resourceData
     if resourceType == GOODIE_RESOURCE_TYPE.CREDITS:
         return Money(
             credits=getPriceWithDiscount(price.credits, resourceData))
     return Money(
         gold=getPriceWithDiscount(price.gold, resourceData)
     ) if resourceType == GOODIE_RESOURCE_TYPE.GOLD else MONEY_UNDEFINED
 def tankmenRestoreConfig(self):
     config = self.__getRestoreConfig().get('tankmen', {})
     if IS_CHINA:
         duration = config.get('goldDuration', 0)
         price = Money(gold=config.get('goldCost', 0))
     else:
         duration = config.get('creditsDuration', 0)
         price = Money(credits=config.get('creditsCost', 0))
     return _TankmenRestoreConfig(config.get('freeDuration', 0), duration, price, config.get('limit', 100))
def getCouponDiscountForItemPack(itemsPack, price=maxint):
    discount = 0
    if itemsPack is None:
        return Money(gold=discount)
    else:
        for item in itemsPack:
            if item.type in ItemPackTypeGroup.DISCOUNT:
                discount += item.count

        return Money(gold=min(discount, price))
示例#17
0
 def __getPriceWithDiscount(price, resourceData):
     """
     Translates goodie value into the final price in Money
     """
     resourceType, _, _ = resourceData
     if resourceType == GOODIE_RESOURCE_TYPE.CREDITS:
         return Money(credits=getPriceWithDiscount(price.credits, resourceData))
     if resourceType == GOODIE_RESOURCE_TYPE.GOLD:
         return Money(gold=getPriceWithDiscount(price.gold, resourceData))
     return MONEY_UNDEFINED
 def _initialize(self, *args, **kwargs):
     super(BuyVehicleView, self)._initialize()
     self._blur = CachedBlur(enabled=True)
     self.__addListeners()
     isElite = self.__vehicle.isElite
     vehType = self.__vehicle.type.replace('-', '_')
     isRestore = self.__vehicle.isRestoreAvailable()
     if self.__showOnlyCongrats:
         self.viewModel.setIsContentHidden(True)
     with self.viewModel.transaction() as vm:
         vm.setIsRestore(isRestore)
         vm.setBgSource(
             R.images.gui.maps.icons.store.shop_2_background_arsenal())
         vm.setTankType('{}_elite'.format(vehType) if isElite else vehType)
         vehicleTooltip = i18n.makeString(
             getTypeUserName(self.__vehicle.type, isElite))
         noCrewLabelPath = R.strings.store.buyVehicleWindow.checkBox
         vm.setVehicleNameTooltip(vehicleTooltip)
         vm.setNation(nations.NAMES[self.__vehicle.nationID])
         vm.setNoCrewCheckboxLabel(noCrewLabelPath.restore.withoutCrew(
         ) if isRestore else noCrewLabelPath.buy.withoutCrew())
         vm.setTankLvl(int2roman(self.__vehicle.level))
         vm.setTankName(self.__vehicle.shortUserName)
         vm.setCountCrew(len(self.__vehicle.crew))
         vm.setBuyVehicleIntCD(self.__vehicle.intCD)
         vm.setIsElite(isElite)
         if self.__vehicle.hasCrew:
             vm.setWithoutCommanderAltText(
                 R.strings.store.buyVehicleWindow.crewInVehicle())
         equipmentBlock = vm.equipmentBlock
         equipmentBlock.setIsRentVisible(self.__isRentVisible)
         equipmentBlock.setTradeInIsEnabled(self.__isTradeIn())
         emtySlotAvailable = self.__itemsCache.items.inventory.getFreeSlots(
             self.__stats.vehicleSlots) > 0
         equipmentBlock.setEmtySlotAvailable(emtySlotAvailable)
         equipmentBlock.setIsRestore(isRestore)
         if self.__vehicle.hasRentPackages and (
                 not isRestore
                 or self.__actionType == VehicleBuyActionTypes.RENT
         ) and self.__actionType != VehicleBuyActionTypes.BUY:
             self.__selectedRentIdx = 0
             self.__selectedRentID = self.__vehicle.rentPackages[
                 self.__selectedRentIdx]['rentID']
         self.__updateCommanderCards()
         self.__updateSlotPrice()
         self.__updateAmmoPrice()
         self.__updateTradeInInfo()
         self.__updateRentInfo()
         self.__updateBuyBtnLabel()
         totalPriceArray = equipmentBlock.totalPrice.getItems()
         self.__addVMsInActionPriceList(
             totalPriceArray,
             ItemPrice(price=Money(credits=0, gold=0),
                       defPrice=Money(credits=0, gold=0)))
         self.__updateTotalPrice()
示例#19
0
 def getRemovalPrice(self, proxy=None):
     if not self.isRemovable and proxy is not None:
         if self.isDeluxe():
             cost = proxy.shop.paidDeluxeRemovalCost
             defaultCost = proxy.shop.defaults.paidDeluxeRemovalCost
             return ItemPrice(price=cost, defPrice=defaultCost)
         cost = proxy.shop.paidRemovalCost
         defaultCost = proxy.shop.defaults.paidRemovalCost
         return ItemPrice(price=Money(gold=cost), defPrice=Money(gold=defaultCost))
     else:
         return super(OptionalDevice, self).getRemovalPrice(proxy)
def getStylePurchaseItems(style, modifiedOutfits, c11nService=None, prolongRent=False, progressionLevel=-1):
    purchaseItems = []
    vehicle = g_currentVehicle.item
    vehicleCD = vehicle.descriptor.makeCompactDescr()
    isStyleInstalled = c11nService.getCurrentOutfit(SeasonType.SUMMER).id == style.id
    inventoryCounts = __getInventoryCounts(modifiedOutfits, vehicleCD)
    styleCount = style.fullInventoryCount(vehicle.intCD)
    isFromInventory = not prolongRent and (styleCount > 0 or isStyleInstalled)
    if style.isProgressive:
        totalPrice = ItemPrice(Money(), Money())
        currentProgressionLvl = style.getLatestOpenedProgressionLevel(vehicle)
        progressivePrice = style.getUpgradePrice(currentProgressionLvl, progressionLevel)
        if style.isProgressionPurchasable(progressionLevel):
            totalPrice = progressivePrice
        if not style.isHidden and not isFromInventory:
            totalPrice += style.getBuyPrice()
        isFromInventory = False if progressionLevel > currentProgressionLvl else isFromInventory
        purchaseItem = PurchaseItem(style, totalPrice, areaID=None, slotType=None, regionIdx=None, selected=True, group=AdditionalPurchaseGroups.STYLES_GROUP_ID, isFromInventory=isFromInventory, locked=True, progressionLevel=progressionLevel)
        purchaseItems.append(purchaseItem)
    else:
        purchaseItem = PurchaseItem(style, style.getBuyPrice(), areaID=None, slotType=None, regionIdx=None, selected=True, group=AdditionalPurchaseGroups.STYLES_GROUP_ID, isFromInventory=isFromInventory, locked=True)
        purchaseItems.append(purchaseItem)
    for season in SeasonType.COMMON_SEASONS:
        modifiedOutfit = modifiedOutfits[season]
        if style.isProgressive:
            modifiedOutfit = c11nService.removeAdditionalProgressionData(outfit=modifiedOutfit, style=style, vehCD=vehicleCD, season=season)
        baseOutfit = style.getOutfit(season, vehicleCD)
        for intCD, component, regionIdx, container, _ in modifiedOutfit.itemsFull():
            item = c11nService.getItemByCD(intCD)
            itemTypeID = item.itemTypeID
            slotType = ITEM_TYPE_TO_SLOT_TYPE.get(itemTypeID)
            if slotType is None:
                continue
            slotId = C11nId(container.getAreaID(), slotType, regionIdx)
            modifiedSlotData = SlotData(intCD, component)
            baseSlotData = getSlotDataFromSlot(baseOutfit, slotId)
            isEdited = baseSlotData.intCD != modifiedSlotData.intCD
            if isEdited:
                if slotId != correctSlot(slotId):
                    continue
                price = item.getBuyPrice()
                isFromInventory = inventoryCounts[intCD] > 0 or item.isStyleOnly
                locked = bool(style.getDependenciesIntCDs()) and itemTypeID in EDITABLE_STYLE_IRREMOVABLE_TYPES and itemTypeID != GUI_ITEM_TYPE.CAMOUFLAGE
            else:
                price = ItemPrice(Money(credits=0), Money())
                isFromInventory = True
                locked = isPurchaseItemLocked(item, style)
            purchaseItem = PurchaseItem(item, price=price, areaID=slotId.areaId, slotType=slotId.slotType, regionIdx=slotId.regionIdx, selected=True, group=season, isFromInventory=isFromInventory, component=component, locked=locked, isEdited=isEdited)
            purchaseItems.append(purchaseItem)
            inventoryCounts[intCD] -= 1

    return purchaseItems
def packDropSkill(tankman,
                  itemsCache=None,
                  goodiesCache=None,
                  lobbyContext=None):
    items = itemsCache.items
    vehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
    currentMoney = items.stats.money
    prices = items.shop.dropSkillsCost.values()
    trainingCosts = [
        Money(credits=price[Currency.CREDITS] or None,
              gold=price[Currency.GOLD] or None) for price in prices
    ]
    defaultCosts = [
        Money(credits=price[Currency.CREDITS] or None,
              gold=price[Currency.GOLD] or None)
        for price in items.shop.defaults.dropSkillsCost.itervalues()
    ]
    states = [
        cost <= currentMoney or cost.get(Currency.GOLD) is not None
        for cost in trainingCosts
    ]
    factors = [price['xpReuseFraction'] for price in prices]
    tankmanLevels = [
        math.floor(tankman.efficiencyRoleLevel * factor) for factor in factors
    ]
    result = [{
        'level':
        '{}%'.format(int(lvl)),
        'enabled':
        state,
        'price': [cost.getCurrency(),
                  cost.getSignValue(cost.getCurrency())],
        'isMoneyEnough':
        cost <= currentMoney,
        'isNativeVehicle':
        True,
        'nation':
        vehicle.nationName,
        'showAction':
        cost != defCost
    } for lvl, state, cost, defCost in zip(tankmanLevels, states,
                                           trainingCosts, defaultCosts)]
    rfo = copy.deepcopy(result[0])
    rfo['level'] = '100%'
    recertificationFormGoodie = goodiesCache.getRecertificationForm(
        currency='gold')
    rfo['enabled'] = SwitchState.ENABLED.value == lobbyContext.getServerSettings(
    ).recertificationFormState(
    ) and recertificationFormGoodie.enabled and recertificationFormGoodie.count > 0
    result.append(rfo)
    return result
示例#22
0
 def getUpgradePrice(self, proxy=None):
     if self.isUpgradable and proxy is not None:
         price = proxy.shop.getOperationPrices().get(
             ITEM_OPERATION.UPGRADE, {}).get(
                 (self.intCD,
                  self.descriptor.upgradeInfo.upgradedCompDescr), None)
         defaultPrice = proxy.shop.defaults.getOperationPrices().get(
             ITEM_OPERATION.UPGRADE, {}).get(
                 (self.intCD,
                  self.descriptor.upgradeInfo.upgradedCompDescr), None)
         return ItemPrice(price=Money(**price),
                          defPrice=Money(**defaultPrice))
     else:
         return ITEM_PRICE_EMPTY
示例#23
0
 def __init__(self,
              vehicle,
              item,
              slotIdx,
              install=True,
              isUseGold=False,
              conflictedEqs=None):
     """
     Ctor.
     
     @param vehicle: vehicle
     @param item: module to install
     @param slotIdx: vehicle equipment slot index to install
     @param install: flag to designated process
     @param conflictedEqs: conflicted items
     """
     super(OptDeviceInstaller,
           self).__init__(vehicle, item, (GUI_ITEM_TYPE.OPTIONALDEVICE, ),
                          slotIdx, install, conflictedEqs)
     self.cost = g_itemsCache.items.shop.paidRemovalCost
     defaultCost = g_itemsCache.items.shop.defaults.paidRemovalCost
     action = None
     if self.cost != defaultCost:
         action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                        'paidRemovalCost', True,
                                        Money(gold=self.cost),
                                        Money(gold=defaultCost))
     addPlugins = []
     if install:
         addPlugins += (plugins.MessageConfirmator(
             'installConfirmationNotRemovable',
             ctx={'name': item.userName},
             isEnabled=not item.isRemovable), )
     else:
         addPlugins += (plugins.DemountDeviceConfirmator(
             'removeConfirmationNotRemovableGold',
             ctx={
                 'name': item.userName,
                 'price': self.cost,
                 'action': action
             },
             isEnabled=not item.isRemovable and isUseGold),
                        plugins.DestroyDeviceConfirmator(
                            'removeConfirmationNotRemovable',
                            itemName=item.userName,
                            isEnabled=not item.isRemovable
                            and not isUseGold))
     self.addPlugins(addPlugins)
     self.useGold = isUseGold
     return
示例#24
0
 def _buildSupplyItems(self):
     self._supplyItems = []
     items = self._itemsCache.items
     slots = items.stats.vehicleSlots
     vehicles = self.getTotalVehiclesCount()
     slotPrice = items.shop.getVehicleSlotsPrice(slots)
     defaultSlotPrice = items.shop.defaults.getVehicleSlotsPrice(slots)
     if slotPrice != defaultSlotPrice:
         discount = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                          'slotsPrices', True,
                                          Money(gold=slotPrice),
                                          Money(gold=defaultSlotPrice))
     else:
         discount = None
     self._emptySlotsCount = slots - vehicles
     smallBuySlotString, buySlotString = getStatusStrings('buySlot')
     smallBuyTankString, buyTankString = getStatusStrings('buyTank')
     smallEmptySlotsString, emptySlotsString = getStatusStrings(
         'buyTankEmptyCount',
         style=text_styles.main,
         ctx={'count': self._emptySlotsCount})
     self._supplyItems.append({
         'buyTank':
         True,
         'smallInfoText':
         text_styles.concatStylesToMultiLine(smallBuyTankString,
                                             smallEmptySlotsString),
         'infoText':
         text_styles.concatStylesToMultiLine(buyTankString,
                                             emptySlotsString),
         'icon':
         RES_ICONS.MAPS_ICONS_LIBRARY_TANKITEM_BUY_TANK,
         'tooltip':
         TOOLTIPS.TANKS_CAROUSEL_BUY_VEHICLE_NEW
         if isIngameShopEnabled() else TOOLTIPS.TANKS_CAROUSEL_BUY_VEHICLE
     })
     buySlotVO = {
         'buySlot': True,
         'slotPrice': slotPrice,
         'icon': RES_ICONS.MAPS_ICONS_LIBRARY_TANKITEM_BUY_SLOT,
         'infoText': buySlotString,
         'smallInfoText': smallBuySlotString,
         'hasSale': discount is not None,
         'tooltip': TOOLTIPS.TANKS_CAROUSEL_BUY_SLOT
     }
     if discount is not None:
         buySlotVO.update({'slotPriceActionData': discount})
     self._supplyItems.append(buySlotVO)
     return
    def __setRepairPrice(self):
        vehicle = g_currentVehicle.item
        if isIncorrectVehicle(vehicle):
            return
        items = self.viewModel.repairPrice.getItems()
        items.clear()
        repairCost = vehicle.repairCost
        itemPrice = ItemPrice(price=Money(credits=repairCost),
                              defPrice=Money(credits=repairCost))
        actionPriceModels = getItemPricesViewModel(
            self.__itemsCache.items.stats.money, itemPrice)[0]
        for model in actionPriceModels:
            items.addViewModel(model)

        items.invalidate()
示例#26
0
 def tankmenRestoreConfig(self):
     config = self.__getRestoreConfig().get('tankmen', {})
     return _TankmenRestoreConfig(
         config.get('freeDuration', 0), config.get('creditsDuration', 0),
         config.get('goldDuration', 0),
         Money(credits=config.get('creditsCost', 0)),
         config.get('limit', 100))
 def _successHandler(self, code, ctx=None):
     msgType = self.__getTankmanSysMsgType(self.dropSkillCostIdx)
     price = self.itemsCache.items.shop.dropSkillsCost.get(
         self.dropSkillCostIdx)
     return makeI18nSuccess('drop_tankman_skill/success',
                            money=formatPrice(Money(**price)),
                            type=msgType)
示例#28
0
 def _successHandler(self, code, ctx=None):
     msgType = SM_TYPE.FinancialTransactionWithGold
     vehicle = self.itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     additionalMsgs = []
     if self.__compensationRequired:
         additionalMsgs.append(
             makeCrewSkinCompensationMessage(
                 self.__compensationPriceObject))
     if ctx == EQUIP_TMAN_CODE.OK:
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/installed',
                             vehicle=vehicle.shortUserName))
     elif ctx == EQUIP_TMAN_CODE.NO_FREE_SLOT:
         roleStr = Tankman.getRoleUserName(SKILL_NAMES[self.__roleIdx])
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/slot_is_taken',
                             vehicle=vehicle.shortUserName,
                             role=roleStr))
     else:
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/no_vehicle'))
     return makeI18nSuccess('change_tankman_role/success',
                            money=formatPrice(
                                Money(gold=self.__changeRoleCost)),
                            type=msgType,
                            auxData=additionalMsgs)
示例#29
0
    def changeRetrainType(self, operationId):
        operationId = int(operationId)
        items = g_itemsCache.items
        vehicle = g_currentVehicle.item
        shopPrices = items.shop.tankmanCost
        currentSelection = shopPrices[operationId]
        crewInfo = []
        for idx, tMan in vehicle.crew:
            if tMan is not None:
                if tMan.vehicleNativeDescr.type.compactDescr != tMan.vehicleDescr.type.compactDescr:
                    crewInfo.append(self.__getTankmanRoleInfo(tMan))
                elif tMan.roleLevel != tankmen.MAX_SKILL_LEVEL and tMan.efficiencyRoleLevel < currentSelection[
                        'roleLevel']:
                    crewInfo.append(self.__getTankmanRoleInfo(tMan))

        crewSize = len(crewInfo)
        price = crewSize * Money(**currentSelection)
        self.as_setCrewDataS({
            'price':
            price,
            'crew':
            crewInfo,
            'crewMembersText':
            text_styles.concatStylesWithSpace(
                _ms(RETRAIN_CREW.LABEL_CREWMEMBERS),
                text_styles.middleTitle(crewSize))
        })
        return
示例#30
0
def getTotalPurchaseInfo(purchaseItems):
    totalPrice = ITEM_PRICE_EMPTY
    numSelectedItems = 0
    numApplyingItems = 0
    isAtLeastOneItemFromInventory = False
    isAtLeastOneItemDismantled = False
    minPriceItem = Money()
    for purchaseItem in purchaseItems:
        if not purchaseItem.isDismantling:
            numApplyingItems += 1
        else:
            isAtLeastOneItemDismantled = True
        if purchaseItem.selected and not purchaseItem.isDismantling:
            numSelectedItems += 1
            if not purchaseItem.isFromInventory:
                totalPrice += purchaseItem.price
                if not minPriceItem.isDefined(
                ) or purchaseItem.price.price < minPriceItem:
                    minPriceItem = purchaseItem.price.price
            else:
                isAtLeastOneItemFromInventory = True

    return CartInfo(totalPrice, numSelectedItems, numApplyingItems,
                    len(purchaseItems), minPriceItem,
                    isAtLeastOneItemFromInventory, isAtLeastOneItemDismantled)