def start_stress_test(args: Dict[str, Any]) -> None: """(internal)""" from ba._general import Call from ba._dualteamsession import DualTeamSession from ba._freeforallsession import FreeForAllSession from ba._enums import TimeType, TimeFormat appconfig = _ba.app.config playlist_type = args['playlist_type'] if playlist_type == 'Random': if random.random() < 0.5: playlist_type = 'Teams' else: playlist_type = 'Free-For-All' _ba.screenmessage('Running Stress Test (listType="' + playlist_type + '", listName="' + args['playlist_name'] + '")...') if playlist_type == 'Teams': appconfig['Team Tournament Playlist Selection'] = args['playlist_name'] appconfig['Team Tournament Playlist Randomize'] = 1 _ba.timer(1.0, Call(_ba.pushcall, Call(_ba.new_host_session, DualTeamSession)), timetype=TimeType.REAL) else: appconfig['Free-for-All Playlist Selection'] = args['playlist_name'] appconfig['Free-for-All Playlist Randomize'] = 1 _ba.timer(1.0, Call(_ba.pushcall, Call(_ba.new_host_session, FreeForAllSession)), timetype=TimeType.REAL) _ba.set_stress_testing(True, args['player_count']) _ba.app.stress_test_reset_timer = _ba.Timer( args['round_duration'] * 1000, Call(_reset_stress_test, args), timetype=TimeType.REAL, timeformat=TimeFormat.MILLISECONDS)
def stop_stress_test() -> None: """End a running stress test.""" _ba.set_stress_testing(False, 0) try: if _ba.app.stress_test_reset_timer is not None: _ba.screenmessage('Ending stress test...', color=(1, 1, 0)) except Exception: pass _ba.app.stress_test_reset_timer = None
def _reset_stress_test(args: Dict[str, Any]) -> None: from ba._general import Call from ba._enums import TimeType _ba.set_stress_testing(False, args['player_count']) _ba.screenmessage('Resetting stress test...') session = _ba.get_foreground_host_session() assert session is not None session.end() _ba.timer(1.0, Call(start_stress_test, args), timetype=TimeType.REAL)