From 424f5d4a830fb43f86c76d73d795412890d55bc2 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 22 Sep 2025 12:05:18 -0400 Subject: [Apworld] Added worldport shuffle --- apworld/__init__.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'apworld/__init__.py') diff --git a/apworld/__init__.py b/apworld/__init__.py index f1de503..2213e33 100644 --- a/apworld/__init__.py +++ b/apworld/__init__.py @@ -6,7 +6,7 @@ from worlds.AutoWorld import WebWorld, World from .items import Lingo2Item, ANTI_COLLECTABLE_TRAPS from .options import Lingo2Options from .player_logic import Lingo2PlayerLogic -from .regions import create_regions +from .regions import create_regions, shuffle_entrances, connect_ports_from_ut from .static_logic import Lingo2StaticLogic from .version import APWORLD_VERSION @@ -46,12 +46,25 @@ class Lingo2World(World): player_logic: Lingo2PlayerLogic + port_pairings: dict[int, int] + def generate_early(self): self.player_logic = Lingo2PlayerLogic(self) + self.port_pairings = {} def create_regions(self): create_regions(self) + def connect_entrances(self): + if self.options.shuffle_worldports: + if hasattr(self.multiworld, "re_gen_passthrough") and "Lingo 2" in self.multiworld.re_gen_passthrough: + slot_value = self.multiworld.re_gen_passthrough["Lingo 2"]["port_pairings"] + self.port_pairings = {int(fp): int(tp) for fp, tp in slot_value.items()} + + connect_ports_from_ut(self.port_pairings, self) + else: + shuffle_entrances(self) + from Utils import visualize_regions visualize_regions(self.multiworld.get_region("Menu", self.player), "my_world.puml") @@ -100,17 +113,29 @@ class Lingo2World(World): "shuffle_gallery_paintings", "shuffle_letters", "shuffle_symbols", + "shuffle_worldports", "strict_cyan_ending", "strict_purple_ending", "victory_condition", ] - slot_data = { + slot_data: dict[str, object] = { **self.options.as_dict(*slot_options), "version": [self.static_logic.get_data_version(), APWORLD_VERSION], } + if self.options.shuffle_worldports: + slot_data["port_pairings"] = self.port_pairings + return slot_data def get_filler_item_name(self) -> str: return "A Job Well Done" + + # for the universal tracker, doesn't get called in standard gen + # docs: https://github.com/FarisTheAncient/Archipelago/blob/tracker/worlds/tracker/docs/re-gen-passthrough.md + @staticmethod + def interpret_slot_data(slot_data: dict[str, object]) -> dict[str, object]: + # returning slot_data so it regens, giving it back in multiworld.re_gen_passthrough + # we are using re_gen_passthrough over modifying the world here due to complexities with ER + return slot_data -- cgit 1.4.1