Generate: improve error message for missing game (#1857)
--------- Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									f3c788d0cc
								
							
						
					
					
						commit
						78b981228a
					
				| 
						 | 
				
			
			@ -447,6 +447,11 @@ def roll_settings(weights: dict, plando_options: PlandoOptions = PlandoOptions.b
 | 
			
		|||
            raise Exception(f"Option {option_key} has to be in a game's section, not on its own.")
 | 
			
		||||
 | 
			
		||||
    ret.game = get_choice("game", weights)
 | 
			
		||||
    if ret.game not in AutoWorldRegister.world_types:
 | 
			
		||||
        picks = Utils.get_fuzzy_results(ret.game, AutoWorldRegister.world_types, limit=1)[0]
 | 
			
		||||
        raise Exception(f"No world found to handle game {ret.game}. Did you mean '{picks[0]}' ({picks[1]}% sure)? "
 | 
			
		||||
                        f"Check your spelling or installation of that world.")
 | 
			
		||||
 | 
			
		||||
    if ret.game not in weights:
 | 
			
		||||
        raise Exception(f"No game options for selected game \"{ret.game}\" found.")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -461,7 +466,6 @@ def roll_settings(weights: dict, plando_options: PlandoOptions = PlandoOptions.b
 | 
			
		|||
    for option_key, option in Options.common_options.items():
 | 
			
		||||
        setattr(ret, option_key, option.from_any(get_choice(option_key, weights, option.default)))
 | 
			
		||||
 | 
			
		||||
    if ret.game in AutoWorldRegister.world_types:
 | 
			
		||||
    for option_key, option in world_type.option_definitions.items():
 | 
			
		||||
        handle_option(ret, game_weights, option_key, option, plando_options)
 | 
			
		||||
    for option_key, option in Options.per_game_common_options.items():
 | 
			
		||||
| 
						 | 
				
			
			@ -485,8 +489,6 @@ def roll_settings(weights: dict, plando_options: PlandoOptions = PlandoOptions.b
 | 
			
		|||
                    ))
 | 
			
		||||
    elif ret.game == "A Link to the Past":
 | 
			
		||||
        roll_alttp_settings(ret, game_weights, plando_options)
 | 
			
		||||
    else:
 | 
			
		||||
        raise Exception(f"Unsupported game {ret.game}")
 | 
			
		||||
 | 
			
		||||
    return ret
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -92,7 +92,7 @@ def roll_options(options: Dict[str, Union[dict, str]],
 | 
			
		|||
                        rolled_results[f"{filename}/{i + 1}"] = roll_settings(yaml_data,
 | 
			
		||||
                                                                              plando_options=plando_options)
 | 
			
		||||
            except Exception as e:
 | 
			
		||||
                results[filename] = f"Failed to generate mystery in {filename}: {e}"
 | 
			
		||||
                results[filename] = f"Failed to generate options in {filename}: {e}"
 | 
			
		||||
            else:
 | 
			
		||||
                results[filename] = True
 | 
			
		||||
    return results, rolled_results
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue