Exemplo n.º 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)
Exemplo n.º 2
0
 def handleGetShopBannerParams(self, _):
     isActive = not self.__battlePassCtrl.isPaused(
     ) and self.__battlePassCtrl.isVisible()
     chapterConfig = self.__battlePassCtrl.getChapterConfig()
     chaptersBuyInfo = {
         chapter: self.__battlePassCtrl.isBought(chapter=chapter)
         for chapter, _ in enumerate(
             chapterConfig, BattlePassConsts.MINIMAL_CHAPTER_NUMBER)
     }
     boughtChapters = {
         chapter: isBought
         for chapter, isBought in chaptersBuyInfo.iteritems() if isBought
     }
     if boughtChapters:
         maxBoughtChapter = max(boughtChapters)
         canBuyLevels = chapterConfig[
             maxBoughtChapter -
             1] > self.__battlePassCtrl.getCurrentLevel()
     else:
         canBuyLevels = False
     canBuyBP = not all(chaptersBuyInfo.values())
     hasBP = any(chaptersBuyInfo.values())
     data = {
         'isActive': isActive,
         'canBuyBP': canBuyBP,
         'canBuyLevels': canBuyLevels,
         'hasBP': hasBP,
         'isSeasonLeftSoon': isSeasonEndingSoon()
     }
     return data
 def __updateData(self, model=None):
     self.__updateLevelState(model)
     isBattlePassBought = self.__battlePass.isBought(
         chapterID=self.__chapterID)
     model.setIsBattlePassPurchased(isBattlePassBought)
     model.setIsPaused(self.__battlePass.isPaused())
     model.setChapterState(
         _CHAPTER_STATES.get(
             self.__battlePass.getChapterState(self.__chapterID)))
     model.setFinalReward(
         self.__battlePass.getRewardType(self.__chapterID).value)
     model.setChapterID(self.__chapterID)
     model.setBpbitCount(
         self.__itemsCache.items.stats.dynamicCurrencies.get(
             CurrencyBP.BIT.value, 0))
     model.setIsBattlePassCompleted(self.__battlePass.isCompleted())
     model.setNotChosenRewardCount(
         self.__battlePass.getNotChosenRewardCount())
     model.setIsChooseRewardsEnabled(self.__battlePass.canChooseAnyReward())
     model.setIsExtra(self.__battlePass.isExtraChapter(self.__chapterID))
     model.setIsSeasonEndingSoon(isSeasonEndingSoon())
     model.setSeasonText(self.__makeSeasonTimeText())
     model.setHasExtra(self.__battlePass.hasExtra())
     self.__setExpirations(model)
     if self.__battlePass.getRewardType(
             self.__chapterID) == FinalReward.STYLE:
         self.__setStyleTaken(model)
     self.__updateRewardSelectButton(model=model)
    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
 def handleGetShopBannerParams(self, _):
     isBase = isCurrentBattlePassStateBase()
     isActive = not self.__battlePassCtrl.isPaused(
     ) and self.__battlePassCtrl.isVisible()
     canBuyBP = not self.__battlePassCtrl.isBought()
     canBuyLevels = self.__battlePassCtrl.getBoughtLevels(
     ) == 0 or self.__battlePassCtrl.isSellAnyLevelsUnlocked()
     isVisible = isActive and (canBuyBP or isBase and canBuyLevels)
     data = {
         'isVisible': isVisible,
         'isSeasonLeftSoon': isSeasonEndingSoon()
     }
     return data
Exemplo n.º 6
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)
Exemplo n.º 8
0
 def handleGetShopBannerParams(self, _):
     _logger.error(
         'W2C "get_shop_banners_params" is deprecated, use "get_info" instead!'
     )
     isActive = not self.__battlePass.isPaused(
     ) and self.__battlePass.isVisible()
     chaptersBuyInfo = {
         chapterID: self.__battlePass.isBought(chapterID=chapterID)
         for chapterID in self.__battlePass.getChapterIDs()
     }
     canBuyBP = not all(chaptersBuyInfo.values())
     hasBP = any(chaptersBuyInfo.values())
     canBuyLevels = any(
         (isBought and self.__battlePass.getChapterState(chapterID)
          == ChapterState.ACTIVE
          for chapterID, isBought in chaptersBuyInfo.iteritems()))
     return {
         'isActive': isActive,
         'canBuyBP': canBuyBP,
         'canBuyLevels': canBuyLevels,
         'hasBP': hasBP,
         'isSeasonLeftSoon': isSeasonEndingSoon()
     }