예제 #1
0
 def _onEntered(self):
     machine = self.getMachine()
     if machine is None:
         return
     else:
         chapter = machine.getChosenStyleChapter()
         _, machineData = machine.getRewardsData()
         if machineData is not None:
             oldLevel = machineData['prevLevel']
             newLevel = machineData['newLevel']
             oldChapter = self.__battlePass.getChapterByLevel(oldLevel)
             newChapter = self.__battlePass.getChapterByLevel(newLevel)
             isMaxLevel = newLevel == self.__battlePass.getMaxLevel()
             if chapter >= oldChapter and (oldChapter != newChapter or isMaxLevel):
                 machine.post(StateEvent())
                 return
         chapter = machine.getChosenStyleChapter()
         _, level = getStyleInfoForChapter(chapter)
         if level is None:
             machine.post(StateEvent())
             return
         prevLevel, _ = self.__battlePass.getChapterLevelInterval(chapter)
         data = {'reason': BattlePassRewardReason.SELECT_STYLE,
          'prevLevel': prevLevel,
          'callback': partial(machine.post, StateEvent())}
         styleToken = get3DStyleProgressToken(self.__battlePass.getSeasonID(), chapter, level)
         rewards = packToken(styleToken)
         machine.clearChosenStyle()
         showBattlePassAwardsWindow([rewards], data)
         return
예제 #2
0
 def _onEntered(self):
     machine = self.getMachine()
     if machine is None:
         return
     else:
         rewards, data = machine.getRewardsData()
         if rewards is None:
             machine.clearSelf()
             machine.post(StateEvent())
             return
         if data is None:
             data = {'reason': BattlePassRewardReason.PURCHASE_BATTLE_PASS_LEVELS,
              'prevLevel': self.__battlePass.getCurrentLevel()}
         data['callback'] = partial(machine.post, StateEvent())
         chapter = machine.getChosenStyleChapter()
         _, level = getStyleInfoForChapter(chapter)
         chosenStyleLevel = level
         if chapter is None:
             chapter = self.__battlePass.getChapterByLevel(data['prevLevel'])
             if 'newLevel' in data:
                 newLevel = data['newLevel'] + 1
                 if chosenStyleLevel is None and newLevel > self.__battlePass.getChapterLevelInterval(chapter)[1]:
                     level = self.__battlePass.getChapterStyleProgress(chapter)
         if level is not None:
             styleToken = get3DStyleProgressToken(self.__battlePass.getSeasonID(), chapter, level)
             rewards.append(packToken(styleToken))
             if chosenStyleLevel is not None:
                 machine.clearChosenStyle()
         if not rewards:
             machine.clearSelf()
             machine.post(StateEvent())
             return
         showBattlePassAwardsWindow(rewards, data)
         return
예제 #3
0
 def _onEntered(self):
     machine = self.getMachine()
     if machine is None:
         return
     else:
         rewards, data = machine.getRewardsData()
         if rewards is None:
             machine.clearSelf()
             machine.post(StateEvent())
             return
         if data is None:
             data = {
                 'reason':
                 BattlePassRewardReason.PURCHASE_BATTLE_PASS_LEVELS
             }
         data['callback'] = partial(self.__onAwardClose,
                                    data.get('chapter'), data.get('reason'))
         chapter = machine.getChosenStyleChapter()
         if chapter is not None:
             _, level = getStyleInfoForChapter(chapter)
             styleToken = get3DStyleProgressToken(
                 self.__battlePass.getSeasonID(), chapter, level)
             rewards.append(packToken(styleToken))
             machine.clearChapterStyle()
         if not rewards:
             machine.clearSelf()
             machine.post(StateEvent())
             return
         showBattlePassAwardsWindow(rewards, data)
         return
예제 #4
0
 def _onEntered(self):
     machine = self.getMachine()
     if machine is None:
         return
     else:
         chapterID = machine.getChosenStyleChapter()
         _, level = getStyleInfoForChapter(chapterID)
         style = getStyleForChapter(chapterID)
         if style is not None and style.getProgressionLevel(
         ) == style.getMaxProgressionLevel():
             machine.post(StateEvent())
             return
         prevLevel, _ = self.__battlePass.getChapterLevelInterval(chapterID)
         data = {
             'reason': BattlePassRewardReason.STYLE_UPGRADE,
             'chapter': chapterID,
             'prevLevel': prevLevel,
             'callback': partial(machine.post, StateEvent())
         }
         styleToken = get3DStyleProgressToken(
             self.__battlePass.getSeasonID(), chapterID, level)
         rewards = packToken(styleToken)
         machine.clearChapterStyle()
         showBattlePassAwardsWindow([rewards], data)
         return
예제 #5
0
 def _onEntered(self):
     machine = self.getMachine()
     if machine is not None:
         chapter = machine.getChosenStyleChapter()
         intCD, level = getStyleInfoForChapter(chapter)
         videoSource = R.videos.battle_pass.dyn('c_{}_{}'.format(
             intCD, level))
         if not videoSource.exists():
             machine.post(StateEvent())
             return
         showVideo(videoSource,
                   isAutoClose=True,
                   onVideoClosed=partial(machine.post, StateEvent()))
     return
예제 #6
0
 def _onEntered(self):
     machine = self.getMachine()
     if machine is not None:
         if machine.hasRewardToChoose():
             showBattlePassRewardChoiceWindow()
         else:
             machine.post(StateEvent())
     return
예제 #7
0
 def __onAwardClose(self, chapterID, reason):
     machine = self.getMachine()
     if machine is not None:
         machine.post(StateEvent())
     if not self.__battlePass.isDisabled(
     ) and reason == BattlePassRewardReason.PURCHASE_BATTLE_PASS:
         showMissionsBattlePass(
             R.views.lobby.battle_pass.BattlePassProgressionsView(),
             chapterID)
     return
예제 #8
0
    def _onEntered(self):
        machine = self.getMachine()
        if machine is not None:
            _, data = machine.getRewardsData()
            if machine.hasRewardToChoose():

                def onCloseCallback():
                    for token, isTaken in processRewardsToChoose(
                            machine.getRewardsToChoose()).iteritems():
                        machine.removeRewardToChoose(token, isTaken)

                    machine.post(StateEvent())

                showBattlePassRewardsSelectionWindow(
                    chapterID=data.get('chapter', 0),
                    level=data.get('level', 0),
                    onRewardsReceivedCallback=machine.extendRewards,
                    onCloseCallback=onCloseCallback)
            else:
                machine.post(StateEvent())
        return
예제 #9
0
 def __onHidePreview(self, _):
     machine = self.getMachine()
     if machine:
         machine.post(StateEvent())
예제 #10
0
                def onCloseCallback():
                    for token, isTaken in processRewardsToChoose(
                            machine.getRewardsToChoose()).iteritems():
                        machine.removeRewardToChoose(token, isTaken)

                    machine.post(StateEvent())
예제 #11
0
 def postStateEvent(self, **kwargs):
     if self.__machine.isRunning():
         self.__machine.post(StateEvent(**kwargs))