Skip to content

Commit

Permalink
Update HK to new options dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
qwint committed Jun 1, 2024
1 parent 92c3b5b commit e0dc4df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion worlds/hk/Options.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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,))
8 changes: 5 additions & 3 deletions worlds/hk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e0dc4df

Please sign in to comment.