@@ -16,10 +16,12 @@ def __enum(table: dict, key: str, enum: Any, default: int = 0) -> Any:
16
16
return enum (default )
17
17
try :
18
18
for i in range (100000 ):
19
- if str (enum (i )).split ('.' )[- 1 ].lower () == table [key ].lower ():
19
+ if str (enum (i )).split ("." )[- 1 ].lower () == table [key ].lower ():
20
20
return enum (i )
21
21
except ValueError :
22
- raise ConfigParsingException (f"Invalid value { repr (table [key ])} for key '{ key } '." )
22
+ raise ConfigParsingException (
23
+ f"Invalid value { repr (table [key ])} for key '{ key } '."
24
+ )
23
25
24
26
25
27
def __str (table : dict , key : str , default : str = "" ) -> str :
@@ -51,9 +53,9 @@ def __table(table: dict, key: str) -> dict:
51
53
52
54
53
55
def __team (table : dict ) -> int :
54
- if ' team' not in table :
56
+ if " team" not in table :
55
57
return 0
56
- v = table [' team' ]
58
+ v = table [" team" ]
57
59
if isinstance (v , str ):
58
60
if v .lower () == "blue" :
59
61
return 0
@@ -62,7 +64,9 @@ def __team(table: dict) -> int:
62
64
if isinstance (v , int ):
63
65
if 0 <= v <= 1 :
64
66
return v
65
- raise ConfigParsingException (f"'team' has value { repr (v )} . Expected a 0, 1, \" blue\" , or \" orange\" ." )
67
+ raise ConfigParsingException (
68
+ f'\' team\' has value { repr (v )} . Expected a 0, 1, "blue", or "orange".'
69
+ )
66
70
67
71
68
72
def load_match_config (config_path : Path | str ) -> flat .MatchConfiguration :
@@ -83,7 +87,9 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
83
87
name = __str (car_table , "name" )
84
88
team = __team (car_table )
85
89
loadout_file = __str (car_table , "loadout_file" ) or None
86
- skill = __enum (car_table , "skill" , flat .PsyonixSkill , int (flat .PsyonixSkill .AllStar ))
90
+ skill = __enum (
91
+ car_table , "skill" , flat .PsyonixSkill , int (flat .PsyonixSkill .AllStar )
92
+ )
87
93
variant = __str (car_table , "type" , "rlbot" ).lower ()
88
94
89
95
match variant :
@@ -97,14 +103,16 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
97
103
logger .warning ("PartyMember player type is not supported yet." )
98
104
variety , use_config = flat .PartyMember , False
99
105
case t :
100
- raise ConfigParsingException (f"Invalid player type { repr (t )} for player { len (players )} ." )
106
+ raise ConfigParsingException (
107
+ f"Invalid player type { repr (t )} for player { len (players )} ."
108
+ )
101
109
102
110
if use_config and car_config :
103
111
abs_config_path = (config_path .parent / car_config ).resolve ()
104
- players .append (load_player_config (abs_config_path , variety , team , name , loadout_file ))
112
+ players .append (load_player_config (abs_config_path , variety , team , name , loadout_file )) # type: ignore
105
113
else :
106
114
loadout = load_player_loadout (loadout_file , team ) if loadout_file else None
107
- players .append (flat .PlayerConfiguration (variety , name , team , loadout = loadout ))
115
+ players .append (flat .PlayerConfiguration (variety , name , team , loadout = loadout )) # type: ignore
108
116
109
117
scripts = []
110
118
for script_table in config .get ("scripts" , []):
@@ -121,14 +129,20 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
121
129
overtime = __enum (mutator_table , "overtime" , flat .OvertimeMutator ),
122
130
series_length = __enum (mutator_table , "series_length" , flat .SeriesLengthMutator ),
123
131
game_speed = __enum (mutator_table , "game_speed" , flat .GameSpeedMutator ),
124
- ball_max_speed = __enum (mutator_table , "ball_max_speed" , flat .BallMaxSpeedMutator ),
132
+ ball_max_speed = __enum (
133
+ mutator_table , "ball_max_speed" , flat .BallMaxSpeedMutator
134
+ ),
125
135
ball_type = __enum (mutator_table , "ball_type" , flat .BallTypeMutator ),
126
136
ball_weight = __enum (mutator_table , "ball_weight" , flat .BallWeightMutator ),
127
137
ball_size = __enum (mutator_table , "ball_size" , flat .BallSizeMutator ),
128
- ball_bounciness = __enum (mutator_table , "ball_bounciness" , flat .BallBouncinessMutator ),
138
+ ball_bounciness = __enum (
139
+ mutator_table , "ball_bounciness" , flat .BallBouncinessMutator
140
+ ),
129
141
boost_amount = __enum (mutator_table , "boost_amount" , flat .BoostAmountMutator ),
130
142
rumble = __enum (mutator_table , "rumble" , flat .RumbleMutator ),
131
- boost_strength = __enum (mutator_table , "boost_strength" , flat .BoostStrengthMutator ),
143
+ boost_strength = __enum (
144
+ mutator_table , "boost_strength" , flat .BoostStrengthMutator
145
+ ),
132
146
gravity = __enum (mutator_table , "gravity" , flat .GravityMutator ),
133
147
demolish = __enum (mutator_table , "demolish" , flat .DemolishMutator ),
134
148
respawn_time = __enum (mutator_table , "respawn_time" , flat .RespawnTimeMutator ),
@@ -148,7 +162,9 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
148
162
skip_replays = __bool (match_table , "skip_replays" ),
149
163
instant_start = __bool (match_table , "instant_start" ),
150
164
mutators = mutators ,
151
- existing_match_behavior = __enum (match_table , "existing_match_behavior" , flat .ExistingMatchBehavior ),
165
+ existing_match_behavior = __enum (
166
+ match_table , "existing_match_behavior" , flat .ExistingMatchBehavior
167
+ ),
152
168
enable_rendering = __bool (match_table , "enable_rendering" ),
153
169
enable_state_setting = __bool (match_table , "enable_state_setting" ),
154
170
freeplay = __bool (match_table , "freeplay" ),
@@ -196,8 +212,11 @@ def load_player_loadout(path: Path | str, team: int) -> flat.PlayerLoadout:
196
212
197
213
198
214
def load_player_config (
199
- path : Path | str , type : flat .CustomBot | flat .Psyonix , team : int ,
200
- name_override : str | None = None , loadout_override : Path | str | None = None ,
215
+ path : Path | str ,
216
+ type : flat .CustomBot | flat .Psyonix ,
217
+ team : int ,
218
+ name_override : str | None = None ,
219
+ loadout_override : Path | str | None = None ,
201
220
) -> flat .PlayerConfiguration :
202
221
"""
203
222
Reads the bot toml file at the provided path and
@@ -217,9 +236,15 @@ def load_player_config(
217
236
if CURRENT_OS == OS .LINUX and "run_command_linux" in settings :
218
237
run_command = __str (settings , "run_command_linux" )
219
238
220
- loadout_path = path .parent / Path (__str (settings , "loadout_file" )) if "loadout_file" in settings else None
239
+ loadout_path = (
240
+ path .parent / Path (__str (settings , "loadout_file" ))
241
+ if "loadout_file" in settings
242
+ else None
243
+ )
221
244
loadout_path = loadout_override or loadout_path
222
- loadout = load_player_loadout (loadout_path , team ) if loadout_path is not None else None
245
+ loadout = (
246
+ load_player_loadout (loadout_path , team ) if loadout_path is not None else None
247
+ )
223
248
224
249
return flat .PlayerConfiguration (
225
250
type ,
0 commit comments