From 79e1bf351edb6449bc6dc4bf5a66a270a83ea310 Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Sun, 24 Dec 2023 16:47:54 -0800 Subject: [PATCH] Adventure: options assigned as data_class --- worlds/adventure/Options.py | 39 ++++++++++++++++++------------------ worlds/adventure/__init__.py | 5 +++-- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/worlds/adventure/Options.py b/worlds/adventure/Options.py index fb09e5329b..e07370cb4b 100644 --- a/worlds/adventure/Options.py +++ b/worlds/adventure/Options.py @@ -2,7 +2,9 @@ from __future__ import annotations from typing import Dict -from Options import Choice, Option, DefaultOnToggle, DeathLink, Range, Toggle +from Options import Choice, Option, DefaultOnToggle, DeathLink, Range, Toggle, PerGameCommonOptions + +from dataclasses import dataclass class FreeincarnateMax(Range): @@ -224,21 +226,20 @@ class StartCastle(Choice): default = option_yellow -adventure_option_definitions: Dict[str, type(Option)] = { - "dragon_slay_check": DragonSlayCheck, - "death_link": DeathLink, - "bat_logic": BatLogic, - "freeincarnate_max": FreeincarnateMax, - "dragon_rando_type": DragonRandoType, - "connector_multi_slot": ConnectorMultiSlot, - "yorgle_speed": YorgleStartingSpeed, - "yorgle_min_speed": YorgleMinimumSpeed, - "grundle_speed": GrundleStartingSpeed, - "grundle_min_speed": GrundleMinimumSpeed, - "rhindle_speed": RhindleStartingSpeed, - "rhindle_min_speed": RhindleMinimumSpeed, - "difficulty_switch_a": DifficultySwitchA, - "difficulty_switch_b": DifficultySwitchB, - "start_castle": StartCastle, - -} \ No newline at end of file +@dataclass +class AdventureOptions(PerGameCommonOptions): + dragon_slay_check: DragonSlayCheck + death_link: DeathLink + bat_logic: BatLogic + freeincarnate_max: FreeincarnateMax + dragon_rando_type: DragonRandoType + connector_multi_slot: ConnectorMultiSlot + yorgle_speed: YorgleStartingSpeed + yorgle_min_speed: YorgleMinimumSpeed + grundle_speed: GrundleStartingSpeed + grundle_min_speed: GrundleMinimumSpeed + rhindle_speed: RhindleStartingSpeed + rhindle_min_speed: RhindleMinimumSpeed + difficulty_switch_a: DifficultySwitchA + difficulty_switch_b: DifficultySwitchB + start_castle: StartCastle diff --git a/worlds/adventure/__init__.py b/worlds/adventure/__init__.py index 14ffe2a23f..0eb42c4369 100644 --- a/worlds/adventure/__init__.py +++ b/worlds/adventure/__init__.py @@ -15,7 +15,7 @@ from Options import AssembleOptions from worlds.AutoWorld import WebWorld, World from Fill import fill_restrictive from worlds.generic.Rules import add_rule, set_rule -from .Options import adventure_option_definitions, DragonRandoType, DifficultySwitchA, DifficultySwitchB +from .Options import AdventureOptions, DragonRandoType, DifficultySwitchA, DifficultySwitchB from .Rom import get_base_rom_bytes, get_base_rom_path, AdventureDeltaPatch, apply_basepatch, \ AdventureAutoCollectLocation from .Items import item_table, ItemData, nothing_item_id, event_table, AdventureItem, standard_item_max @@ -109,7 +109,8 @@ class AdventureWorld(World): game: ClassVar[str] = "Adventure" web: ClassVar[WebWorld] = AdventureWeb() - option_definitions: ClassVar[Dict[str, AssembleOptions]] = adventure_option_definitions + options = AdventureOptions + options_dataclass = AdventureOptions settings: ClassVar[AdventureSettings] item_name_to_id: ClassVar[Dict[str, int]] = {name: data.id for name, data in item_table.items()} location_name_to_id: ClassVar[Dict[str, int]] = {name: data.location_id for name, data in location_table.items()}