@@ -94,30 +94,30 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
94
94
95
95
match variant :
96
96
case "rlbot" :
97
- variety , use_config = flat .CustomBot (), True
97
+ abs_config_path = (config_path .parent / car_config ).resolve ()
98
+ players .append (
99
+ load_player_config (abs_config_path , team , name , loadout_file )
100
+ )
98
101
case "psyonix" :
99
- variety , use_config = flat .Psyonix (skill ), True
102
+ abs_config_path = (
103
+ (config_path .parent / car_config ).resolve () if car_config else None
104
+ )
105
+ players .append (
106
+ load_psyonix_config (
107
+ team ,
108
+ skill ,
109
+ name ,
110
+ loadout_file ,
111
+ abs_config_path ,
112
+ )
113
+ )
100
114
case "human" :
101
- variety , use_config = flat .Human (), False
102
- case "partymember" :
103
- logger .warning ("PartyMember player type is not supported yet." )
104
- variety , use_config = flat .PartyMember (), False
115
+ players .append (flat .PlayerConfiguration (flat .Human (), team , 0 ))
105
116
case t :
106
117
raise ConfigParsingException (
107
118
f"Invalid player type { repr (t )} for player { len (players )} ."
108
119
)
109
120
110
- if use_config and car_config :
111
- abs_config_path = (config_path .parent / car_config ).resolve ()
112
- players .append (
113
- load_player_config (abs_config_path , variety , team , name , loadout_file ) # type: ignore
114
- )
115
- else :
116
- loadout = load_player_loadout (loadout_file , team ) if loadout_file else None
117
- players .append (
118
- flat .PlayerConfiguration (variety , name , team , loadout = loadout )
119
- )
120
-
121
121
scripts : list [flat .ScriptConfiguration ] = []
122
122
for script_table in config .get ("scripts" , []):
123
123
if script_config := __str (script_table , "config_file" ):
@@ -155,6 +155,17 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
155
155
audio = __enum (mutator_table , "audio" , flat .AudioMutator ),
156
156
)
157
157
158
+ try :
159
+ enable_rendering = (
160
+ flat .DebugRendering .OnByDefault
161
+ if __bool (match_table , "enable_rendering" )
162
+ else flat .DebugRendering .OffByDefault
163
+ )
164
+ except ConfigParsingException :
165
+ enable_rendering = __enum (
166
+ match_table , "enable_rendering" , flat .DebugRendering .AlwaysOff
167
+ )
168
+
158
169
return flat .MatchConfiguration (
159
170
launcher = __enum (rlbot_table , "launcher" , flat .Launcher ),
160
171
launcher_arg = __str (rlbot_table , "launcher_arg" ),
@@ -170,7 +181,7 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
170
181
existing_match_behavior = __enum (
171
182
match_table , "existing_match_behavior" , flat .ExistingMatchBehavior
172
183
),
173
- enable_rendering = __bool ( match_table , " enable_rendering" ) ,
184
+ enable_rendering = enable_rendering ,
174
185
enable_state_setting = __bool (match_table , "enable_state_setting" ),
175
186
freeplay = __bool (match_table , "freeplay" ),
176
187
)
@@ -217,8 +228,7 @@ def load_player_loadout(path: Path | str, team: int) -> flat.PlayerLoadout:
217
228
218
229
219
230
def load_player_config (
220
- path : Path | str | None ,
221
- type : flat .CustomBot | flat .Psyonix ,
231
+ path : Path | str ,
222
232
team : int ,
223
233
name_override : str | None = None ,
224
234
loadout_override : Path | str | None = None ,
@@ -227,20 +237,6 @@ def load_player_config(
227
237
Reads the bot toml file at the provided path and
228
238
creates a `PlayerConfiguration` of the given type for the given team.
229
239
"""
230
- if path is None :
231
- loadout = (
232
- load_player_loadout (loadout_override , team )
233
- if loadout_override is not None
234
- else None
235
- )
236
-
237
- return flat .PlayerConfiguration (
238
- type ,
239
- name_override or "" ,
240
- team ,
241
- loadout = loadout ,
242
- )
243
-
244
240
path = Path (path )
245
241
with open (path , "rb" ) as f :
246
242
config = tomllib .load (f )
@@ -266,15 +262,64 @@ def load_player_config(
266
262
)
267
263
268
264
return flat .PlayerConfiguration (
269
- type ,
270
- name_override or __str (settings , "name" ),
265
+ flat .CustomBot (
266
+ name_override or __str (settings , "name" ),
267
+ str (root_dir ),
268
+ run_command ,
269
+ loadout ,
270
+ __str (settings , "agent_id" ),
271
+ __bool (settings , "hivemind" ),
272
+ ),
273
+ team ,
274
+ 0 ,
275
+ )
276
+
277
+
278
+ def load_psyonix_config (
279
+ team : int ,
280
+ skill_level : flat .PsyonixSkill ,
281
+ name_override : str | None = None ,
282
+ loadout_override : Path | str | None = None ,
283
+ path : Path | str | None = None ,
284
+ ) -> flat .PlayerConfiguration :
285
+ """
286
+ Creates a `PlayerConfiguration` for a Psyonix bot of the given team and skill.
287
+ If a path is provided, it will be used override the default name and loadout.
288
+ """
289
+ name = name_override
290
+ loadout_path = loadout_override
291
+
292
+ # Don't parse the toml file if we have no data we need to extract,
293
+ # even if a path to a toml file is provided.
294
+ if path is not None and (name is None or loadout_path is None ):
295
+ path = Path (path )
296
+ with open (path , "rb" ) as f :
297
+ config = tomllib .load (f )
298
+
299
+ settings = __table (config , "settings" )
300
+
301
+ if name is None :
302
+ name = __str (settings , "name" )
303
+
304
+ if loadout_path is None :
305
+ loadout_path = (
306
+ path .parent / Path (__str (settings , "loadout_file" ))
307
+ if "loadout_file" in settings
308
+ else None
309
+ )
310
+
311
+ loadout = (
312
+ load_player_loadout (loadout_path , team ) if loadout_path is not None else None
313
+ )
314
+
315
+ return flat .PlayerConfiguration (
316
+ flat .PsyonixBot (
317
+ name or "" ,
318
+ loadout ,
319
+ skill_level ,
320
+ ),
271
321
team ,
272
- str (root_dir ),
273
- run_command ,
274
- loadout ,
275
322
0 ,
276
- __str (settings , "agent_id" ),
277
- __bool (settings , "hivemind" ),
278
323
)
279
324
280
325
0 commit comments