コード例 #1
0
    def compensation(self):
        bonuses = []
        substitutes = []
        cache = vehicles.g_cache.customization20()
        for customizationItem in self._value:
            c11nItem = self.__getC11nItem(customizationItem)
            itemType, itemId = cc.splitIntDescr(c11nItem.intCD)
            c11nComponent = cache.itemTypes[itemType][itemId]
            count = customizationItem.get('value')
            inventoryCount = c11nItem.inventoryCount
            maxNumber = c11nComponent.maxNumber
            compensationCount = count - max(0, maxNumber - inventoryCount)
            if compensationCount > 0 and maxNumber != 0:
                realCount = count - compensationCount
                if realCount > 0:
                    substituteItem = copy.deepcopy(customizationItem)
                    substituteItem['value'] = realCount
                    substitutes.append(substituteItem)
                compensation = customizationItem.get('customCompensation')
                money = Money.makeMoney(compensation)
                for currency, value in money.iteritems():
                    if value:
                        cls = _BONUSES.get(currency)
                        bonuses.append(
                            cls(currency,
                                value * compensationCount,
                                isCompensation=True))

            substitutes.append(copy.deepcopy(customizationItem))

        bonuses.insert(0, CustomizationsBonus('customizations', substitutes))
        return bonuses
コード例 #2
0
    def _getValue(self):
        self._rewardsLabels = []
        self._rewardsValues = []
        self._playerRangeIndex = -1
        achievement = self._tooltip.item
        configuration = self._tooltip.context.getParamsConfiguration(
            achievement)
        arenaType = configuration.arenaType
        rewardData = self.itemsCache.items.shop.getAchievementReward(
            achievement, arenaType)
        if not rewardData:
            return
        else:
            self._playerVehicleLevel = configuration.vehicleLevel
            baseReward = Money.makeMoney(rewardData['bonus'])
            vehLevelMultipliers = self._applyMultiplierToReward(
                baseReward, rewardData['vehicleMultipliers'])
            count = len(vehLevelMultipliers) - 1
            i = 0
            lastMulIndex = -1
            lastMulValue = None
            while i <= count:
                mulValue = vehLevelMultipliers[i]
                if lastMulIndex == -1:
                    lastMulIndex = i
                    lastMulValue = mulValue
                else:
                    isLastIndex = i == count
                    if lastMulValue != mulValue:
                        self._appendRewardsRange(
                            lastMulIndex, i - 1,
                            vehLevelMultipliers[lastMulIndex])
                        if isLastIndex:
                            self._appendRewardsRange(i, i,
                                                     vehLevelMultipliers[i])
                        else:
                            lastMulIndex = i
                            lastMulValue = mulValue
                    elif isLastIndex:
                        self._appendRewardsRange(
                            lastMulIndex, i, vehLevelMultipliers[lastMulIndex])
                i += 1

            rewardsCount = len(self._rewardsLabels)
            if rewardsCount > 0:
                headerValue = ''
                if rewardsCount == 10:
                    headerValue = self._rewardsValues[0]
                return {
                    'selectedIndex': self._playerRangeIndex,
                    'header': makeString(TOOLTIPS.ACHIEVEMENT_REWARD_HEADER),
                    'headerValue': headerValue,
                    'labels': self._rewardsLabels,
                    'values': self._rewardsValues
                }
            return
            return
コード例 #3
0
    def compensation(self, vehicle):
        bonuses = []
        if not vehicle.isPurchased:
            return bonuses
        for curVehicle, vehInfo in self.getVehicles():
            compensation = vehInfo.get('customCompensation')
            if curVehicle == vehicle and compensation:
                money = Money.makeMoney(compensation)
                for currency, value in money.iteritems():
                    if value:
                        cls = _BONUSES.get(currency)
                        bonuses.append(
                            cls(currency, value, isCompensation=True))

        return bonuses