Exemplo n.º 1
0
 def join(self, ctx, callback=None):
     prbID = ctx.getID()
     if not AutoInvitesNotifier.hasInvite(prbID):
         SystemMessages.pushI18nMessage(
             I18N_SYSTEM_MESSAGES.ARENA_START_ERRORS_JOIN_NOT_FOUND,
             type=SystemMessages.SM_TYPE.Error)
         if callback:
             callback(False)
         return
     peripheryID = AutoInvitesNotifier.getInvite(prbID).peripheryID
     if g_lobbyContext.isAnotherPeriphery(peripheryID):
         hostName = g_lobbyContext.getPeripheryName(peripheryID)
         if hostName:
             message = i18n.makeString(
                 I18N_SYSTEM_MESSAGES.
                 ARENA_START_ERRORS_JOIN_WRONG_PERIPHERY_KNOWN, hostName)
         else:
             message = i18n.makeString(
                 I18N_SYSTEM_MESSAGES.
                 ARENA_START_ERRORS_JOIN_WRONG_PERIPHERY_UNKNOWN)
         SystemMessages.pushMessage(message,
                                    type=SystemMessages.SM_TYPE.Warning)
         if callback:
             callback(False)
     else:
         super(BattleSessionEntryPoint, self).join(ctx, callback)
Exemplo n.º 2
0
 def join(self, peripheryID, ctx, postActions = None, finishActions = None):
     if not g_lobbyContext.isAnotherPeriphery(peripheryID):
         LOG_ERROR('Player is in given periphery', peripheryID)
         return
     else:
         if postActions:
             if type(postActions) is types.ListType:
                 actionsList = postActions
             else:
                 LOG_ERROR('Argument "postActions" is invalid', postActions)
                 return
         else:
             actionsList = []
         actionsList.extend([actions.DisconnectFromPeriphery(), actions.ConnectToPeriphery(peripheryID), self.__enableAction])
         if finishActions:
             if type(finishActions) is types.ListType:
                 actionsList.extend(finishActions)
             else:
                 LOG_ERROR('Argument "finishActions" is invalid', finishActions)
                 return
         self.__joinCtx = ctx
         if self.__joinChain is not None:
             self.__joinChain.onStopped -= self.__onJoinChainStopped
             self.__joinChain.stop()
         self.__enableAction.inactivate()
         self.__joinChain = actions.ActionsChain(actionsList)
         self.__joinChain.onStopped += self.__onJoinChainStopped
         self.__joinChain.start()
         return
Exemplo n.º 3
0
def getLeaveOrChangeText(funcState, invitePrbType, peripheryID):
    key, kwargs = None, {}
    isAnotherPeriphery = g_lobbyContext.isAnotherPeriphery(peripheryID)
    if funcState.doLeaveToAcceptInvite(invitePrbType):
        if funcState.isInPrebattle() or funcState.isInUnit():
            entityName = getPrbName(funcState.entityTypeID)
        elif funcState.isInPreQueue():
            entityName = getPreQueueName(funcState.entityTypeID)
        else:
            LOG_ERROR('Can not resolve name of entity', funcState)
            return ''
        if isAnotherPeriphery:
            key = I18N_INVITES.invites_note_change_and_leave(entityName)
            kwargs = {
                'host': g_lobbyContext.getPeripheryName(peripheryID) or ''
            }
        else:
            key = I18N_INVITES.invites_note_leave(entityName)
    elif isAnotherPeriphery:
        key = I18N_INVITES.INVITES_NOTE_SERVER_CHANGE
        kwargs = {'host': g_lobbyContext.getPeripheryName(peripheryID) or ''}
    if key:
        text = i18n.makeString(key, **kwargs)
    else:
        text = ''
    return text
Exemplo n.º 4
0
def getLeaveOrChangeText(funcState, invitePrbType, peripheryID):
    key, kwargs = None, {}
    isAnotherPeriphery = g_lobbyContext.isAnotherPeriphery(peripheryID)
    if funcState.doLeaveToAcceptInvite(invitePrbType):
        if funcState.isInPrebattle() or funcState.isInUnit():
            entityName = getPrbName(funcState.entityTypeID)
        else:
            if funcState.isInFallout():
                return ''
            if funcState.isInPreQueue():
                entityName = getPreQueueName(funcState.entityTypeID)
            else:
                LOG_ERROR('Can not resolve name of entity', funcState)
                return ''
        if isAnotherPeriphery:
            key = I18N_INVITES.invites_note_change_and_leave(entityName)
            kwargs = {'host': g_lobbyContext.getPeripheryName(peripheryID) or ''}
        else:
            key = I18N_INVITES.invites_note_leave(entityName)
    elif isAnotherPeriphery:
        key = I18N_INVITES.INVITES_NOTE_SERVER_CHANGE
        kwargs = {'host': g_lobbyContext.getPeripheryName(peripheryID) or ''}
    if key:
        text = i18n.makeString(key, **kwargs)
    else:
        text = ''
    return text
Exemplo n.º 5
0
def tryToConnectFortBattle(battleID, peripheryID):
    from gui.prb_control.dispatcher import g_prbLoader
    from gui import DialogsInterface, SystemMessages
    yield lambda callback: callback(None)
    if g_lobbyContext.isAnotherPeriphery(peripheryID):
        if g_lobbyContext.isPeripheryAvailable(peripheryID):
            result = yield DialogsInterface.showDialog(
                UnitConfirmDialogMeta(
                    PREBATTLE_TYPE.FORT_BATTLE,
                    'changePeriphery',
                    messageCtx={
                        'host': g_lobbyContext.getPeripheryName(peripheryID)
                    }))
            if result:
                g_prbLoader.getPeripheriesHandler().join(
                    peripheryID,
                    CreateOrJoinFortBattleCtx(
                        battleID, waitingID='fort/fortBattle/createOrJoin'))
        else:
            SystemMessages.pushI18nMessage(
                '#system_messages:periphery/errors/isNotAvailable',
                type=SystemMessages.SM_TYPE.Error)
    else:
        yield g_prbLoader.getDispatcher().join(
            CreateOrJoinFortBattleCtx(
                battleID, waitingID='fort/fortBattle/createOrJoin'))
Exemplo n.º 6
0
def tryToConnectClubBattle(club, joinTime):
    from gui import DialogsInterface, SystemMessages
    from gui.prb_control.dispatcher import g_prbLoader
    from gui.Scaleform.daapi.view.dialogs.rally_dialog_meta import UnitConfirmDialogMeta
    yield lambda callback: callback(None)
    if not club:
        LOG_ERROR('Invalid club info to join unit', club, joinTime)
        return
    clubDbID = club.getClubDbID()
    if club.hasActiveUnit():
        peripheryID = club.getUnitInfo().peripheryID
        if g_lobbyContext.isAnotherPeriphery(peripheryID):
            if g_lobbyContext.isPeripheryAvailable(peripheryID):
                result = yield DialogsInterface.showDialog(
                    UnitConfirmDialogMeta(
                        PREBATTLE_TYPE.CLUBS,
                        'changePeriphery',
                        messageCtx={
                            'host':
                            g_lobbyContext.getPeripheryName(peripheryID)
                        }))
                if result:
                    g_prbLoader.getPeripheriesHandler().join(
                        peripheryID,
                        JoinClubBattleCtx(clubDbID,
                                          joinTime,
                                          allowDelay=True,
                                          waitingID='clubs/joinClubUnit'))
            else:
                SystemMessages.pushI18nMessage(
                    '#system_messages:periphery/errors/isNotAvailable',
                    type=SystemMessages.SM_TYPE.Error)
            return
    yield g_prbLoader.getDispatcher().join(
        JoinClubBattleCtx(clubDbID, joinTime, waitingID='clubs/joinClubUnit'))
Exemplo n.º 7
0
 def join(self, peripheryID, ctx, postActions=None, finishActions=None):
     if not g_lobbyContext.isAnotherPeriphery(peripheryID):
         LOG_ERROR('Player is in given periphery', peripheryID)
         return
     else:
         if postActions:
             if type(postActions) is types.ListType:
                 actionsList = postActions
             else:
                 LOG_ERROR('Argument "postActions" is invalid', postActions)
                 return
         else:
             actionsList = []
         actionsList.extend([
             actions.DisconnectFromPeriphery(),
             actions.ConnectToPeriphery(peripheryID), self.__enableAction
         ])
         if finishActions:
             if type(finishActions) is types.ListType:
                 actionsList.extend(finishActions)
             else:
                 LOG_ERROR('Argument "finishActions" is invalid',
                           finishActions)
                 return
         self.__joinCtx = ctx
         if self.__joinChain is not None:
             self.__joinChain.onStopped -= self.__onJoinChainStopped
             self.__joinChain.stop()
         self.__enableAction.inactivate()
         self.__joinChain = actions.ActionsChain(actionsList)
         self.__joinChain.onStopped += self.__onJoinChainStopped
         self.__joinChain.start()
         return
Exemplo n.º 8
0
 def __handleCreateOrJoinFortBattle(self, peripheryID, battleID, slotIndex = -1):
     if g_lobbyContext.isAnotherPeriphery(peripheryID):
         if g_lobbyContext.isPeripheryAvailable(peripheryID):
             self.__requestToReloginAndCreateOrJoinFortBattle(peripheryID, battleID, slotIndex)
         else:
             SystemMessages.pushI18nMessage('#system_messages:periphery/errors/isNotAvailable', type=SystemMessages.SM_TYPE.Error)
     else:
         self.__requestToCreateOrJoinFortBattle(battleID, slotIndex)
Exemplo n.º 9
0
 def requestToJoinTeam(self, prbID, prbType):
     item = self.__listRequester.getItem(prbID)
     if g_lobbyContext.isAnotherPeriphery(item.peripheryID):
         self.fireEvent(events.LoadViewEvent(
             PREBATTLE_ALIASES.AUTO_INVITE_WINDOW_PY, ctx={'prbID': prbID}),
                        scope=EVENT_BUS_SCOPE.LOBBY)
     else:
         self.__requestToJoin(prbID, prbType)
Exemplo n.º 10
0
 def canAcceptInvite(self, invite):
     result = True
     dispatcher = self.__loader.getDispatcher()
     if dispatcher is not None and dispatcher.getEntity().hasLockedState():
         result = False
     peripheryID = invite.peripheryID
     if result and g_lobbyContext.isAnotherPeriphery(peripheryID):
         result = g_lobbyContext.isPeripheryAvailable(peripheryID)
     return result
Exemplo n.º 11
0
 def onJoinRally(self, rallyId, slotIndex, peripheryID):
     ctx = JoinUnitCtx(rallyId, PREBATTLE_TYPE.SORTIE, slotIndex, waitingID='prebattle/join')
     if g_lobbyContext.isAnotherPeriphery(peripheryID):
         if g_lobbyContext.isPeripheryAvailable(peripheryID):
             self.__requestToReloginAndJoinSortie(peripheryID, ctx)
         else:
             SystemMessages.pushI18nMessage('#system_messages:periphery/errors/isNotAvailable', type=SystemMessages.SM_TYPE.Error)
     else:
         self.__requestToJoinSortie(ctx)
Exemplo n.º 12
0
def tryToConnectFortBattle(battleID, peripheryID):
    from gui.prb_control.dispatcher import g_prbLoader
    yield lambda callback: callback(None)
    if g_lobbyContext.isAnotherPeriphery(peripheryID):
        if g_lobbyContext.isPeripheryAvailable(peripheryID):
            result = yield DialogsInterface.showDialog(UnitConfirmDialogMeta(PREBATTLE_TYPE.FORT_BATTLE, 'changePeriphery', messageCtx={'host': g_lobbyContext.getPeripheryName(peripheryID)}))
            if result:
                g_prbLoader.getPeripheriesHandler().join(peripheryID, CreateOrJoinFortBattleCtx(battleID, waitingID='fort/fortBattle/createOrJoin'))
        else:
            SystemMessages.pushI18nMessage('#system_messages:periphery/errors/isNotAvailable', type=SystemMessages.SM_TYPE.Error)
    else:
        yield g_prbLoader.getDispatcher().join(CreateOrJoinFortBattleCtx(battleID, waitingID='fort/fortBattle/createOrJoin'))
Exemplo n.º 13
0
 def canAcceptInvite(self, invite):
     result = True
     dispatcher = self.__loader.getDispatcher()
     if dispatcher:
         prbFunctional = dispatcher.getPrbFunctional()
         unitFunctional = dispatcher.getUnitFunctional()
         if prbFunctional and prbFunctional.hasLockedState() or unitFunctional and unitFunctional.hasLockedState():
             result = False
     peripheryID = invite.peripheryID
     if result and g_lobbyContext.isAnotherPeriphery(peripheryID):
         result = g_lobbyContext.isPeripheryAvailable(peripheryID)
     return result
Exemplo n.º 14
0
 def canAcceptInvite(self, invite):
     result = True
     dispatcher = self.__loader.getDispatcher()
     if dispatcher:
         prbFunctional = dispatcher.getPrbFunctional()
         unitFunctional = dispatcher.getUnitFunctional()
         if prbFunctional and prbFunctional.hasLockedState() or unitFunctional and unitFunctional.hasLockedState():
             result = False
     peripheryID = invite.peripheryID
     if result and g_lobbyContext.isAnotherPeriphery(peripheryID):
         result = g_lobbyContext.isPeripheryAvailable(peripheryID)
     return result
Exemplo n.º 15
0
 def __handleCreateOrJoinFortBattle(self,
                                    peripheryID,
                                    battleID,
                                    slotIndex=-1):
     if g_lobbyContext.isAnotherPeriphery(peripheryID):
         if g_lobbyContext.isPeripheryAvailable(peripheryID):
             self.__requestToReloginAndCreateOrJoinFortBattle(
                 peripheryID, battleID, slotIndex)
         else:
             SystemMessages.pushI18nMessage(
                 '#system_messages:periphery/errors/isNotAvailable',
                 type=SystemMessages.SM_TYPE.Error)
     else:
         self.__requestToCreateOrJoinFortBattle(battleID, slotIndex)
Exemplo n.º 16
0
 def onJoinRally(self, rallyId, slotIndex, peripheryID):
     ctx = JoinUnitCtx(rallyId,
                       PREBATTLE_TYPE.SORTIE,
                       slotIndex,
                       waitingID='prebattle/join')
     if g_lobbyContext.isAnotherPeriphery(peripheryID):
         if g_lobbyContext.isPeripheryAvailable(peripheryID):
             self.__requestToReloginAndJoinSortie(peripheryID, ctx)
         else:
             SystemMessages.pushI18nMessage(
                 '#system_messages:periphery/errors/isNotAvailable',
                 type=SystemMessages.SM_TYPE.Error)
     else:
         self.__requestToJoinSortie(ctx)
Exemplo n.º 17
0
 def onJoinRally(self, rallyId, slotIndex, peripheryID):
     if self.prbEntity.getEntityType() == PREBATTLE_TYPE.CLUBS:
         if self.clubsState.getStateID() == CLIENT_CLUB_STATE.SENT_APP:
             if self.clubsState.getClubDbID() == rallyId:
                 self.__requestToCancelClub(rallyId)
         elif self.clubsState.getStateID() == CLIENT_CLUB_STATE.NO_CLUB:
             self.__requestToJoinClub(rallyId)
     else:
         ctx = JoinUnitCtx(rallyId, self.prbEntity.getEntityType(), slotIndex, waitingID='prebattle/join')
         if g_lobbyContext.isAnotherPeriphery(peripheryID):
             if g_lobbyContext.isPeripheryAvailable(peripheryID):
                 self.__requestToReloginAndJoin(peripheryID, ctx)
             else:
                 SystemMessages.pushI18nMessage('#system_messages:periphery/errors/isNotAvailable', type=SystemMessages.SM_TYPE.Error)
         else:
             self.__requestToJoin(ctx)
Exemplo n.º 18
0
 def onJoinRally(self, rallyId, slotIndex, peripheryID):
     if self.unitFunctional.getEntityType() == PREBATTLE_TYPE.CLUBS:
         if self.clubsState.getStateID() == CLIENT_CLUB_STATE.SENT_APP:
             if self.clubsState.getClubDbID() == rallyId:
                 self.__requestToCancelClub(rallyId)
         elif self.clubsState.getStateID() == CLIENT_CLUB_STATE.NO_CLUB:
             self.__requestToJoinClub(rallyId)
     else:
         ctx = unit_ctx.JoinUnitCtx(rallyId, self.getPrbType(), slotIndex, waitingID='prebattle/join')
         if g_lobbyContext.isAnotherPeriphery(peripheryID):
             if g_lobbyContext.isPeripheryAvailable(peripheryID):
                 self.__requestToReloginAndJoin(peripheryID, ctx)
             else:
                 SystemMessages.pushI18nMessage('#system_messages:periphery/errors/isNotAvailable', type=SystemMessages.SM_TYPE.Error)
         else:
             self.__requestToJoin(ctx)
Exemplo n.º 19
0
def getAcceptNotAllowedText(prbType, peripheryID, isInviteActive = True, isAlreadyJoined = False):
    key, kwargs = None, {}
    isAnotherPeriphery = g_lobbyContext.isAnotherPeriphery(peripheryID)
    if isInviteActive:
        if isAlreadyJoined:
            key = I18N_INVITES.invites_prebattle_alreadyjoined(getPrbName(prbType))
        elif isAnotherPeriphery:
            host = g_lobbyContext.getPeripheryName(peripheryID)
            if host:
                key = I18N_INVITES.invites_prebattle_acceptnotallowed('otherPeriphery')
                kwargs = {'host': host}
            else:
                key = I18N_INVITES.invites_prebattle_acceptnotallowed('undefinedPeriphery')
    if key:
        text = i18n.makeString(key, **kwargs)
    else:
        text = ''
    return text
Exemplo n.º 20
0
def getAcceptNotAllowedText(prbType, peripheryID, isInviteActive = True, isAlreadyJoined = False):
    key, kwargs = None, {}
    isAnotherPeriphery = g_lobbyContext.isAnotherPeriphery(peripheryID)
    if isInviteActive:
        if isAlreadyJoined:
            key = I18N_INVITES.invites_prebattle_alreadyjoined(getPrbName(prbType))
        elif isAnotherPeriphery:
            host = g_lobbyContext.getPeripheryName(peripheryID)
            if host:
                key = I18N_INVITES.invites_prebattle_acceptnotallowed('otherPeriphery')
                kwargs = {'host': host}
            else:
                key = I18N_INVITES.invites_prebattle_acceptnotallowed('undefinedPeriphery')
    if key:
        text = i18n.makeString(key, **kwargs)
    else:
        text = ''
    return text
Exemplo n.º 21
0
 def join(self, ctx, callback = None):
     prbID = ctx.getID()
     if not AutoInvitesNotifier.hasInvite(prbID):
         SystemMessages.pushI18nMessage(I18N_SYSTEM_MESSAGES.ARENA_START_ERRORS_JOIN_NOT_FOUND, type=SystemMessages.SM_TYPE.Error)
         if callback:
             callback(False)
         return
     peripheryID = AutoInvitesNotifier.getInvite(prbID).peripheryID
     if g_lobbyContext.isAnotherPeriphery(peripheryID):
         hostName = g_lobbyContext.getPeripheryName(peripheryID)
         if hostName:
             message = i18n.makeString(I18N_SYSTEM_MESSAGES.ARENA_START_ERRORS_JOIN_WRONG_PERIPHERY_KNOWN, hostName)
         else:
             message = i18n.makeString(I18N_SYSTEM_MESSAGES.ARENA_START_ERRORS_JOIN_WRONG_PERIPHERY_UNKNOWN)
         SystemMessages.pushMessage(message, type=SystemMessages.SM_TYPE.Warning)
         if callback:
             callback(False)
     else:
         super(BattleSessionEntry, self).join(ctx, callback)
Exemplo n.º 22
0
def tryToConnectClubBattle(club, joinTime):
    from gui import DialogsInterface, SystemMessages
    from gui.prb_control.dispatcher import g_prbLoader
    from gui.Scaleform.daapi.view.dialogs.rally_dialog_meta import UnitConfirmDialogMeta
    yield lambda callback: callback(None)
    if not club:
        LOG_ERROR('Invalid club info to join unit', club, joinTime)
        return
    clubDbID = club.getClubDbID()
    if club.hasActiveUnit():
        peripheryID = club.getUnitInfo().peripheryID
        if g_lobbyContext.isAnotherPeriphery(peripheryID):
            if g_lobbyContext.isPeripheryAvailable(peripheryID):
                result = yield DialogsInterface.showDialog(UnitConfirmDialogMeta(PREBATTLE_TYPE.CLUBS, 'changePeriphery', messageCtx={'host': g_lobbyContext.getPeripheryName(peripheryID)}))
                if result:
                    g_prbLoader.getPeripheriesHandler().join(peripheryID, JoinClubBattleCtx(clubDbID, joinTime, allowDelay=True, waitingID='clubs/joinClubUnit'))
            else:
                SystemMessages.pushI18nMessage('#system_messages:periphery/errors/isNotAvailable', type=SystemMessages.SM_TYPE.Error)
            return
    yield g_prbLoader.getDispatcher().join(JoinClubBattleCtx(clubDbID, joinTime, waitingID='clubs/joinClubUnit'))
Exemplo n.º 23
0
 def join(self, peripheryID, ctx, postActions=None, finishActions=None):
     """
     Join to prebattle/unit that is on another periphery.
     Args:
         peripheryID: periphery identifier
         ctx: join request context
         postActions: post actions chain
         finishActions: finish actions chain
     """
     if not g_lobbyContext.isAnotherPeriphery(peripheryID):
         LOG_ERROR('Player is in given periphery', peripheryID)
         return
     else:
         if postActions:
             if isinstance(postActions, types.ListType):
                 actionsList = postActions
             else:
                 LOG_ERROR('Argument "postActions" is invalid', postActions)
                 return
         else:
             actionsList = []
         actionsList.extend([
             actions.DisconnectFromPeriphery(),
             actions.ConnectToPeriphery(peripheryID), self.__enableAction
         ])
         if finishActions:
             if isinstance(finishActions, types.ListType):
                 actionsList.extend(finishActions)
             else:
                 LOG_ERROR('Argument "finishActions" is invalid',
                           finishActions)
                 return
         self.__joinCtx = ctx
         if self.__joinChain is not None:
             self.__joinChain.onStopped -= self.__onJoinChainStopped
             self.__joinChain.stop()
         self.__enableAction.inactivate()
         self.__joinChain = actions.ActionsChain(actionsList)
         self.__joinChain.onStopped += self.__onJoinChainStopped
         self.__joinChain.start()
         return
Exemplo n.º 24
0
 def requestToJoinTeam(self, prbID, prbType):
     item = self.__listRequester.getItem(prbID)
     if g_lobbyContext.isAnotherPeriphery(item.peripheryID):
         self.fireEvent(events.LoadViewEvent(PREBATTLE_ALIASES.AUTO_INVITE_WINDOW_PY, ctx={'prbID': prbID}), scope=EVENT_BUS_SCOPE.LOBBY)
     else:
         self.__requestToJoin(prbID, prbType)