Beispiel #1
0
 def configure(self):
     entering = State(stateID=GameplayStateID.AVATAR_ENTERING,
                      flags=StateFlags.INITIAL | StateFlags.SINGULAR)
     arenaInfo = State(stateID=GameplayStateID.AVATAR_ARENA_INFO)
     showGUI = State(stateID=GameplayStateID.AVATAR_SHOW_GUI)
     arenaLoaded = State(stateID=GameplayStateID.AVATAR_ARENA_LOADED)
     exiting = State(stateID=GameplayStateID.AVATAR_EXITING)
     self.addChildState(entering)
     self.addChildState(arenaInfo)
     self.addChildState(showGUI)
     self.addChildState(arenaLoaded)
     self.addChildState(exiting)
     entering.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_ARENA_INFO),
                            target=arenaInfo)
     arenaInfo.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_SHOW_GUI),
                             target=showGUI)
     arenaInfo.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_ARENA_LOADED),
                             target=arenaLoaded)
     showGUI.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_ARENA_LOADED),
                           target=arenaLoaded)
     arenaLoaded.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_NON_PLAYER),
                               target=exiting)
Beispiel #2
0
 def configure(self):
     choiceItem = ChoiceItemState()
     choiceStyle = ChoiceStyleState()
     preview = PreviewState()
     choiceStyle.addTransition(StringEventTransition(StateMachineEventID.OPEN_PREVIEW, priority=2), target=preview)
     preview.addTransition(StringEventTransition(StateMachineEventID.CLOSE_PREVIEW, priority=1), target=choiceStyle)
     self.addChildState(choiceItem)
     self.addChildState(choiceStyle)
     self.addChildState(preview)
Beispiel #3
0
 def configure(self):
     loading = State(stateID=GameplayStateID.BATTLE_REPLAY_LOADING,
                     flags=StateFlags.SINGULAR | StateFlags.INITIAL)
     differs = State(stateID=GameplayStateID.BATTLE_REPLAY_VERSION_DIFFERS)
     starting = State(stateID=GameplayStateID.BATTLE_REPLAY_STARTING)
     nextReplay = State(stateID=GameplayStateID.BATTLE_REPLAY_NEXT)
     loading.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_VERSION_CONFIRMATION),
                           target=differs)
     differs.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_VERSION_CONFIRMED),
                           target=starting)
     self.addChildState(loading)
     self.addChildState(differs)
     self.addChildState(starting)
     self.addChildState(nextReplay)
Beispiel #4
0
 def configure(self):
     entering = State(stateID=GameplayStateID.ACCOUNT_ENTERING,
                      flags=StateFlags.INITIAL | StateFlags.SINGULAR)
     showGUI = State(stateID=GameplayStateID.ACCOUNT_SHOW_GUI)
     exiting = State(stateID=GameplayStateID.ACCOUNT_EXITING)
     self.addChildState(entering)
     self.addChildState(showGUI)
     self.addChildState(exiting)
     entering.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_SHOW_GUI),
                            target=showGUI)
     showGUI.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_BECOME_NON_PLAYER),
                           target=exiting)
     exiting.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_BECOME_PLAYER),
                           target=entering)
Beispiel #5
0
 def configure(self, initialization):
     avatar = AvatarState(flags=StateFlags.INITIAL | StateFlags.SINGULAR)
     avatar.configure()
     finish = State(GameplayStateID.BATTLE_REPLAY_FINISHED)
     rewind = State(GameplayStateID.BATTLE_REPLAY_REWIND)
     self.addChildState(avatar)
     self.addChildState(finish)
     self.addChildState(rewind)
     initialization.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                                  target=avatar)
     rewind.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                          target=avatar)
     avatar.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_FINISHED),
                          target=finish)
     avatar.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_REWIND),
                          target=rewind)
     finish.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_REWIND),
                          target=rewind)
     avatar.exiting.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_NEXT),
                                  target=initialization.nextReplay)
 def configure(self, offline):
     account = AccountState(flags=StateFlags.INITIAL | StateFlags.SINGULAR)
     account.configure()
     avatar = AvatarState()
     avatar.configure()
     self.addChildState(account)
     self.addChildState(avatar)
     offline.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_BECOME_PLAYER),
                           target=account)
     offline.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                           target=avatar)
     account.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                           target=avatar)
     avatar.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_BECOME_PLAYER),
                          target=account)
     self.addTransition(StringEventTransition(
         PlayerEventID.NON_PLAYER_BECOME_PLAYER),
                        target=offline.login)
Beispiel #7
0
 def configure(self):
     loading = State(stateID=GameplayStateID.GAME_LOADING,
                     flags=StateFlags.INITIAL | StateFlags.SINGULAR)
     intro = State(stateID=GameplayStateID.INTRO_VIDEO)
     login = State(stateID=GameplayStateID.LOGIN)
     loading.addTransition(ConditionTransition(
         lambda e: helpers.isShowStartupVideo(), invert=False),
                           target=intro)
     loading.addTransition(ConditionTransition(
         lambda e: helpers.isShowStartupVideo(), invert=True),
                           target=login)
     intro.addTransition(StringEventTransition(
         GUIEventID.INTRO_VIDEO_FINISHED),
                         target=login)
     self.addChildState(loading)
     self.addChildState(intro)
     self.addChildState(login)
Beispiel #8
0
    def _configuredStates(self, startState):
        states = {}
        for stateName in BuyAndExchangeStateEnum:
            flags = StateFlags.SINGULAR
            if stateName == startState:
                flags |= StateFlags.INITIAL
            states[stateName] = State(stateName, flags)

        states[BuyAndExchangeStateEnum.BUY_CONTENT].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.NEED_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.NEED_EXCHANGE])
        states[BuyAndExchangeStateEnum.CAN_NOT_BUY].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.NEED_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.NEED_EXCHANGE])
        states[BuyAndExchangeStateEnum.GOLD_NOT_ENOUGH].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.NEED_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.EXCHANGE_NOT_REQUIRED].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.NEED_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.BUY_CONTENT].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.START_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.CAN_NOT_BUY].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.START_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.GOLD_NOT_ENOUGH].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.START_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.EXCHANGE_NOT_REQUIRED].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.START_EXCHANGE),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.NEED_EXCHANGE].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.ACCEPT_CLICKED),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.ACCEPT_CLICKED),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_IN_PROCESS])
        states[BuyAndExchangeStateEnum.EXCHANGE_IN_PROCESS].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.EXCHANGE_COMPLETED),
            target=states[BuyAndExchangeStateEnum.BUY_CONTENT])
        states[BuyAndExchangeStateEnum.EXCHANGE_IN_PROCESS].addTransition(
            StringEventTransition(
                BuyAndExchangeEventEnum.EXCHANGE_VALIDATION_ERROR),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT])
        states[BuyAndExchangeStateEnum.BUY_CONTENT].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_NOT_BUY),
            target=states[BuyAndExchangeStateEnum.CAN_NOT_BUY])
        states[BuyAndExchangeStateEnum.NEED_EXCHANGE].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_NOT_BUY),
            target=states[BuyAndExchangeStateEnum.CAN_NOT_BUY])
        states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_NOT_BUY),
            target=states[BuyAndExchangeStateEnum.GOLD_NOT_ENOUGH])
        states[BuyAndExchangeStateEnum.EXCHANGE_NOT_REQUIRED].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_NOT_BUY),
            target=states[BuyAndExchangeStateEnum.GOLD_NOT_ENOUGH])
        states[BuyAndExchangeStateEnum.NEED_EXCHANGE].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_BUY),
            target=states[BuyAndExchangeStateEnum.BUY_CONTENT])
        states[BuyAndExchangeStateEnum.EXCHANGE_CONTENT].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_BUY),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_NOT_REQUIRED])
        states[BuyAndExchangeStateEnum.CAN_NOT_BUY].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_BUY),
            target=states[BuyAndExchangeStateEnum.BUY_CONTENT])
        states[BuyAndExchangeStateEnum.GOLD_NOT_ENOUGH].addTransition(
            StringEventTransition(BuyAndExchangeEventEnum.CAN_BUY),
            target=states[BuyAndExchangeStateEnum.EXCHANGE_NOT_REQUIRED])
        for state in states.values():
            self.__stateMachine.addState(state)
Beispiel #9
0
 def configure(self, offline):
     account = AccountState(flags=StateFlags.INITIAL | StateFlags.SINGULAR)
     account.configure()
     avatar = AvatarState()
     avatar.configure()
     enteringReplay = State(stateID=GameplayStateID.SERVER_REPLAY_ENTERING)
     exitingReplay = State(stateID=GameplayStateID.SERVER_REPLAY_EXITING)
     rewindReplay = State(GameplayStateID.BATTLE_REPLAY_REWIND)
     finishReplay = State(GameplayStateID.BATTLE_REPLAY_FINISHED)
     self.addChildState(account)
     self.addChildState(avatar)
     self.addChildState(enteringReplay)
     self.addChildState(exitingReplay)
     self.addChildState(rewindReplay)
     self.addChildState(finishReplay)
     offline.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_BECOME_PLAYER),
                           target=account)
     offline.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                           target=avatar)
     account.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                           target=avatar)
     account.addTransition(StringEventTransition(
         ReplayEventID.SERVER_REPLAY_ENTERING),
                           target=enteringReplay)
     enteringReplay.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                                  target=avatar)
     enteringReplay.addTransition(StringEventTransition(
         ReplayEventID.SERVER_REPLAY_EXITING),
                                  target=exitingReplay)
     avatar.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_FINISHED),
                          target=finishReplay)
     avatar.addTransition(StringEventTransition(
         ReplayEventID.SERVER_REPLAY_EXITING),
                          target=exitingReplay)
     exitingReplay.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_BECOME_PLAYER),
                                 target=account)
     avatar.addTransition(StringEventTransition(
         PlayerEventID.ACCOUNT_BECOME_PLAYER),
                          target=account)
     avatar.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_REWIND),
                          target=rewindReplay)
     rewindReplay.addTransition(StringEventTransition(
         PlayerEventID.AVATAR_BECOME_PLAYER),
                                target=avatar)
     finishReplay.addTransition(StringEventTransition(
         ReplayEventID.REPLAY_REWIND),
                                target=rewindReplay)
     finishReplay.addTransition(StringEventTransition(
         ReplayEventID.SERVER_REPLAY_EXITING),
                                target=exitingReplay)
     self.addTransition(StringEventTransition(
         PlayerEventID.NON_PLAYER_BECOME_PLAYER),
                        target=offline.login)