def _on_max_public_party_size_minus_press(self) -> None: val = _ba.get_public_party_max_size() val -= 1 if val < 1: val = 1 _ba.set_public_party_max_size(val) ba.textwidget(edit=self._host_max_party_size_value, text=str(val))
def _config_server() -> None: """Apply server config changes that can take effect immediately. (party name, etc) """ config = copy.deepcopy(_ba.app.server_config) # FIXME: Should make a proper low level config entry for this or # else not store in in app.config. Probably shouldn't be going through # the app config for this anyway since it should just be for this run. _ba.app.config['Auto Balance Teams'] = (config.get('auto_balance_teams', True)) _ba.set_public_party_max_size(config.get('max_party_size', 9)) _ba.set_public_party_name(config.get('party_name', 'party')) _ba.set_public_party_stats_url(config.get('stats_url', '')) # Call set-enabled last (will push state). _ba.set_public_party_enabled(config.get('party_is_public', True)) if not _ba.app.run_server_first_run: print('server config updated.') # FIXME: We could avoid setting this as dirty if the only changes have # been ones here we can apply immediately. Could reduce cases where # players have to rejoin. _ba.app.server_config_dirty = True
def _launch_server_session(self) -> None: """Kick off a host-session based on the current server config.""" app = _ba.app appcfg = app.config sessiontype = self._get_session_type() if _ba.get_account_state() != 'signed_in': print('WARNING: launch_server_session() expects to run ' 'with a signed in server account') if self._first_run: curtimestr = time.strftime('%c') _ba.log( f'{Clr.BLD}{Clr.BLU}{_ba.appnameupper()} {app.version}' f' ({app.build_number})' f' entering server-mode {curtimestr}{Clr.RST}', to_server=False) if sessiontype is FreeForAllSession: appcfg['Free-for-All Playlist Selection'] = self._playlist_name appcfg['Free-for-All Playlist Randomize'] = ( self._config.playlist_shuffle) elif sessiontype is DualTeamSession: appcfg['Team Tournament Playlist Selection'] = self._playlist_name appcfg['Team Tournament Playlist Randomize'] = ( self._config.playlist_shuffle) else: raise RuntimeError(f'Unknown session type {sessiontype}') app.teams_series_length = self._config.teams_series_length app.ffa_series_length = self._config.ffa_series_length _ba.set_authenticate_clients(self._config.authenticate_clients) _ba.set_enable_default_kick_voting( self._config.enable_default_kick_voting) _ba.set_admins(self._config.admins) # Call set-enabled last (will push state to the cloud). _ba.set_public_party_max_size(self._config.max_party_size) _ba.set_public_party_name(self._config.party_name) _ba.set_public_party_stats_url(self._config.stats_url) _ba.set_public_party_enabled(self._config.party_is_public) # And here.. we.. go. if self._config.stress_test_players is not None: # Special case: run a stress test. from ba.internal import run_stress_test run_stress_test(playlist_type='Random', playlist_name='__default__', player_count=self._config.stress_test_players, round_duration=30) else: _ba.new_host_session(sessiontype) # Run an access check if we're trying to make a public party. if not self._ran_access_check and self._config.party_is_public: self._run_access_check() self._ran_access_check = True
def _launch_server_session(self) -> None: """Kick off a host-session based on the current server config.""" app = _ba.app appcfg = app.config sessiontype = self._get_session_type() if _ba.get_account_state() != 'signed_in': print('WARNING: launch_server_session() expects to run ' 'with a signed in server account') if self._first_run: curtimestr = time.strftime('%c') print(f'{Clr.BLD}{Clr.BLU}BallisticaCore {app.version}' f' ({app.build_number})' f' entering server-mode {curtimestr}{Clr.RST}') if sessiontype is FreeForAllSession: appcfg['Free-for-All Playlist Selection'] = self._playlist_name appcfg['Free-for-All Playlist Randomize'] = ( self._config.playlist_shuffle) elif sessiontype is DualTeamSession: appcfg['Team Tournament Playlist Selection'] = self._playlist_name appcfg['Team Tournament Playlist Randomize'] = ( self._config.playlist_shuffle) else: raise RuntimeError(f'Unknown session type {sessiontype}') app.teams_series_length = self._config.teams_series_length app.ffa_series_length = self._config.ffa_series_length _ba.set_authenticate_clients(self._config.authenticate_clients) _ba.set_enable_default_kick_voting( self._config.enable_default_kick_voting) _ba.set_admins(self._config.admins) # Call set-enabled last (will push state to the cloud). _ba.set_public_party_max_size(self._config.max_party_size) _ba.set_public_party_name(self._config.party_name) _ba.set_public_party_stats_url(self._config.stats_url) _ba.set_public_party_enabled(self._config.party_is_public) # And here we go. _ba.new_host_session(sessiontype) if not self._ran_access_check: self._run_access_check() self._ran_access_check = True
def changepartysize(arguments): if len(arguments) == 0: _ba.chatmessage("enter number") else: _ba.set_public_party_max_size(int(arguments[0]))
def _launch_server_session(self) -> None: """Kick off a host-session based on the current server config.""" # pylint: disable=too-many-branches app = _ba.app appcfg = app.config sessiontype = self._get_session_type() if _ba.get_v1_account_state() != 'signed_in': print('WARNING: launch_server_session() expects to run ' 'with a signed in server account') # If we didn't fetch a playlist but there's an inline one in the # server-config, pull it in to the game config and use it. if (self._config.playlist_code is None and self._config.playlist_inline is not None): self._playlist_name = 'ServerModePlaylist' if sessiontype is FreeForAllSession: ptypename = 'Free-for-All' elif sessiontype is DualTeamSession: ptypename = 'Team Tournament' elif sessiontype is CoopSession: ptypename = 'Coop' else: raise RuntimeError(f'Unknown session type {sessiontype}') # Need to add this in a transaction instead of just setting # it directly or it will get overwritten by the master-server. _ba.add_transaction({ 'type': 'ADD_PLAYLIST', 'playlistType': ptypename, 'playlistName': self._playlist_name, 'playlist': self._config.playlist_inline }) _ba.run_transactions() if self._first_run: curtimestr = time.strftime('%c') _ba.log( f'{Clr.BLD}{Clr.BLU}{_ba.appnameupper()} {app.version}' f' ({app.build_number})' f' entering server-mode {curtimestr}{Clr.RST}', to_server=False) if sessiontype is FreeForAllSession: appcfg['Free-for-All Playlist Selection'] = self._playlist_name appcfg['Free-for-All Playlist Randomize'] = ( self._config.playlist_shuffle) elif sessiontype is DualTeamSession: appcfg['Team Tournament Playlist Selection'] = self._playlist_name appcfg['Team Tournament Playlist Randomize'] = ( self._config.playlist_shuffle) elif sessiontype is CoopSession: app.coop_session_args = { 'campaign': self._config.coop_campaign, 'level': self._config.coop_level, } else: raise RuntimeError(f'Unknown session type {sessiontype}') app.teams_series_length = self._config.teams_series_length app.ffa_series_length = self._config.ffa_series_length _ba.set_authenticate_clients(self._config.authenticate_clients) _ba.set_enable_default_kick_voting( self._config.enable_default_kick_voting) _ba.set_admins(self._config.admins) # Call set-enabled last (will push state to the cloud). _ba.set_public_party_max_size(self._config.max_party_size) _ba.set_public_party_name(self._config.party_name) _ba.set_public_party_stats_url(self._config.stats_url) _ba.set_public_party_enabled(self._config.party_is_public) # And here.. we.. go. if self._config.stress_test_players is not None: # Special case: run a stress test. from ba.internal import run_stress_test run_stress_test(playlist_type='Random', playlist_name='__default__', player_count=self._config.stress_test_players, round_duration=30) else: _ba.new_host_session(sessiontype) # Run an access check if we're trying to make a public party. if not self._ran_access_check and self._config.party_is_public: self._run_access_check() self._ran_access_check = True
def _on_max_public_party_size_minus_press(self) -> None: val = max(1, _ba.get_public_party_max_size() - 1) _ba.set_public_party_max_size(val) ba.textwidget(edit=self._host_max_party_size_value, text=str(val))