Esempio n. 1
0
def handleJoinBattle(command, ctx):

    def doJoin(restoreOnError):
        dispatcher = g_prbLoader.getDispatcher()

        @process
        def onError(errorData):
            if restoreOnError:
                dispatcher.restorePrevious()
            else:
                yield dispatcher.doSelectAction(PrbAction(PREBATTLE_ACTION_NAME.STRONGHOLDS_BATTLES_LIST))
            try:
                message = errorData['extra_data']['title']
                pushMessage(message, type=SM_TYPE.Error)
            except (KeyError, TypeError):
                LOG_CURRENT_EXCEPTION()

        _doJoinBattle(dispatcher, command.unit_id, onError)

    connectionMgr = dependency.instance(IConnectionManager)
    if connectionMgr.peripheryID != command.periphery_id:
        success = yield DialogsInterface.showI18nConfirmDialog('changePeriphery')
        if success:
            reloginCtrl = dependency.instance(IReloginController)
            reloginCtrl.doRelogin(command.periphery_id, extraChainSteps=(actions.OnLobbyInitedAction(onInited=partial(doJoin, False)),))
    else:
        doJoin(True)
    def __getExtraSteps(self):
        if self.__isEnabled:
            prbAction = PREBATTLE_ACTION_NAME.RANKED
        else:
            prbAction = PREBATTLE_ACTION_NAME.RANKED_FORCED

        def onLobbyInit():
            actions.SelectPrb(PrbAction(prbAction)).invoke()

        return [actions.OnLobbyInitedAction(onInited=onLobbyInit)]
Esempio n. 3
0
    def serverClick(self, eventID, serverID):
        def doJoin():
            from gui.Scaleform.framework import g_entitiesFactories
            g_eventBus.handleEvent(
                g_entitiesFactories.makeLoadEvent('missions'),
                scope=EVENT_BUS_SCOPE.LOBBY)

        reloginCtrl = dependency.instance(IReloginController)
        success = yield DialogsInterface.showI18nConfirmDialog(
            'changePeriphery')
        if success:
            reloginCtrl.doRelogin(int(serverID),
                                  extraChainSteps=(actions.OnLobbyInitedAction(
                                      onInited=doJoin), ))
Esempio n. 4
0
    def getExtraChainSteps(self):
        def onLobbyInit():
            actions.SelectPrb(PrbAction(PREBATTLE_ACTION_NAME.RANKED)).invoke()

        return [actions.OnLobbyInitedAction(onInited=onLobbyInit)]
Esempio n. 5
0
    def __getExtraSteps(self):
        def onLobbyInit():
            actions.SelectPrb(PrbAction(self._getPrbActionName())).invoke()

        return [actions.OnLobbyInitedAction(onInited=onLobbyInit)]