def hideInvisible(cls, bonuses, needSplit=False):
     if needSplit:
         bonuses = mergeBonuses(bonuses)
         bonuses = splitBonuses(bonuses)
     bonuses = list(
         filter(cls.__bonusesLayoutController.getIsVisible, bonuses))
     return bonuses
 def _getAwards(self, bonuses):
     return [{
         'icon': award['imgSource'],
         'value': award['label'],
         'tooltip': award.get('tooltip', None),
         'specialAlias': award.get('specialAlias', None),
         'specialArgs': award.get('specialArgs', None)
     } for award in getLinkedSetBonuses(mergeBonuses(bonuses)) if award]
def composeBonuses(rewards, ctx=None):
    bonuses = []
    for reward in rewards:
        for key, value in reward.iteritems():
            bonuses.extend(getNonQuestBonuses(key, value, ctx))

    bonuses = mergeBonuses(bonuses)
    bonuses = splitBonuses(bonuses)
    return bonuses
示例#4
0
 def getAwards(self, bonuses, isCompleted, alpha=1.0):
     return [{
         'icon': award['imgSource'],
         'value': award['label'],
         'isCompleted': isCompleted,
         'tooltip': award.get('tooltip', None),
         'specialAlias': award.get('specialAlias', None),
         'specialArgs': award.get('specialArgs', None),
         'alpha': alpha
     } for award in getLinkedSetBonuses(mergeBonuses(bonuses)) if award]
示例#5
0
 def __getBonuses(self, level):
     questsProgressData = self.__ctx[
         'reusableInfo'].personal.getQuestsProgress()
     bonuses = after_battle_reward_view_helpers.getQuestBonuses(
         questsProgressData,
         (self.__battleRoyaleController.TOKEN_QUEST_ID, ),
         self.__battleRoyaleController.TOKEN_QUEST_ID + str(level))
     bonuses = mergeBonuses(bonuses)
     bonuses = splitBonuses(bonuses)
     return bonuses
示例#6
0
    def _getRemainingRewards(self):
        finished, _ = self.getMarathonProgress()
        rewardsQuests = self._getQuestsWithRewards()
        remainingQuests = rewardsQuests[finished:]
        hiddenQuests = self._eventsCache.getHiddenQuests()
        bonuses = []
        for questID in remainingQuests:
            quest = hiddenQuests.get(questID)
            bonuses.extend(quest.getBonuses())

        merged = mergeBonuses(bonuses)
        return merged
示例#7
0
 def __setBonuses(self, model):
     questsBonuses = self.__data[BRSections.PERSONAL][
         BRSections.REWARDS].get(BRSections.BONUSES, [])
     if not questsBonuses:
         return
     bonusesModel = model.getBonuses()
     bonusesModel.clear()
     bonuses = [
         bonus for questBonuses in questsBonuses for bonus in questBonuses
     ]
     bonuses = [
         bonus for bonus in mergeBonuses(bonuses)
         if bonus.getName() not in _CURRENCIES
     ]
     bonuses = splitBonuses(bonuses)
     packBonusModelAndTooltipData(bonuses,
                                  bonusesModel,
                                  tooltipData=self.__tooltipsData)
     bonusesModel.invalidate()
    def getWholeBonusesData(self, invoiceData, productCode, callback=None):
        yield lambda callback: callback(True)
        metaData = invoiceData.get('meta', {})
        if productCode:
            purchasePackage = yield self.__purchaseCache.requestPurchaseByID(productCode)
            bonusData = deepcopy(invoiceData['data'])
            compensation = invoiceData.get('compensation', {})
            _addCompensation(compensation, bonusData)
            sortedBList = _OrderHelper.buildSortedBonusList(bonusData, metaData.get('order', EMPTY_TUPLE), purchasePackage.getEntitlements())
            self.__extendSortedBonusList(sortedBList, purchasePackage.getExtraData())
            bonuses = []
            for bData in sortedBList:
                bonuses.extend(awardsFactory(bData))

            bonuses = mergeBonuses(bonuses)
            if self.__prefetchEssentialData(bonuses, productCode):
                viewRewards, tooltipItems = yield packBonusModelAndTooltipData(bonuses, productCode)
                if viewRewards:
                    callback((viewRewards, tooltipItems))
                    return
        callback((EMPTY_TUPLE, EMPTY_TUPLE))
示例#9
0
    def __getBonuses(self, prevLevel, currentLevel):
        questsProgressData = self.__ctx[
            'reusableInfo'].personal.getQuestsProgress()
        if currentLevel == self.__epicController.getMaxPlayerLevel():
            bonuses = getFinishBadgeBonuses(
                questsProgressData, self.__epicController.FINAL_BADGE_QUEST_ID)
        else:
            bonuses = []
        bonuses.extend(
            getQuestBonuses(
                questsProgressData, (self.__epicController.TOKEN_QUEST_ID, ),
                self.__epicController.TOKEN_QUEST_ID + str(currentLevel)))
        if self.__battlePass.getCurrentLevel(
        ) == self.__battlePass.getMaxLevel():
            excluded = [BattleRewardItemModel.BATTLE_PASS_POINTS]
            bonuses = [b for b in bonuses if b.getName() not in excluded]
        for level in range(prevLevel + 1, currentLevel + 1):
            bonuses.extend(self.__getAbilityPointsRewardBonus(level))

        bonuses = mergeBonuses(bonuses)
        bonuses = splitBonuses(bonuses)
        return bonuses
示例#10
0
 def _populate(self):
     super(EpicBattlesAfterBattleView, self)._populate()
     levelUpInfo = self.__ctx['levelUpInfo']
     pMetaLevel, pFamePts = levelUpInfo.get('metaLevel', (None, None))
     prevPMetaLevel, prevPFamePts = levelUpInfo.get('prevMetaLevel',
                                                    (None, None))
     boosterFLXP = levelUpInfo.get('boosterFlXP', 0)
     originalFlXP = levelUpInfo.get('originalFlXP', 0)
     maxMetaLevel = self.__epicController.getMaxPlayerLevel()
     famePtsToProgress = self.__epicController.getLevelProgress()
     season = self.__epicController.getCurrentSeason() or None
     cycleNumber = 0
     if season is not None:
         cycleNumber = self.__epicController.getCurrentOrNextActiveCycleNumber(
             season)
     famePointsReceived = sum(famePtsToProgress[prevPMetaLevel:pMetaLevel]
                              ) + pFamePts - prevPFamePts
     achievedRank = max(levelUpInfo.get('playerRank', 0), 1)
     rankNameId = R.strings.epic_battle.rank.dyn('rank' + str(achievedRank))
     rankName = toUpper(backport.text(
         rankNameId())) if rankNameId.exists() else ''
     bonuses = sorted(mergeBonuses(
         self.__getBonuses(prevPMetaLevel, pMetaLevel)),
                      key=lambda item: self._BONUS_ORDER_PRIORITY.get(
                          item.getName(), self._MIDDLE_PRIORITY))
     awardsVO = self.__markAnimationBonuses(
         self._awardsFormatter.getFormattedBonuses(bonuses,
                                                   size=AWARDS_SIZES.BIG))
     fameBarVisible = True
     dailyQuestAvailable = False
     if prevPMetaLevel >= maxMetaLevel or pMetaLevel >= maxMetaLevel:
         boosterFLXP = famePointsReceived - originalFlXP if famePointsReceived > originalFlXP else 0
         if prevPMetaLevel >= maxMetaLevel:
             fameBarVisible = False
         else:
             self.__maxLvlReached = True
     lvlReachedText = toUpper(
         backport.text(R.strings.epic_battle.epic_battles_after_battle.
                       Level_Up_Title(),
                       level=pMetaLevel))
     data = {
         'awards':
         awardsVO,
         'progress':
         self.__getProgress(pMetaLevel, pFamePts, prevPMetaLevel,
                            prevPFamePts, maxMetaLevel, boosterFLXP),
         'barText':
         '+' + str(min(originalFlXP, famePointsReceived)),
         'barBoostText':
         '+' + str(boosterFLXP),
         'epicMetaLevelIconData':
         getProgressionIconVODict(cycleNumber, pMetaLevel),
         'rank':
         achievedRank,
         'rankText':
         text_styles.epicTitle(rankName),
         'rankSubText':
         text_styles.promoTitle(
             backport.text(R.strings.epic_battle.epic_battles_after_battle.
                           Achieved_Rank())),
         'levelUpText':
         text_styles.heroTitle(lvlReachedText),
         'backgroundImageSrc':
         backport.image(R.images.gui.maps.icons.epicBattles.backgrounds.
                        back_congrats()),
         'fameBarVisible':
         fameBarVisible,
         'maxLevel':
         maxMetaLevel,
         'maxLvlReached':
         self.__maxLvlReached,
         'questPanelVisible':
         dailyQuestAvailable,
         'isRewardsButtonShown':
         self.__epicController.hasAnyOfferGiftToken()
         and self.__hasSelectBonus(bonuses)
     }
     self.as_setDataS(data)
     return
 def sortBonuses(cls, bonuses):
     bonuses = mergeBonuses(bonuses)
     bonuses = splitBonuses(bonuses)
     bonuses.sort(key=cls.__bonusesLayoutController.getPriority,
                  reverse=True)
     return bonuses