@@ -15,7 +15,8 @@ def __parse_enum(table: dict, key: str, enum: Any, default: int = 0) -> Any:
1515 if str (enum (i )).split ('.' )[- 1 ].lower () == table [key ].lower ():
1616 return enum (i )
1717 except ValueError :
18- logger .warning (f"Unknown value '{ table [key ]} ' for key '{ key } ' using default ({ enum (default )} )" )
18+ logger .error (f"Invalid value '{ table [key ]} ' for key '{ key } '. "
19+ f"Using default '{ str (enum (default )).split ('.' )[- 1 ]} ' instead." )
1920 return enum (default )
2021
2122
@@ -41,29 +42,33 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
4142 except ValueError :
4243 team = {"blue" : 0 , "orange" : 1 }.get (team .lower ())
4344 if team is None or team not in [0 , 1 ]:
44- logger .warning (f"Unknown team '{ car_table .get ("team" )} ' for player { len (players )} , using default team 0" )
45+ logger .error (f"Invalid team '{ car_table .get ("team" )} ' for player { len (players )} . "
46+ "Using default team 0 instead." )
4547
4648 loadout_file = car_table .get ("loadout_file" )
47- variant = car_table .get ("type" , "rlbot" )
4849 skill = __parse_enum (car_table , "skill" , flat .PsyonixSkill , int (flat .PsyonixSkill .AllStar ))
50+ variant = car_table .get ("type" , "rlbot" ).lower ()
51+
4952 match variant :
5053 case "rlbot" :
51- if car_config is None :
52- loadout = load_player_loadout (loadout_file , team ) if loadout_file else None
53- players .append (flat .PlayerConfiguration (flat .CustomBot (), name , team , loadout = loadout ))
54- else :
55- abs_config_path = (config_path .parent / car_config ).resolve ()
56- players .append (load_player_config (abs_config_path , flat .CustomBot (), team , name , loadout_file ))
54+ variety , use_config = flat .CustomBot (), True
5755 case "psyonix" :
58- if car_config is None :
59- loadout = load_player_loadout (loadout_file , team ) if loadout_file else None
60- players .append (flat .PlayerConfiguration (flat .Psyonix (skill ), name , team , loadout = loadout ))
61- else :
62- abs_config_path = (config_path .parent / car_config ).resolve ()
63- players .append (load_player_config (abs_config_path , flat .Psyonix (skill ), team , name , loadout_file ))
56+ variety , use_config = flat .Psyonix (skill ), True
6457 case "human" :
65- loadout = load_player_loadout (loadout_file , team ) if loadout_file else None
66- players .append (flat .PlayerConfiguration (flat .Human (), name , team , loadout = loadout ))
58+ variety , use_config = flat .Human (), False
59+ case "partymember" :
60+ logger .warning ("PartyMember player type is not supported yet." )
61+ variety , use_config = flat .PartyMember , False
62+ case t :
63+ logger .error (f"Invalid player type '{ t } ' for player { len (players )} . Using default 'rlbot' instead." )
64+ variety , use_config = flat .CustomBot (), True
65+
66+ if use_config and car_config is not None :
67+ abs_config_path = (config_path .parent / car_config ).resolve ()
68+ players .append (load_player_config (abs_config_path , variety , team , name , loadout_file ))
69+ else :
70+ loadout = load_player_loadout (loadout_file , team ) if loadout_file else None
71+ players .append (flat .PlayerConfiguration (variety , name , team , loadout = loadout ))
6772
6873 scripts = []
6974 for script_table in config .get ("scripts" , []):
0 commit comments