From ae163319e0fdd3d37fcf3917abea7e15a247206d Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 1 Apr 2022 03:42:56 +0200 Subject: [PATCH] More bug fixes --- Options.py | 5 +++-- worlds/hk/Options.py | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Options.py b/Options.py index 025cb0d5..9dd3525e 100644 --- a/Options.py +++ b/Options.py @@ -38,6 +38,7 @@ class AssembleOptions(type): return ret return validate + attrs["__init__"] = validate_decorator(attrs["__init__"]) else: # construct an __init__ that calls parent __init__ @@ -53,6 +54,7 @@ class AssembleOptions(type): return super(AssembleOptions, mcs).__new__(mcs, name, bases, attrs) + T = typing.TypeVar('T') @@ -199,7 +201,7 @@ class Choice(Option[int]): if isinstance(other, self.__class__): return other.value != self.value elif isinstance(other, str): - assert other in self.options , f"compared against a str that could never be equal. {self} != {other}" + assert other in self.options, f"compared against a str that could never be equal. {self} != {other}" return other != self.current_key elif isinstance(other, int): assert other in self.name_lookup, f"compared against am int that could never be equal. {self} != {other}" @@ -507,7 +509,6 @@ per_game_common_options = { "item_links": ItemLinks } - if __name__ == "__main__": from worlds.alttp.Options import Logic diff --git a/worlds/hk/Options.py b/worlds/hk/Options.py index afb85315..1dac8813 100644 --- a/worlds/hk/Options.py +++ b/worlds/hk/Options.py @@ -2,6 +2,20 @@ import typing from .ExtractedData import logic_options, starts, pool_options from Options import Option, DefaultOnToggle, Toggle, Choice, Range + +class Disabled(Toggle): + def __init__(self, value: int): + super(Disabled, self).__init__(0) + + @classmethod + def from_text(cls, text: str) -> Toggle: + return cls(0) + + @classmethod + def from_any(cls, data: typing.Any): + return cls(0) + + locations = {"option_" + start: i for i, start in enumerate(starts)} # This way the dynamic start names are picked up by the MetaClass Choice belongs to StartLocation = type("StartLocation", (Choice,), {"auto_display_name": False, **locations}) @@ -24,23 +38,25 @@ disabled = { "RandomizeSwim", "RandomizeMimics", "RandomizeNail", - } hollow_knight_randomize_options: typing.Dict[str, type(Option)] = {} for option_name, option_data in pool_options.items(): extra_data = {"items": option_data[0], "locations": option_data[1]} + if option_name in disabled: + extra_data["__doc__"] = "Disabled Option. Not implemented." + option = type(option_name, (Disabled,), extra_data) if option_name in default_on: option = type(option_name, (DefaultOnToggle,), extra_data) else: option = type(option_name, (Toggle,), extra_data) hollow_knight_randomize_options[option_name] = option + hollow_knight_logic_options: typing.Dict[str, type(Option)] = { - option_name: Toggle for option_name in logic_options.values() if - option_name not in hollow_knight_randomize_options - and option_name != "RandomizeCharmNotches"} + option_name: Disabled if option_name in disabled else Toggle for option_name in logic_options.values() if + option_name not in hollow_knight_randomize_options} class MinimumGrubPrice(Range):