예제 #1
0
 def __updateBuyButtonState(self):
     currentLevel = self.__battlePassController.getCurrentLevel()
     isBattlePassBought = self.__battlePassController.isBought(
         chapter=self.__chosenChapter)
     minLevel, maxLevel = self.__battlePassController.getChapterLevelInterval(
         self.__chosenChapter)
     allLevelsComplete = maxLevel <= currentLevel or self.__battlePassController.getState(
     ) == BattlePassState.COMPLETED
     isVisible = not (isBattlePassBought and allLevelsComplete)
     if not isVisible:
         with self.viewModel.transaction() as model:
             model.setIsVisibleBuyButton(isVisible)
         return
     seasonTimeLeft = ''
     if minLevel > currentLevel + 1:
         if not isBattlePassBought:
             state = self.viewModel.buyButton.DISABLE_BP
         else:
             state = self.viewModel.buyButton.DISABLE_LEVELS
     elif not isBattlePassBought:
         state = self.viewModel.buyButton.BUY_BP
     else:
         state = self.viewModel.buyButton.BUY_LEVELS
     showBubble = not self.__isBuyButtonHintShown()
     isHighlightOn = isSeasonEndingSoon()
     if isHighlightOn:
         seasonTimeLeft = getFormattedTimeLeft(
             self.__battlePassController.getSeasonTimeLeft())
     with self.viewModel.transaction() as model:
         model.setIsVisibleBuyButton(isVisible)
         buyButtonModel = model.buyButton
         buyButtonModel.setState(state)
         buyButtonModel.setIsHighlightOn(isHighlightOn)
         buyButtonModel.setSeasonTimeLeft(seasonTimeLeft)
         buyButtonModel.setShowBuyButtonBubble(showBubble)
    def _onLoading(self, *args, **kwargs):
        super(BattlePassInProgressTooltipView,
              self)._onLoading(*args, **kwargs)
        prbDispatcher = g_prbLoader.getDispatcher()
        if prbDispatcher is None:
            return
        else:
            battleType = self.__battleType or prbDispatcher.getEntity(
            ).getQueueType()
            with self.getViewModel().transaction() as model:
                if self.__battleRoyaleController.isBattleRoyaleMode():
                    self.__updateBattleRoyalePoints(model)
                else:
                    items = model.rewardPoints.getItems()
                    arenaBonusType = getSupportedCurrentArenaBonusType(
                        battleType)
                    for points in self.__battlePass.getPerBattlePoints(
                            gameMode=arenaBonusType):
                        item = RewardPointsModel()
                        item.setTopCount(points.label)
                        item.setPointsWin(points.winPoint)
                        item.setPointsLose(points.losePoint)
                        items.addViewModel(item)

                curLevel = self.__battlePass.getCurrentLevel()
                chapterID = self.__battlePass.getCurrentChapterID()
                curPoints, limitPoints = self.__battlePass.getLevelProgression(
                    chapterID)
                isBattlePassPurchased = self.__battlePass.isBought(
                    chapterID=chapterID)
                model.setLevel(curLevel)
                model.setChapter(chapterID)
                model.setCurrentPoints(curPoints)
                model.setMaxPoints(limitPoints)
                model.setIsBattlePassPurchased(isBattlePassPurchased)
                model.setBattleType(getPreQueueName(battleType).lower())
                model.setNotChosenRewardCount(
                    self.__battlePass.getNotChosenRewardCount())
                model.setExpireTime(
                    self.__battlePass.getChapterRemainingTime(chapterID))
                model.setIsExtra(self.__battlePass.isExtraChapter(chapterID))
                model.setFinalReward(
                    self.__battlePass.getRewardType(chapterID).value)
                timeTillEnd = ''
                if isSeasonEndingSoon() and not isBattlePassPurchased:
                    timeTillEnd = getFormattedTimeLeft(
                        self.__battlePass.getSeasonTimeLeft())
                model.setTimeTillEnd(timeTillEnd)
                self.__getAwards(chapterID, model.rewardsCommon, curLevel,
                                 BattlePassConsts.REWARD_FREE)
                self.__getAwards(chapterID, model.rewardsElite, curLevel,
                                 BattlePassConsts.REWARD_PAID)
            return
예제 #3
0
 def __updateBuyButtonState(self):
     sellAnyLevelsUnlocked = self.__battlePassController.isSellAnyLevelsUnlocked(
     )
     disableBuyButton = not sellAnyLevelsUnlocked and self.__battlePassController.getBoughtLevels(
     ) > 0
     showBubble = sellAnyLevelsUnlocked and not self.__isBuyButtonHintShown(
     ) and isCurrentBattlePassStateBase()
     isVisible = isCurrentBattlePassStateBase(
     ) or not self.__battlePassController.isBought()
     sellAnyLevelsUnlockTimeLeft = ''
     if disableBuyButton:
         sellAnyLevelsUnlockTimeLeft = getFormattedTimeLeft(
             self.__battlePassController.getSellAnyLevelsUnlockTimeLeft())
     with self.viewModel.transaction() as model:
         model.setIsFinalOfferTime(isSeasonEndingSoon())
         model.setSeasonTimeLeft(
             getFormattedTimeLeft(
                 self.__battlePassController.getSeasonTimeLeft()))
         model.setSellAnyLevelsUnlockTimeLeft(sellAnyLevelsUnlockTimeLeft)
         model.setShowBuyButtonBubble(showBubble)
         model.setIsVisibleBuyButton(isVisible)
    def _onLoading(self, *args, **kwargs):
        super(BattlePassInProgressTooltipView,
              self)._onLoading(*args, **kwargs)
        with self.getViewModel().transaction() as model:
            items = model.rewardPoints.getItems()
            for points in self.__battlePassController.getPerBattlePoints():
                item = RewardPointsModel()
                item.setTopCount(points.label)
                item.setPointsWin(points.winPoint)
                item.setPointsLose(points.losePoint)
                items.addViewModel(item)

            curLevel = self.__battlePassController.getCurrentLevel()
            curPoints, limitPoints = self.__battlePassController.getLevelProgression(
            )
            isPostProgression = self.__battlePassController.getState(
            ) == BattlePassState.POST
            model.setLevel(curLevel)
            model.setCurrentPoints(curPoints)
            model.setMaxPoints(limitPoints)
            model.setIsBattlePassPurchased(
                self.__battlePassController.isBought())
            model.setIsPostProgression(isPostProgression)
            model.setCanPlay(
                self.__battlePassController.canPlayerParticipate())
            timeTillEnd = ''
            if isSeasonEndingSoon(
            ) and not self.__battlePassController.isBought():
                timeTillEnd = getFormattedTimeLeft(
                    self.__battlePassController.getSeasonTimeLeft())
            model.setTimeTillEnd(timeTillEnd)
            if isPostProgression:
                self.__getAwards(model.rewardsCommon, curLevel,
                                 BattlePassConsts.REWARD_POST)
            else:
                self.__getAwards(model.rewardsCommon, curLevel,
                                 BattlePassConsts.REWARD_FREE)
                self.__getAwards(model.rewardsElite, curLevel,
                                 BattlePassConsts.REWARD_PAID)
예제 #5
0
 def __getTimeLeft(self):
     currentSeason = self.__rankedBattleController.getCurrentSeason()
     return getFormattedTimeLeft(
         max(0,
             currentSeason.getEndDate() -
             time_utils.getServerUTCTime())) if currentSeason else ''
예제 #6
0
 def __setPackageUnlockTime(model, package):
     timeToUnlock = package.getTimeToUnlock()
     model.setTimeToUnlock(
         getFormattedTimeLeft(timeToUnlock) if timeToUnlock else '')
예제 #7
0
 def __updateTimer(self):
     self.viewModel.setSeasonTimeLeft(
         getFormattedTimeLeft(
             self.__battlePassController.getSeasonTimeLeft()))
     self.__updateBuyButtonState()
예제 #8
0
 def __setCurrentLevelState(self, model=None):
     currentChapter = self.__battlePassController.getCurrentChapter()
     pointsBeforeChapterStart = self.__battlePassController.getFullChapterPoints(
         self.__chosenChapter, False)
     minLevel, maxLevel = self.__battlePassController.getChapterLevelInterval(
         self.__chosenChapter)
     if self.__chosenChapter == currentChapter:
         previousTotalPoints = AccountSettings.getSettings(
             LAST_BATTLE_PASS_POINTS_SEEN)
         currentTotalPoints = self.__battlePassController.getCurrentPoints()
         AccountSettings.setSettings(LAST_BATTLE_PASS_POINTS_SEEN,
                                     currentTotalPoints)
     elif self.__chosenChapter < currentChapter:
         previousTotalPoints = currentTotalPoints = self.__battlePassController.getFullChapterPoints(
             self.__chosenChapter, True)
     else:
         previousTotalPoints = currentTotalPoints = pointsBeforeChapterStart
     _, previousLevel = self.__battlePassController.getLevelByPoints(
         previousTotalPoints)
     previousPoints, _ = self.__battlePassController.getProgressionByPoints(
         previousTotalPoints, previousLevel)
     previousLevel += 1
     _, currentLevel = self.__battlePassController.getLevelByPoints(
         currentTotalPoints)
     currentLevel += 1
     if previousTotalPoints > currentTotalPoints or previousLevel > currentLevel:
         previousLevel = minLevel
         previousTotalPoints = pointsBeforeChapterStart
     previousLevel = min(max(previousLevel, minLevel - 1), maxLevel + 1)
     currentLevel = min(max(currentLevel, minLevel - 1), maxLevel + 1)
     previousTotalPoints = max(
         0, previousTotalPoints - pointsBeforeChapterStart)
     currentTotalPoints -= pointsBeforeChapterStart
     isBattlePassBought = self.__battlePassController.isBought(
         chapter=self.__chosenChapter)
     chapterConfig = self.__battlePassController.getChapterConfig()
     model.setChapterCount(len(chapterConfig))
     model.setChapterStep(first(chapterConfig, default=0))
     model.setChosenChapter(self.__chosenChapter)
     model.setCurrentChapter(currentChapter)
     model.setPointsBeforeStart(pointsBeforeChapterStart)
     chapterText = backport.text(
         _rBattlePass.progression.chapterText(),
         chapter=backport.text(
             _rBattlePass.chapter.name.num(self.__chosenChapter)()),
         chapterName=backport.text(
             _rBattlePass.chapter.fullName.num(self.__chosenChapter)()))
     model.setChapterText(chapterText)
     model.setPreviousAllPoints(previousTotalPoints)
     model.setPreviousPoints(previousPoints)
     model.setPreviousLevel(previousLevel)
     model.setCurrentAllPoints(currentTotalPoints)
     currentPoints, levelPoints = self.__battlePassController.getLevelProgression(
     )
     if self.__chosenChapter != currentChapter:
         currentPoints = 0
         currentLevel = self.__battlePassController.getCurrentLevel() + 1
     currentLevel = min(currentLevel,
                        self.__battlePassController.getMaxLevel())
     model.setCurrentPoints(currentPoints)
     model.setTotalPoints(levelPoints)
     model.setCurrentLevel(currentLevel)
     model.setIsBattlePassPurchased(isBattlePassBought)
     model.setIsPaused(self.__battlePassController.isPaused())
     model.setSeasonTimeLeft(
         getFormattedTimeLeft(
             self.__battlePassController.getSeasonTimeLeft()))
     if self.__battlePassController.isSeasonFinished():
         model.setSeasonText(
             backport.text(_rBattlePass.commonProgression.body.ended()))
     else:
         seasonNum = self.__battlePassController.getSeasonNum()
         timeEnd = self.__battlePassController.getSeasonFinishTime()
         model.setSeasonText(self.__makeSeasonTimeText(timeEnd, seasonNum))
     self.__updateRewardSelectButton(model=model)
예제 #9
0
 def __getSeasonTimeLeft(self):
     currentSeason = self.__mapboxCtrl.getCurrentSeason()
     return getFormattedTimeLeft(
         max(0,
             currentSeason.getEndDate() -
             time_utils.getServerUTCTime())) if currentSeason else ''
 def __updateTimer(self):
     self.viewModel.setExpireTimeStr(
         getFormattedTimeLeft(self.__battlePass.getSeasonTimeLeft()))
     self.__updateBuyButtonState()
 def __setExpirations(self, model):
     expireTimestamp = self.__battlePass.getChapterRemainingTime(
         self.__chapterID) if self.__battlePass.isExtraChapter(
             self.__chapterID) else self.__battlePass.getSeasonTimeLeft()
     model.setExpireTime(expireTimestamp)
     model.setExpireTimeStr(getFormattedTimeLeft(expireTimestamp))
예제 #12
0
 def __setCurrentLevelState(self, model=None):
     previousTotalPoints = AccountSettings.getSettings(
         LAST_BATTLE_PASS_POINTS_SEEN)
     previousState, previousLevel = self.__battlePassController.getLevelByPoints(
         previousTotalPoints)
     previousPoints, _ = self.__battlePassController.getProgressionByPoints(
         previousTotalPoints, previousState, previousLevel)
     previousLevel += 1
     currentTotalPoints = self.__battlePassController.getCurrentPoints()
     currentState = self.__battlePassController.getState()
     currentLevel = self.__battlePassController.getCurrentLevel() + 1
     AccountSettings.setSettings(LAST_BATTLE_PASS_POINTS_SEEN,
                                 currentTotalPoints)
     if previousState != currentState:
         if not (previousState == BattlePassState.POST
                 and currentState == BattlePassState.COMPLETED):
             previousLevel = 1
             previousTotalPoints = 0
     if previousTotalPoints > currentTotalPoints or previousLevel > currentLevel:
         previousState = BattlePassState.BASE
         previousLevel = 1
         previousTotalPoints = 0
     previousLevel = min(
         previousLevel,
         self.__battlePassController.getMaxLevel(
             previousState == BattlePassState.BASE))
     currentLevel = min(
         currentLevel,
         self.__battlePassController.getMaxLevel(
             currentState == BattlePassState.BASE))
     if previousTotalPoints > 0:
         if previousState == BattlePassState.POST:
             previousTotalPoints -= self.__battlePassController.getMaxPoints(
             )
         elif previousState == BattlePassState.COMPLETED:
             previousTotalPoints = self.__battlePassController.getMaxPoints(
                 False)
     if currentState == BattlePassState.POST:
         currentTotalPoints -= self.__battlePassController.getMaxPoints()
     elif currentState == BattlePassState.COMPLETED:
         currentTotalPoints = self.__battlePassController.getMaxPoints(
             False)
     currentPoints, levelPoints = self.__battlePassController.getLevelProgression(
     )
     isBattlePassBought = self.__battlePassController.isBought()
     model.setTitle(
         backport.text(R.strings.battle_pass_2020.progression.title()))
     model.setPreviousAllPoints(previousTotalPoints)
     model.setPreviousPoints(previousPoints)
     model.setPreviousLevel(previousLevel)
     model.setCurrentAllPoints(currentTotalPoints)
     model.setCurrentPoints(currentPoints)
     model.setTotalPoints(levelPoints)
     model.setCurrentLevel(currentLevel)
     model.setMaxLevelBase(self.__battlePassController.getMaxLevel())
     model.setMaxLevelPost(self.__battlePassController.getMaxLevel(False))
     model.setIsPostProgression(currentState != BattlePassState.BASE)
     model.setIsBattlePassPurchased(isBattlePassBought)
     isPaused = self.__battlePassController.isPaused()
     canBuy = self.__battlePassController.isActive(
     ) or currentLevel > 0 and not isPaused
     model.setIsPaused(isPaused)
     model.setCanBuy(canBuy)
     model.setSeasonTimeLeft(
         getFormattedTimeLeft(
             self.__battlePassController.getSeasonTimeLeft()))
     model.setCanPlayerParticipate(
         self.__battlePassController.canPlayerParticipate())
     if self.__battlePassController.isSeasonFinished():
         model.setSeasonTime(
             backport.text(
                 R.strings.battle_pass_2020.commonProgression.body.ended()))
     else:
         timeStart = self.__battlePassController.getSeasonStartTime()
         timeEnd = self.__battlePassController.getSeasonFinishTime()
         timePeriod = '{} - {}'.format(self.__makeSeasonTimeText(timeStart),
                                       self.__makeSeasonTimeText(timeEnd))
         model.setSeasonTime(timePeriod)