Revamp HMG logic

This commit is contained in:
KrisDavie
2024-12-16 00:06:54 +01:00
parent 8b73fee1f2
commit af1892c7d5
7 changed files with 71 additions and 121 deletions

View File

@@ -2,7 +2,7 @@
Helper functions to deliver entrance/exit/region sets to OWG rules.
"""
from BaseClasses import Entrance
from BaseClasses import Entrance, Region
# Cave regions that superbunny can get through - but only with a sword.
sword_required_superbunny_mirror_regions = ["Spiral Cave (Top)"]
@@ -283,10 +283,18 @@ def add_alternate_rule(entrance, rule):
entrance.access_rule = lambda state: old_rule(state) or rule(state)
def create_no_logic_connections(player, world, connections):
def create_no_logic_connections(player, world, connections, connect_external=False):
for entrance, parent_region, target_region, *rule_override in connections:
parent = world.get_region(parent_region, player)
target = world.get_region(target_region, player)
if isinstance(target_region, Region):
target_region = target_region.name
if connect_external and target_region.endswith(" Portal"):
target = world.get_portal(target_region[:-7], player).find_portal_entrance().parent_region
else:
target = world.get_region(target_region, player)
connection = Entrance(player, entrance, parent)
parent.exits.append(connection)
connection.connect(target)