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)
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
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
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
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'))
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'))
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
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)
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)
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
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)
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'))
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
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)
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)
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)
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)
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
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)
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'))
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
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)