Merge, implement verify plando directions

This commit is contained in:
Scipio Wright
2024-08-03 15:01:32 -04:00
parent f45f3cfc1a
commit 6655b0a3d3
2 changed files with 13 additions and 7 deletions

View File

@@ -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:

View File

@@ -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