diff --git a/AdventureClient.py b/AdventureClient.py index 06e4d60dad43..465c0d33db41 100644 --- a/AdventureClient.py +++ b/AdventureClient.py @@ -80,7 +80,7 @@ def __init__(self, server_address, password): self.local_item_locations = {} self.dragon_speed_info = {} - options = Utils.get_options() + options = Utils.get_settings() self.display_msgs = options["adventure_options"]["display_msgs"] async def server_auth(self, password_requested: bool = False): @@ -102,7 +102,7 @@ def _set_message(self, msg: str, msg_id: int): def on_package(self, cmd: str, args: dict): if cmd == 'Connected': self.locations_array = None - if Utils.get_options()["adventure_options"].get("death_link", False): + if Utils.get_settings()["adventure_options"].get("death_link", False): self.set_deathlink = True async_start(self.get_freeincarnates_used()) elif cmd == "RoomInfo": @@ -415,8 +415,8 @@ async def atari_sync_task(ctx: AdventureContext): async def run_game(romfile): - auto_start = Utils.get_options()["adventure_options"].get("rom_start", True) - rom_args = Utils.get_options()["adventure_options"].get("rom_args") + auto_start = Utils.get_settings()["adventure_options"].get("rom_start", True) + rom_args = Utils.get_settings()["adventure_options"].get("rom_args") if auto_start is True: import webbrowser webbrowser.open(romfile) diff --git a/worlds/adventure/Options.py b/worlds/adventure/Options.py index 9e0cc9d686b8..e6a8e4c20200 100644 --- a/worlds/adventure/Options.py +++ b/worlds/adventure/Options.py @@ -2,7 +2,8 @@ from typing import Dict -from Options import Choice, Option, DefaultOnToggle, DeathLink, Range, Toggle +from dataclasses import dataclass +from Options import Choice, Option, DefaultOnToggle, DeathLink, Range, Toggle, PerGameCommonOptions class FreeincarnateMax(Range): @@ -223,22 +224,22 @@ class StartCastle(Choice): option_white = 2 default = option_yellow +@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 + -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, - -} diff --git a/worlds/adventure/Regions.py b/worlds/adventure/Regions.py index 00617b2f7164..e72806ca454f 100644 --- a/worlds/adventure/Regions.py +++ b/worlds/adventure/Regions.py @@ -1,4 +1,5 @@ from BaseClasses import MultiWorld, Region, Entrance, LocationProgressType +from Options import PerGameCommonOptions from .Locations import location_table, LocationData, AdventureLocation, dragon_room_to_region @@ -24,7 +25,7 @@ def connect(world: MultiWorld, player: int, source: str, target: str, rule: call connect(world, player, target, source, rule, True) -def create_regions(multiworld: MultiWorld, player: int, dragon_rooms: []) -> None: +def create_regions(options: PerGameCommonOptions, multiworld: MultiWorld, player: int, dragon_rooms: []) -> None: menu = Region("Menu", player, multiworld) @@ -74,7 +75,7 @@ def create_regions(multiworld: MultiWorld, player: int, dragon_rooms: []) -> Non credits_room_far_side.exits.append(Entrance(player, "CreditsFromFarSide", credits_room_far_side)) multiworld.regions.append(credits_room_far_side) - dragon_slay_check = multiworld.dragon_slay_check[player].value + dragon_slay_check = options.dragon_slay_check.value priority_locations = determine_priority_locations(multiworld, dragon_slay_check) for name, location_data in location_table.items(): diff --git a/worlds/adventure/Rules.py b/worlds/adventure/Rules.py index 6f4b53faa11b..930295301288 100644 --- a/worlds/adventure/Rules.py +++ b/worlds/adventure/Rules.py @@ -6,7 +6,7 @@ def set_rules(self) -> None: world = self.multiworld - use_bat_logic = world.bat_logic[self.player].value == BatLogic.option_use_logic + use_bat_logic = self.options.bat_logic.value == BatLogic.option_use_logic set_rule(world.get_entrance("YellowCastlePort", self.player), lambda state: state.has("Yellow Key", self.player)) @@ -28,7 +28,7 @@ def set_rules(self) -> None: lambda state: state.has("Bridge", self.player) or state.has("Magnet", self.player)) - dragon_slay_check = world.dragon_slay_check[self.player].value + dragon_slay_check = self.options.dragon_slay_check.value if dragon_slay_check: if self.difficulty_switch_b == DifficultySwitchB.option_hard_with_unlock_item: set_rule(world.get_location("Slay Yorgle", self.player), diff --git a/worlds/adventure/__init__.py b/worlds/adventure/__init__.py index 84caca828f2c..54969405f355 100644 --- a/worlds/adventure/__init__.py +++ b/worlds/adventure/__init__.py @@ -15,7 +15,8 @@ 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 DragonRandoType, DifficultySwitchA, DifficultySwitchB, \ + AdventureOptions 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 +110,7 @@ class AdventureWorld(World): game: ClassVar[str] = "Adventure" web: ClassVar[WebWorld] = AdventureWeb() - option_definitions: ClassVar[Dict[str, AssembleOptions]] = adventure_option_definitions + 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()} @@ -150,18 +151,18 @@ def generate_early(self) -> None: bytearray(f"ADVENTURE{__version__.replace('.', '')[:3]}_{self.player}_{self.multiworld.seed}", "utf8")[:21] self.rom_name.extend([0] * (21 - len(self.rom_name))) - self.dragon_rando_type = self.multiworld.dragon_rando_type[self.player].value - self.dragon_slay_check = self.multiworld.dragon_slay_check[self.player].value - self.connector_multi_slot = self.multiworld.connector_multi_slot[self.player].value - self.yorgle_speed = self.multiworld.yorgle_speed[self.player].value - self.yorgle_min_speed = self.multiworld.yorgle_min_speed[self.player].value - self.grundle_speed = self.multiworld.grundle_speed[self.player].value - self.grundle_min_speed = self.multiworld.grundle_min_speed[self.player].value - self.rhindle_speed = self.multiworld.rhindle_speed[self.player].value - self.rhindle_min_speed = self.multiworld.rhindle_min_speed[self.player].value - self.difficulty_switch_a = self.multiworld.difficulty_switch_a[self.player].value - self.difficulty_switch_b = self.multiworld.difficulty_switch_b[self.player].value - self.start_castle = self.multiworld.start_castle[self.player].value + self.dragon_rando_type = self.options.dragon_rando_type.value + self.dragon_slay_check = self.options.dragon_slay_check.value + self.connector_multi_slot = self.options.connector_multi_slot.value + self.yorgle_speed = self.options.yorgle_speed.value + self.yorgle_min_speed = self.options.yorgle_min_speed.value + self.grundle_speed = self.options.grundle_speed.value + self.grundle_min_speed = self.options.grundle_min_speed.value + self.rhindle_speed = self.options.rhindle_speed.value + self.rhindle_min_speed = self.options.rhindle_min_speed.value + self.difficulty_switch_a = self.options.difficulty_switch_a.value + self.difficulty_switch_b = self.options.difficulty_switch_b.value + self.start_castle = self.options.start_castle.value self.created_items = 0 if self.dragon_slay_check == 0: @@ -228,7 +229,7 @@ def create_items(self) -> None: extra_filler_count = num_locations - self.created_items # traps would probably go here, if enabled - freeincarnate_max = self.multiworld.freeincarnate_max[self.player].value + freeincarnate_max = self.options.freeincarnate_max.value actual_freeincarnates = min(extra_filler_count, freeincarnate_max) self.multiworld.itempool += [self.create_item("Freeincarnate") for _ in range(actual_freeincarnates)] self.created_items += actual_freeincarnates @@ -248,7 +249,7 @@ def create_dragon_slow_items(self, min_speed: int, speed: int, item_name: str, m self.created_items += 1 def create_regions(self) -> None: - create_regions(self.multiworld, self.player, self.dragon_rooms) + create_regions(self.options, self.multiworld, self.player, self.dragon_rooms) set_rules = set_rules @@ -355,7 +356,7 @@ def generate_output(self, output_directory: str) -> None: auto_collect_locations: [AdventureAutoCollectLocation] = [] local_item_to_location: {int, int} = {} bat_no_touch_locs: [LocationData] = [] - bat_logic: int = self.multiworld.bat_logic[self.player].value + bat_logic: int = self.options.bat_logic.value try: rom_deltas: { int, int } = {} self.place_dragons(rom_deltas) @@ -422,7 +423,7 @@ def generate_output(self, output_directory: str) -> None: item_position_data_start = get_item_position_data_start(unplaced_item.table_index) rom_deltas[item_position_data_start] = 0xff - if self.multiworld.connector_multi_slot[self.player].value: + if self.options.connector_multi_slot.value: rom_deltas[connector_port_offset] = (self.player & 0xff) else: rom_deltas[connector_port_offset] = 0