From 6655b0a3d33b54f2dddebbe2b300c75afa1e1b29 Mon Sep 17 00:00:00 2001 From: Scipio Wright Date: Sat, 3 Aug 2024 15:01:32 -0400 Subject: [PATCH] Merge, implement verify plando directions --- worlds/tunic/__init__.py | 8 +++++++- worlds/tunic/er_scripts.py | 12 ++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/worlds/tunic/__init__.py b/worlds/tunic/__init__.py index bf4fed5804..10c2a01cf7 100644 --- a/worlds/tunic/__init__.py +++ b/worlds/tunic/__init__.py @@ -6,7 +6,7 @@ from .locations import location_table, location_name_groups, location_name_to_id from .rules import set_location_rules, set_region_rules, randomize_ability_unlocks, gold_hexagon from .er_rules import set_er_location_rules from .regions import tunic_regions -from .er_scripts import create_er_regions +from .er_scripts import create_er_regions, verify_plando_directions from .er_data import portal_mapping from .options import (TunicOptions, EntranceRando, tunic_option_groups, tunic_option_presets, TunicPlandoConnections, LaurelsLocation, EntranceLayout) @@ -96,6 +96,12 @@ class TunicWorld(World): self.options.plando_connections.value.remove(cxn) self.options.plando_connections.value.insert(index, replacement) + if (self.options.entrance_layout == EntranceLayout.option_direction_pairs + and not verify_plando_directions(cxn)): + raise OptionError(f"TUNIC: Player {self.player_name} has invalid plando connections. " + f"They have Direction Pairs enabled and the connection " + f"{cxn.entrance} --> {cxn.exit} does not abide by this option.") + # Universal tracker stuff, shouldn't do anything in standard gen if hasattr(self.multiworld, "re_gen_passthrough"): if "TUNIC" in self.multiworld.re_gen_passthrough: diff --git a/worlds/tunic/er_scripts.py b/worlds/tunic/er_scripts.py index 4d95cf671c..28bb5a84ee 100644 --- a/worlds/tunic/er_scripts.py +++ b/worlds/tunic/er_scripts.py @@ -323,11 +323,11 @@ def pair_portals(world: "TunicWorld", regions: Dict[str, Region]) -> Dict[Portal # if it's not a dead end, it might be a shop if p_exit == "Shop Portal": # 6 of the shops have south exits, 2 of them have west exits - dir = Direction.south + shop_dir = Direction.south if world.shop_num > 6: - dir = Direction.west + shop_dir = Direction.west portal2 = Portal(name=f"Shop Portal {world.shop_num}", region=f"Shop {world.shop_num}", - destination="Previous Region", tag="_", direction=dir) + destination="Previous Region", tag="_", direction=shop_dir) create_shop_region(world, regions) shop_count -= 1 # need to maintain an even number of portals total @@ -472,11 +472,11 @@ def pair_portals(world: "TunicWorld", regions: Dict[str, Region]) -> Dict[Portal if portal1 is None: raise Exception("Too many shops in the pool, or something else went wrong.") # 6 of the shops have south exits, 2 of them have west exits - dir = Direction.south + shop_dir = Direction.south if world.shop_num > 6: - dir = Direction.west + shop_dir = Direction.west portal2 = Portal(name=f"Shop Portal {world.shop_num}", region=f"Shop {world.shop_num}", - destination="Previous Region", tag="_", direction=dir) + destination="Previous Region", tag="_", direction=shop_dir) create_shop_region(world, regions) portal_pairs[portal1] = portal2