def __setAwards(self, bonuses, isFinalReward):
     rewards = BattlePassAwardsManager.composeBonuses(bonuses)
     rewards = BattlePassAwardsManager.sortBonuses(
         BattlePassAwardsManager.uniteTokenBonuses(rewards))
     if not rewards:
         return
     mainRewards = self.__setMainRewards(rewards,
                                         isFinalReward=isFinalReward)
     rewards = [reward for reward in rewards if reward not in mainRewards]
     packBonusModelAndTooltipData(rewards, self.viewModel.additionalRewards,
                                  self.__tooltipItems)
Пример #2
0
 def getNowAwards(self):
     curLevel = self._getBPCurrentLevel()
     toLevel = curLevel + self.getLevelsCount()
     bonuses = []
     if self.getLevelsCount():
         bonuses.extend(
             self._battlePassController.getPackedAwardsInterval(
                 curLevel + 1,
                 toLevel,
                 awardType=BattlePassConsts.REWARD_BOTH))
     bonuses = BattlePassAwardsManager.uniteTokenBonuses(bonuses)
     return BattlePassAwardsManager.sortBonuses(bonuses)
Пример #3
0
 def getFutureAwards(self):
     bonuses = []
     if self.hasBattlePass():
         fromLevel = self._getBPCurrentLevel() + self.getLevelsCount()
         bonuses.extend(
             self._battlePassController.getPackedAwardsInterval(
                 fromLevel + 1,
                 self._battlePassController.getChapterLevelInterval(
                     self.__chapter)[1],
                 awardType=BattlePassConsts.REWARD_PAID))
     bonuses = BattlePassAwardsManager.uniteTokenBonuses(bonuses)
     return BattlePassAwardsManager.sortBonuses(bonuses)
Пример #4
0
 def getSingleAward(self, chapterId, level, awardType=BattlePassConsts.REWARD_FREE, needSort=True):
     reward = {}
     if awardType in (BattlePassConsts.REWARD_FREE, BattlePassConsts.REWARD_PAID):
         reward = self.__getConfig().getRewardByType(chapterId, level, awardType)
     elif awardType == BattlePassConsts.REWARD_BOTH:
         rewards = [self.__getConfig().getFreeReward(chapterId, level), self.__getConfig().getPaidReward(chapterId, level)]
         return BattlePassAwardsManager.hideInvisible(BattlePassAwardsManager.composeBonuses(rewards))
     if needSort:
         rewards = BattlePassAwardsManager.composeBonuses([reward])
     else:
         rewards = awardsFactory(reward)
     return BattlePassAwardsManager.hideInvisible(rewards, needSplit=not needSort)
Пример #5
0
 def getNowAwards(self):
     fromLevel, maxLevelInChapter = self._battlePassController.getChapterLevelInterval(
         self.__chapter)
     curLevel = min(maxLevelInChapter, self._getBPCurrentLevel())
     bonuses = []
     if self.hasBattlePass():
         bonuses.extend(
             self._battlePassController.getPackedAwardsInterval(
                 fromLevel,
                 curLevel,
                 awardType=BattlePassConsts.REWARD_PAID))
     bonuses = BattlePassAwardsManager.uniteTokenBonuses(bonuses)
     return BattlePassAwardsManager.sortBonuses(bonuses)
Пример #6
0
 def getFutureAwards(self):
     bonuses = []
     if self.hasBattlePass():
         fromLevel = self.getCurrentLevel() + 1
         toLevel = self._getMaxLevel()
         bonuses.extend(
             self._battlePassController.getPackedAwardsInterval(
                 self.__chapterID,
                 fromLevel,
                 toLevel,
                 awardType=BattlePassConsts.REWARD_PAID))
     bonuses = BattlePassAwardsManager.uniteTokenBonuses(bonuses)
     return BattlePassAwardsManager.sortBonuses(bonuses)
Пример #7
0
    def getPackedAwardsInterval(self,
                                fromLevel,
                                toLevel,
                                awardType=BattlePassConsts.REWARD_FREE):
        result = []
        for level in range(fromLevel, toLevel + 1):
            result.extend(self.getSingleAward(level, awardType, False))

        return BattlePassAwardsManager.sortBonuses(result)
Пример #8
0
    def __checkIfRewardIsToken(bonusName, reward):
        if 'tokens' not in reward:
            return False
        bonuses = BattlePassAwardsManager.composeBonuses([reward])
        for bonus in bonuses:
            if bonus.getName() == bonusName:
                return True

        return False
Пример #9
0
 def getNowAwards(self):
     curLevel = self._getBPCurrentLevel()
     bonuses = []
     if self.hasBattlePass():
         bonuses.extend(
             self._battlePassController.getPackedAwardsInterval(
                 1, curLevel, awardType=BattlePassConsts.REWARD_PAID))
         if not isCurrentBattlePassStateBase():
             _, paidBonuses = self._battlePassController.getSplitFinalAwards(
             )
             bonuses.extend(paidBonuses)
     return BattlePassAwardsManager.sortBonuses(bonuses)
    def __processRewardIsBadge(self, reward):
        if 'dossier' not in reward:
            return False
        bonuses = BattlePassAwardsManager.composeBonuses([reward])
        for bonus in bonuses:
            if bonus.getName() != 'dossier':
                continue
            if bonus.getBadges():
                self.__badge = bonus
                return True

        return False
    def getFinalAwardsForPurchaseLevels(self):
        awards = []
        awardsSettings = sorted(self.getFinalRewards().iteritems(),
                                key=itemgetter(0))
        configs = [config for _, config in awardsSettings]
        if len(configs) != 2:
            return awards
        awards.extend(
            BattlePassAwardsManager.composeBonuses(
                [configs[0].get('shared', {})]))
        awards.extend(
            BattlePassAwardsManager.composeBonuses(
                [configs[1].get('shared', {})]))
        uniqueA = BattlePassAwardsManager.composeBonuses(
            [configs[0].get('unique', {})])
        uniqueB = BattlePassAwardsManager.composeBonuses(
            [configs[1].get('unique', {})])
        for optionA, optionB in zip(uniqueA, uniqueB):
            bonus = makeUndefinedBonus(optionA, optionB)
            awards.append(bonus)

        return awards
Пример #12
0
 def getFutureAwards(self):
     bonuses = []
     if self.hasBattlePass():
         fromLevel = self._getBPCurrentLevel() + self.getLevelsCount()
         bonuses.extend(
             self._battlePassController.getPackedAwardsInterval(
                 fromLevel + 1,
                 self._battlePassController.getMaxLevel(),
                 awardType=BattlePassConsts.REWARD_PAID))
         if isCurrentBattlePassStateBase():
             _, paidBonuses = self._battlePassController.getSplitFinalAwards(
             )
             bonuses.extend(paidBonuses)
     return BattlePassAwardsManager.sortBonuses(bonuses)
Пример #13
0
 def getNowAwards(self):
     curLevel = self._getBPCurrentLevel()
     toLevel = curLevel + self.getLevelsCount()
     bonuses = []
     if self.getLevelsCount():
         bonuses.extend(
             self._battlePassController.getPackedAwardsInterval(
                 curLevel + 1,
                 toLevel,
                 awardType=BattlePassConsts.REWARD_BOTH))
         if toLevel == self._battlePassController.getMaxLevel():
             bonuses.extend(self._battlePassController.
                            getFinalAwardsForPurchaseLevels())
     return BattlePassAwardsManager.sortBonuses(bonuses)
Пример #14
0
 def __setAwards(self, bonuses, isPremiumPurchase, isFinalReward,
                 isPostProgression):
     rewards = BattlePassAwardsManager.composeBonuses(bonuses)
     if not rewards:
         return
     if isFinalReward:
         if self.__battlePassController.isBought():
             chosenRewards = [rewards[0], rewards[2]]
             boughtRewards = [rewards[1]]
             with finalAwardsInjection(self.__battlePassController.
                                       getAlternativeVoteOption()):
                 packBonusModelAndTooltipData(boughtRewards,
                                              self.viewModel.mainRewards,
                                              self.__tooltipItems)
             with finalAwardsInjection(
                     self.__battlePassController.getVoteOption()):
                 packBonusModelAndTooltipData(chosenRewards,
                                              self.viewModel.mainRewards,
                                              self.__tooltipItems)
             rewards = rewards[3:]
         else:
             with finalAwardsInjection(
                     self.__battlePassController.getVoteOption()):
                 packBonusModelAndTooltipData([rewards.pop(1)],
                                              self.viewModel.mainRewards,
                                              self.__tooltipItems)
                 packBonusModelAndTooltipData(rewards[:2],
                                              self.viewModel.mainRewards,
                                              self.__tooltipItems)
             rewards = rewards[2:]
     elif not isPremiumPurchase:
         if not isPostProgression or rewards[0].getName(
         ) == 'customizations':
             reward = rewards.pop(0)
             value = reward.getValue()
             if reward.getName() == 'customizations' and value[0][
                     'custType'] == 'projection_decal':
                 with finalAwardsInjection(value[0]['id']):
                     packBonusModelAndTooltipData(
                         [reward], self.viewModel.mainRewards,
                         self.__tooltipItems)
             else:
                 packBonusModelAndTooltipData([reward],
                                              self.viewModel.mainRewards,
                                              self.__tooltipItems)
     packBonusModelAndTooltipData(rewards, self.viewModel.additionalRewards,
                                  self.__tooltipItems)
    def getSplitFinalAwards(self):
        freeReward = []
        paidReward = []
        awardsSettings = sorted(self.getFinalRewards().iteritems(),
                                key=itemgetter(0))
        voteOption = self.getVoteOption()
        if voteOption != 0:
            for vote, config in awardsSettings:
                shared = BattlePassAwardsManager.composeBonuses(
                    [config.get('shared', {})])
                if vote == voteOption:
                    unique = BattlePassAwardsManager.composeBonuses(
                        [config.get('unique', {})])
                    freeReward.extend(shared)
                    freeReward.extend(unique)
                paidReward.extend(shared)

        else:
            configs = [config for _, config in awardsSettings]
            if len(configs) != 2:
                return (freeReward, paidReward)
            sharedA = BattlePassAwardsManager.composeBonuses(
                [configs[0].get('shared', {})])
            sharedB = BattlePassAwardsManager.composeBonuses(
                [configs[1].get('shared', {})])
            uniqueA = BattlePassAwardsManager.composeBonuses(
                [configs[0].get('unique', {})])
            uniqueB = BattlePassAwardsManager.composeBonuses(
                [configs[1].get('unique', {})])
            for optionA, optionB in zip(sharedA, sharedB):
                bonus = makeUndefinedBonus(optionA, optionB)
                freeReward.append(bonus)
                paidReward.append(bonus)

        for optionA, optionB in zip(uniqueA, uniqueB):
            bonus = makeUndefinedBonus(optionA, optionB)
            freeReward.append(bonus)

        return (freeReward, paidReward)
Пример #16
0
 def init(self):
     super(BattlePassController, self).init()
     g_playerEvents.onClientUpdated += self.__onTokensUpdate
     self.__rewardLogic = BattlePassRewardLogic(BattlePassStateMachine())
     BattlePassAwardsManager.init()
 def init(self):
     super(BattlePassController, self).init()
     g_clientUpdateManager.addCallbacks({'tokens': self.__onTokensUpdate})
     BattlePassAwardsManager.init()
 def __getRewardWeight(bonus):
     return REWARD_SIZES.get(BattlePassAwardsManager.getBigIcon(bonus), 0)
Пример #19
0
 def getStylesConfig(self):
     rewards = self.__getConfig().selectedReward
     return BattlePassAwardsManager.composeBonuses([
         rewards
     ]) if rewards else BattlePassAwardsManager.composeBonuses([])
Пример #20
0
 def init(self):
     super(BattlePassController, self).init()
     g_clientUpdateManager.addCallbacks({'tokens': self.__onTokensUpdate})
     self.__rewardLogic = BattlePassRewardLogic(BattlePassStateMachine())
     BattlePassAwardsManager.init()