def selectObserver(self, isObserver): if not isObserver: playersCount = 0 roster = self.prbEntity.getRosterKey() if roster != PREBATTLE_ROSTER.UNKNOWN and roster & PREBATTLE_ROSTER.UNASSIGNED == 0: accounts = self.prbEntity.getRosters()[roster] for account in accounts: if account.isVehicleSpecified(): vehicle = account.getVehicle() if not vehicle.isObserver: playersCount += 1 playersMaxCount = self.__getPlayersMaxCount() if playersCount >= playersMaxCount: event = CoolDownEvent() self.as_startCoolDownObserverS(event.coolDown) self.as_setObserverS(True) self._showActionErrorMessage(PREBATTLE_ERRORS.PLAYERS_LIMIT) return result = yield self.prbDispatcher.sendPrbRequest( SetPlayerObserverStateCtx( isObserver, True, waitingID='prebattle/change_user_status')) if not result: self.as_setObserverS(False) self._showActionErrorMessage()
def __currentPlayerEntered(self): if self.__currentPlayerIsOut: if self.prbEntity.storage.isObserver: yield self.prbDispatcher.sendPrbRequest( SetPlayerObserverStateCtx( isObserver=True, isReadyState=True, waitingID='prebattle/change_user_status')) else: yield self.prbDispatcher.sendPrbRequest( SetPlayerStateCtx(True, waitingID='prebattle/player_ready')) self.as_setObserverS(self.prbEntity.storage.isObserver) self.__currentPlayerIsOut = False
def __enterTrainingRoom(self, isInitial=False): if self.storage.isObserver: self.changeUserObserverStatus( SetPlayerObserverStateCtx( True, True, isInitial=isInitial, waitingID='prebattle/change_user_status'), self.__onPlayerReady) else: self.setPlayerState( SetPlayerStateCtx(True, isInitial=isInitial, waitingID='prebattle/player_ready'), self.__onPlayerReady)