From e0dc4dfc93b79904c25b4c637366f555fac45337 Mon Sep 17 00:00:00 2001 From: qwint Date: Sat, 1 Jun 2024 12:20:29 -0500 Subject: [PATCH] Update HK to new options dataclass --- worlds/hk/Options.py | 6 +++++- worlds/hk/__init__.py | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/worlds/hk/Options.py b/worlds/hk/Options.py index f408528821cc..279b28489d7d 100644 --- a/worlds/hk/Options.py +++ b/worlds/hk/Options.py @@ -1,9 +1,11 @@ import typing import re +from dataclasses import dataclass, make_dataclass + from .ExtractedData import logic_options, starts, pool_options from .Rules import cost_terms -from Options import Option, DefaultOnToggle, Toggle, Choice, Range, OptionDict, NamedRange, DeathLink +from Options import Option, DefaultOnToggle, Toggle, Choice, Range, OptionDict, NamedRange, DeathLink, PerGameCommonOptions from .Charms import vanilla_costs, names as charm_names if typing.TYPE_CHECKING: @@ -534,3 +536,5 @@ class CostSanityHybridChance(Range): }, **cost_sanity_weights } + +HKOptions = make_dataclass("HKOptions", [(name, option) for name, option in hollow_knight_options.items()], bases=(PerGameCommonOptions,)) diff --git a/worlds/hk/__init__.py b/worlds/hk/__init__.py index 67ff1833eb67..22254298e972 100644 --- a/worlds/hk/__init__.py +++ b/worlds/hk/__init__.py @@ -12,7 +12,7 @@ from .Regions import create_regions from .Rules import set_rules, cost_terms from .Options import hollow_knight_options, hollow_knight_randomize_options, Goal, WhitePalace, CostSanity, \ - shop_to_option + shop_to_option, HKOptions from .ExtractedData import locations, starts, multi_locations, location_to_region_lookup, \ event_names, item_effects, connectors, one_ways, vanilla_shop_costs, vanilla_location_costs from .Charms import names as charm_names @@ -142,7 +142,9 @@ class HKWorld(World): As the enigmatic Knight, you’ll traverse the depths, unravel its mysteries and conquer its evils. """ # from https://www.hollowknight.com game: str = "Hollow Knight" - option_definitions = hollow_knight_options + # option_definitions = hollow_knight_options + options_dataclass = HKOptions + options: HKOptions web = HKWeb() @@ -486,7 +488,7 @@ def fill_slot_data(self): slot_data = {} options = slot_data["options"] = {} - for option_name in self.option_definitions: + for option_name in hollow_knight_options: option = getattr(self.options, option_name) try: optionvalue = int(option.value)