Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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'))
Ejemplo n.º 4
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'))
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
 def __requestToReloginAndJoinSortie(self, peripheryID, ctx):
     result = yield DialogsInterface.showDialog(
         UnitConfirmDialogMeta(
             PREBATTLE_TYPE.UNIT,
             'changePeriphery',
             messageCtx={
                 'host': g_lobbyContext.getPeripheryName(peripheryID)
             }))
     if result:
         self.prbPeripheriesHandler.join(peripheryID, ctx)
 def __requestToReloginAndJoin(self, peripheryID, ctx):
     result = yield DialogsInterface.showDialog(
         UnitConfirmDialogMeta(
             PREBATTLE_TYPE.UNIT,
             "changePeriphery",
             messageCtx={"host": g_lobbyContext.getPeripheryName(peripheryID)},
         )
     )
     if result:
         self.prbPeripheriesHandler.join(peripheryID, ctx)
Ejemplo n.º 8
0
 def __requestToReloginAndCreateOrJoinFortBattle(self,
                                                 peripheryID,
                                                 battleID,
                                                 slotIndex=-1):
     result = yield DialogsInterface.showDialog(
         UnitConfirmDialogMeta(
             PREBATTLE_TYPE.FORT_BATTLE,
             'changePeriphery',
             messageCtx={
                 'host': g_lobbyContext.getPeripheryName(peripheryID)
             }))
     if result:
         self.prbPeripheriesHandler.join(
             peripheryID,
             CreateOrJoinFortBattleCtx(battleID, slotIndex,
                                       'fort/fortBattle/createOrJoin'))
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
 def __requestToReloginAndCreateOrJoinFortBattle(self, peripheryID, battleID, slotIndex = -1):
     result = yield DialogsInterface.showDialog(UnitConfirmDialogMeta(PREBATTLE_TYPE.FORT_BATTLE, 'changePeriphery', messageCtx={'host': g_lobbyContext.getPeripheryName(peripheryID)}))
     if result:
         self.prbPeripheriesHandler.join(peripheryID, CreateOrJoinFortBattleCtx(battleID, slotIndex, 'fort/fortBattle/createOrJoin'))
Ejemplo n.º 13
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'))
Ejemplo n.º 14
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'))