diff --git a/Generate.py b/Generate.py index d98edc3f5897..ab8eab22d66b 100644 --- a/Generate.py +++ b/Generate.py @@ -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,32 +466,29 @@ 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(): + 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(): + # skip setting this option if already set from common_options, defaulting to root option + if option_key not in world_type.option_definitions and \ + (option_key not in Options.common_options or option_key in game_weights): handle_option(ret, game_weights, option_key, option, plando_options) - for option_key, option in Options.per_game_common_options.items(): - # skip setting this option if already set from common_options, defaulting to root option - if option_key not in world_type.option_definitions and \ - (option_key not in Options.common_options or option_key in game_weights): - handle_option(ret, game_weights, option_key, option, plando_options) - if PlandoOptions.items in plando_options: - ret.plando_items = game_weights.get("plando_items", []) - if ret.game == "Minecraft" or ret.game == "Ocarina of Time": - # bad hardcoded behavior to make this work for now - ret.plando_connections = [] - if PlandoOptions.connections in plando_options: - options = game_weights.get("plando_connections", []) - for placement in options: - if roll_percentage(get_choice("percentage", placement, 100)): - ret.plando_connections.append(PlandoConnection( - get_choice("entrance", placement), - get_choice("exit", placement), - get_choice("direction", placement) - )) - elif ret.game == "A Link to the Past": - roll_alttp_settings(ret, game_weights, plando_options) - else: - raise Exception(f"Unsupported game {ret.game}") + if PlandoOptions.items in plando_options: + ret.plando_items = game_weights.get("plando_items", []) + if ret.game == "Minecraft" or ret.game == "Ocarina of Time": + # bad hardcoded behavior to make this work for now + ret.plando_connections = [] + if PlandoOptions.connections in plando_options: + options = game_weights.get("plando_connections", []) + for placement in options: + if roll_percentage(get_choice("percentage", placement, 100)): + ret.plando_connections.append(PlandoConnection( + get_choice("entrance", placement), + get_choice("exit", placement), + get_choice("direction", placement) + )) + elif ret.game == "A Link to the Past": + roll_alttp_settings(ret, game_weights, plando_options) return ret diff --git a/WebHostLib/check.py b/WebHostLib/check.py index 3daef72c0335..0c1e090dbe47 100644 --- a/WebHostLib/check.py +++ b/WebHostLib/check.py @@ -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