From 6e4b255be52d280fb635226c94f537072e23d4f9 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 28 Dec 2021 18:43:52 +0100 Subject: [PATCH] Options: make common options overridable in a game section WebHost: add prog balancing and accessibility to settings page --- BaseClasses.py | 2 -- Generate.py | 2 +- Options.py | 4 +++- WebHostLib/options.py | 9 +++++---- WebHostLib/templates/options.yaml | 7 ------- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index 0c90f37c..bbf110d2 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -1210,8 +1210,6 @@ class Spoiler(): if self.world.players > 1: outfile.write('\nPlayer %d: %s\n' % (player, self.world.get_player_name(player))) outfile.write('Game: %s\n' % self.world.game[player]) - for f_option, option in Options.common_options.items(): - write_option(f_option, option) for f_option, option in Options.per_game_common_options.items(): write_option(f_option, option) options = self.world.worlds[player].options diff --git a/Generate.py b/Generate.py index a8c88125..fc82ad43 100644 --- a/Generate.py +++ b/Generate.py @@ -469,7 +469,7 @@ def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("b ret = argparse.Namespace() for option_key in Options.per_game_common_options: - if option_key in weights: + if option_key in weights and option_key not in Options.common_options: raise Exception(f"Option {option_key} has to be in a game's section, not on its own.") ret.game = get_choice("game", weights) diff --git a/Options.py b/Options.py index cd4d9148..ef786e47 100644 --- a/Options.py +++ b/Options.py @@ -334,7 +334,7 @@ class Accessibility(Choice): Locations: ensure everything can be reached and acquired. Items: ensure all logically relevant items can be acquired. Minimal: ensure what is needed to reach your goal can be acquired.""" - + displayname = "Accessibility" option_locations = 0 option_items = 1 option_minimal = 2 @@ -344,6 +344,7 @@ class Accessibility(Choice): class ProgressionBalancing(DefaultOnToggle): """A system that moves progression earlier, to try and prevent the player from getting stuck and bored early.""" + displayname = "Progression Balancing" common_options = { @@ -395,6 +396,7 @@ class DeathLink(Toggle): per_game_common_options = { + **common_options, # can be overwritten per-game "local_items": LocalItems, "non_local_items": NonLocalItems, "start_inventory": StartInventory, diff --git a/WebHostLib/options.py b/WebHostLib/options.py index c8a7b9a6..73bcff46 100644 --- a/WebHostLib/options.py +++ b/WebHostLib/options.py @@ -11,6 +11,8 @@ target_folder = os.path.join("WebHostLib", "static", "generated") def create(): + os.makedirs(os.path.join(target_folder, 'configs'), exist_ok=True) + def dictify_range(option): data = {option.range_start: 0, option.range_end: 0, "random": 0, "random-low": 0, "random-high": 0, option.default: 50} @@ -26,14 +28,13 @@ def create(): return default_value for game_name, world in AutoWorldRegister.world_types.items(): + all_options = {**world.options, **Options.per_game_common_options} res = Template(open(os.path.join("WebHostLib", "templates", "options.yaml")).read()).render( - options={**world.options, **Options.per_game_common_options}, + options=all_options, __version__=__version__, game=game_name, yaml_dump=yaml.dump, dictify_range=dictify_range, default_converter=default_converter, ) - os.makedirs(os.path.join(target_folder, 'configs'), exist_ok=True) - with open(os.path.join(target_folder, 'configs', game_name + ".yaml"), "w") as f: f.write(res) @@ -47,7 +48,7 @@ def create(): } game_options = {} - for option_name, option in world.options.items(): + for option_name, option in all_options.items(): if option.options: game_options[option_name] = this_option = { "type": "select", diff --git a/WebHostLib/templates/options.yaml b/WebHostLib/templates/options.yaml index 91da3a83..95fab2ae 100644 --- a/WebHostLib/templates/options.yaml +++ b/WebHostLib/templates/options.yaml @@ -29,13 +29,6 @@ game: requires: version: {{ __version__ }} # Version of Archipelago required for this yaml to work as expected. # Shared Options supported by all games: -accessibility: - items: 0 # Guarantees you will be able to acquire all items, but you may not be able to access all locations - locations: 50 # Guarantees you will be able to access all locations, and therefore all items - none: 0 # Guarantees only that the game is beatable. You may not be able to access all locations or acquire all items -progression_balancing: - on: 50 # A system to reduce BK, as in times during which you can't do anything by moving your items into an earlier access sphere to make it likely you have stuff to do - off: 0 # Turn this off if you don't mind a longer multiworld, or can glitch/sequence break around missing items. {%- macro range_option(option) %} # you can add additional values between minimum and maximum