def changeComment(self, ctx, callback=None): if ctx.getRequestType() != REQUEST_TYPE.CHANGE_COMMENT: LOG_ERROR('Invalid context for request changeComment', ctx) if callback: callback(False) return if not ctx.isCommentChanged(self._settings): if callback: callback(False) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_SETTINGS): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage( REQUEST_TYPE.CHANGE_SETTINGS), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return pPermissions = self.getPermissions() if not pPermissions.canChangeComment(): LOG_ERROR('Player can not change comment', pPermissions) if callback: callback(False) return ctx.startProcessing(callback) BigWorld.player().prb_changeComment(ctx.getComment(), ctx.onResponseReceived) setRequestCoolDown(REQUEST_TYPE.CHANGE_SETTINGS)
def changeDivision(self, ctx, callback = None): if ctx.getRequestType() != REQUEST_TYPE.CHANGE_DIVISION: LOG_ERROR('Invalid context for request changeDivision', ctx) if callback: callback(False) return if not ctx.isDivisionChanged(self._settings): if callback: callback(False) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_SETTINGS): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.CHANGE_SETTINGS), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return if ctx.getDivision() not in PREBATTLE_COMPANY_DIVISION.RANGE: LOG_ERROR('Division is invalid', ctx) if callback: callback(False) return if self.getTeamState().isInQueue(): LOG_ERROR('Team is ready or locked', ctx) if callback: callback(False) return pPermissions = self.getPermissions() if not pPermissions.canChangeDivision(): LOG_ERROR('Player can not change division', pPermissions) if callback: callback(False) return ctx.startProcessing(callback) BigWorld.player().prb_changeDivision(ctx.getDivision(), ctx.onResponseReceived) setRequestCoolDown(REQUEST_TYPE.CHANGE_SETTINGS)
def _setTeamNotReady(self, ctx, callback = None): if info.isRequestInCoolDown(REQUEST_TYPE.SET_TEAM_STATE): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.SET_TEAM_STATE, REQUEST_COOLDOWN.PREBATTLE_TEAM_NOT_READY), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return ctx.startProcessing(callback) BigWorld.player().prb_teamNotReady(ctx.getTeam(), ctx.onResponseReceived) info.setRequestCoolDown(REQUEST_TYPE.SET_TEAM_STATE, coolDown=REQUEST_COOLDOWN.PREBATTLE_TEAM_NOT_READY)
def request(self, ctx = None): if isRequestInCoolDown(REQUEST_TYPE.PREBATTLES_LIST): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.PREBATTLES_LIST), type=SystemMessages.SM_TYPE.Error) return LOG_DEBUG('Request prebattle', ctx) setRequestCoolDown(REQUEST_TYPE.PREBATTLES_LIST) if ctx.byDivision(): BigWorld.player().requestPrebattlesByDivision(ctx.isNotInBattle, ctx.division) elif ctx.byName(): BigWorld.player().requestPrebattlesByName(PREBATTLE_TYPE.COMPANY, ctx.isNotInBattle, ctx.creatorMask) else: BigWorld.player().requestPrebattles(PREBATTLE_TYPE.COMPANY, PREBATTLE_CACHE_KEY.CREATE_TIME, ctx.isNotInBattle, -50, 0)
def swapTeams(self, ctx, callback = None): if info.isRequestInCoolDown(REQUEST_TYPE.SWAP_TEAMS): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.SWAP_TEAMS), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return pPermissions = self.getPermissions() if self.getPermissions().canChangePlayerTeam(): ctx.startProcessing(callback) BigWorld.player().prb_swapTeams(ctx.onResponseReceived) info.setRequestCoolDown(REQUEST_TYPE.SWAP_TEAMS) else: LOG_ERROR('Player can not swap teams', pPermissions) if callback: callback(False)
def _setPlayerNotReady(self, ctx, callback = None): if info.isRequestInCoolDown(REQUEST_TYPE.SET_PLAYER_STATE): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.SET_PLAYER_STATE, REQUEST_COOLDOWN.PREBATTLE_NOT_READY), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return rosterKey = self.getRosterKey() team, assigned = decodeRoster(rosterKey) if assigned and self.getTeamState(team=team).isInQueue(): LOG_ERROR('Account assigned and team is ready or locked') if callback: callback(False) return ctx.startProcessing(callback) BigWorld.player().prb_notReady(PREBATTLE_ACCOUNT_STATE.NOT_READY, ctx.onResponseReceived) info.setRequestCoolDown(REQUEST_TYPE.SET_PLAYER_STATE, coolDown=REQUEST_COOLDOWN.PREBATTLE_NOT_READY)
def sendInvites(self, ctx, callback = None): if info.isRequestInCoolDown(REQUEST_TYPE.SEND_INVITE): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.SEND_INVITE), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return pPermissions = self.getPermissions() if self.getPermissions().canSendInvite(): BigWorld.player().prb_sendInvites(ctx.getDatabaseIDs(), ctx.getComment()) info.setRequestCoolDown(REQUEST_TYPE.SEND_INVITE, coolDown=REQUEST_COOLDOWN.PREBATTLE_INVITES) if callback: callback(True) else: LOG_ERROR('Player can not send invite', pPermissions) if callback: callback(False)
def request(self, ctx=None): if isRequestInCoolDown(REQUEST_TYPE.PREBATTLES_LIST): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage( REQUEST_TYPE.PREBATTLES_LIST), type=SystemMessages.SM_TYPE.Error) return LOG_DEBUG('Request prebattle', ctx) setRequestCoolDown(REQUEST_TYPE.PREBATTLES_LIST) if ctx.byDivision(): BigWorld.player().requestPrebattlesByDivision( ctx.isNotInBattle, ctx.division) elif ctx.byName(): BigWorld.player().requestPrebattlesByName(PREBATTLE_TYPE.COMPANY, ctx.isNotInBattle, ctx.creatorMask) else: BigWorld.player().requestPrebattles( PREBATTLE_TYPE.COMPANY, PREBATTLE_CACHE_KEY.CREATE_TIME, ctx.isNotInBattle, -50, 0)
def changeArenaVoip(self, ctx, callback = None): if ctx.getChannels() == self._settings[PREBATTLE_SETTING_NAME.ARENA_VOIP_CHANNELS]: if callback: callback(True) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_ARENA_VOIP): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.CHANGE_ARENA_VOIP), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return pPermissions = self.getPermissions() if pPermissions.canChangeArenaVOIP(): ctx.startProcessing(callback=callback) BigWorld.player().prb_changeArenaVoip(ctx.getChannels(), ctx.onResponseReceived) setRequestCoolDown(REQUEST_TYPE.CHANGE_ARENA_VOIP) else: LOG_ERROR('Player can not change arena VOIP', pPermissions) if callback: callback(False)
def changeArenaVoip(self, ctx, callback=None): if ctx.getChannels() == self._settings[ PREBATTLE_SETTING_NAME.ARENA_VOIP_CHANNELS]: if callback: callback(True) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_ARENA_VOIP): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage( REQUEST_TYPE.CHANGE_ARENA_VOIP), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return pPermissions = self.getPermissions() if pPermissions.canChangeArenaVOIP(): ctx.startProcessing(callback=callback) BigWorld.player().prb_changeArenaVoip(ctx.getChannels(), ctx.onResponseReceived) setRequestCoolDown(REQUEST_TYPE.CHANGE_ARENA_VOIP) else: LOG_ERROR('Player can not change arena VOIP', pPermissions) if callback: callback(False)
def changeDivision(self, ctx, callback=None): if ctx.getRequestType() != REQUEST_TYPE.CHANGE_DIVISION: LOG_ERROR('Invalid context for request changeDivision', ctx) if callback: callback(False) return if not ctx.isDivisionChanged(self._settings): if callback: callback(False) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_SETTINGS): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage( REQUEST_TYPE.CHANGE_SETTINGS), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return if ctx.getDivision() not in PREBATTLE_COMPANY_DIVISION.RANGE: LOG_ERROR('Division is invalid', ctx) if callback: callback(False) return if self.getTeamState().isInQueue(): LOG_ERROR('Team is ready or locked', ctx) if callback: callback(False) return pPermissions = self.getPermissions() if not pPermissions.canChangeDivision(): LOG_ERROR('Player can not change division', pPermissions) if callback: callback(False) return ctx.startProcessing(callback) BigWorld.player().prb_changeDivision(ctx.getDivision(), ctx.onResponseReceived) setRequestCoolDown(REQUEST_TYPE.CHANGE_SETTINGS)
def changeComment(self, ctx, callback = None): if ctx.getRequestType() != REQUEST_TYPE.CHANGE_COMMENT: LOG_ERROR('Invalid context for request changeComment', ctx) if callback: callback(False) return if not ctx.isCommentChanged(self._settings): if callback: callback(False) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_SETTINGS): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.CHANGE_SETTINGS), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return pPermissions = self.getPermissions() if not pPermissions.canChangeComment(): LOG_ERROR('Player can not change comment', pPermissions) if callback: callback(False) return ctx.startProcessing(callback) BigWorld.player().prb_changeComment(ctx.getComment(), ctx.onResponseReceived) setRequestCoolDown(REQUEST_TYPE.CHANGE_SETTINGS)
def changeSettings(self, ctx, callback=None): if ctx.getRequestType() != REQUEST_TYPE.CHANGE_SETTINGS: LOG_ERROR('Invalid context for request changeSettings', ctx) if callback: callback(False) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_SETTINGS): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage( REQUEST_TYPE.CHANGE_SETTINGS), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return player = BigWorld.player() pPermissions = self.getPermissions() self.__settingRecords = [] rejected = False isOpenedChanged = ctx.isOpenedChanged(self._settings) isCommentChanged = ctx.isCommentChanged(self._settings) isArenaTypeIDChanged = ctx.isArenaTypeIDChanged(self._settings) isRoundLenChanged = ctx.isRoundLenChanged(self._settings) if isOpenedChanged: if pPermissions.canMakeOpenedClosed(): self.__settingRecords.append('isOpened') else: LOG_ERROR('Player can not make training opened/closed', pPermissions) rejected = True if isCommentChanged: if pPermissions.canChangeComment(): self.__settingRecords.append('comment') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if isArenaTypeIDChanged: if pPermissions.canChangeArena(): self.__settingRecords.append('arenaTypeID') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if isRoundLenChanged: if pPermissions.canChangeArena(): self.__settingRecords.append('roundLength') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if rejected: self.__settingRecords = [] if callback: callback(False) return if not len(self.__settingRecords): if callback: callback(False) return ctx.startProcessing(callback=callback) if isOpenedChanged: player.prb_changeOpenStatus( ctx.isOpened(), partial(self.__onSettingChanged, record='isOpened', callback=ctx.stopProcessing)) if isCommentChanged: player.prb_changeComment( ctx.getComment(), partial(self.__onSettingChanged, record='comment', callback=ctx.stopProcessing)) if isArenaTypeIDChanged: player.prb_changeArena( ctx.getArenaTypeID(), partial(self.__onSettingChanged, record='arenaTypeID', callback=ctx.stopProcessing)) if isRoundLenChanged: player.prb_changeRoundLength( ctx.getRoundLen(), partial(self.__onSettingChanged, record='roundLength', callback=ctx.stopProcessing)) if not len(self.__settingRecords): if callback: callback(False) else: setRequestCoolDown(REQUEST_TYPE.CHANGE_SETTINGS)
def changeSettings(self, ctx, callback = None): if ctx.getRequestType() != REQUEST_TYPE.CHANGE_SETTINGS: LOG_ERROR('Invalid context for request changeSettings', ctx) if callback: callback(False) return if isRequestInCoolDown(REQUEST_TYPE.CHANGE_SETTINGS): SystemMessages.pushMessage(messages.getRequestInCoolDownMessage(REQUEST_TYPE.CHANGE_SETTINGS), type=SystemMessages.SM_TYPE.Error) if callback: callback(False) return player = BigWorld.player() pPermissions = self.getPermissions() self.__settingRecords = [] rejected = False isOpenedChanged = ctx.isOpenedChanged(self._settings) isCommentChanged = ctx.isCommentChanged(self._settings) isArenaTypeIDChanged = ctx.isArenaTypeIDChanged(self._settings) isRoundLenChanged = ctx.isRoundLenChanged(self._settings) if isOpenedChanged: if pPermissions.canMakeOpenedClosed(): self.__settingRecords.append('isOpened') else: LOG_ERROR('Player can not make training opened/closed', pPermissions) rejected = True if isCommentChanged: if pPermissions.canChangeComment(): self.__settingRecords.append('comment') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if isArenaTypeIDChanged: if pPermissions.canChangeArena(): self.__settingRecords.append('arenaTypeID') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if isRoundLenChanged: if pPermissions.canChangeArena(): self.__settingRecords.append('roundLength') else: LOG_ERROR('Player can not change comment', pPermissions) rejected = True if rejected: self.__settingRecords = [] if callback: callback(False) return if not len(self.__settingRecords): if callback: callback(False) return ctx.startProcessing(callback=callback) if isOpenedChanged: player.prb_changeOpenStatus(ctx.isOpened(), partial(self.__onSettingChanged, record='isOpened', callback=ctx.stopProcessing)) if isCommentChanged: player.prb_changeComment(ctx.getComment(), partial(self.__onSettingChanged, record='comment', callback=ctx.stopProcessing)) if isArenaTypeIDChanged: player.prb_changeArena(ctx.getArenaTypeID(), partial(self.__onSettingChanged, record='arenaTypeID', callback=ctx.stopProcessing)) if isRoundLenChanged: player.prb_changeRoundLength(ctx.getRoundLen(), partial(self.__onSettingChanged, record='roundLength', callback=ctx.stopProcessing)) if not len(self.__settingRecords): if callback: callback(False) else: setRequestCoolDown(REQUEST_TYPE.CHANGE_SETTINGS)