From e38516f2436cb7c403da86d6d588b75644c8cdcf Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 14 Feb 2026 13:42:36 -0500 Subject: Refactored access reqs --- apworld/regions.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'apworld/regions.py') diff --git a/apworld/regions.py b/apworld/regions.py index 3996153..313fd02 100644 --- a/apworld/regions.py +++ b/apworld/regions.py @@ -4,10 +4,9 @@ import BaseClasses from BaseClasses import Region, ItemClassification, Entrance from entrance_rando import randomize_entrances from .items import Lingo2Item -from .locations import Lingo2Location, LetterPlacementType +from .locations import Lingo2Location, LetterPlacementType, Lingo2Entrance from .options import FastTravelAccess from .player_logic import AccessRequirements -from .rules import make_location_lambda if TYPE_CHECKING: from . import Lingo2World @@ -22,9 +21,8 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di reqs = location.reqs.copy() reqs.remove_room(new_region.name) - new_location = Lingo2Location(world.player, world.static_logic.location_id_to_name[location.code], - location.code, new_region) - new_location.access_rule = make_location_lambda(reqs, world, regions) + new_location = Lingo2Location.non_event_location(world, location.code, new_region) + new_location.set_access_rule(reqs, regions) if world.options.restrict_letter_placements: if location.is_letter: new_location.set_up_letter_rule(LetterPlacementType.FORCE) @@ -33,7 +31,7 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di new_region.locations.append(new_location) for event_name, item_name in world.player_logic.event_loc_item_by_room.get(room.id, {}).items(): - new_location = Lingo2Location(world.player, event_name, None, new_region) + new_location = Lingo2Location.event_location(world, event_name, new_region) if world.for_tracker and item_name == "Victory": new_location.goal = True @@ -47,12 +45,11 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di if port.no_shuffle: continue - new_location = Lingo2Location(world.player, f"Worldport {port.id} Entered", None, new_region) + new_location = Lingo2Location.event_location(world, f"Worldport {port.id} Entered", new_region) new_location.port_id = port.id if port.HasField("required_door"): - new_location.access_rule = \ - make_location_lambda(world.player_logic.get_door_open_reqs(port.required_door), world, regions) + new_location.set_access_rule(world.player_logic.get_door_open_reqs(port.required_door), regions) new_region.locations.append(new_location) @@ -154,8 +151,8 @@ def create_regions(world: "Lingo2World"): # what regions are dead ends. continue - connection = Entrance(world.player, connection_name, regions[from_region]) - connection.access_rule = make_location_lambda(reqs, world, regions) + connection = Lingo2Entrance(world, connection_name, regions[from_region]) + connection.set_access_rule(reqs, regions) regions[from_region].exits.append(connection) connection.connect(regions[to_region]) @@ -172,13 +169,15 @@ def create_regions(world: "Lingo2World"): continue connection_name = f"Return to {to_region}" - - reqs = AccessRequirements() + connection = Lingo2Entrance(world, connection_name, regions["Menu"]) + regions["Menu"].exits.append(connection) + connection.connect(regions[to_region]) if world.options.fast_travel_access == FastTravelAccess.option_items: + reqs = AccessRequirements() reqs.items.add(world.static_logic.get_map_rte_item_name(rte_map_id)) - regions["Menu"].connect(regions[to_region], connection_name, make_location_lambda(reqs, world, None)) + connection.set_access_rule(reqs, regions) world.multiworld.regions += regions.values() @@ -211,13 +210,13 @@ def shuffle_entrances(world: "Lingo2World"): from_region = world.multiworld.get_region(from_region_name, world.player) to_region = world.multiworld.get_region(to_region_name, world.player) - connection = Entrance(world.player, f"{from_region_name} - {chosen_port.display_name}", from_region) + connection = Lingo2Entrance(world, f"{from_region_name} - {chosen_port.display_name}", from_region) from_region.exits.append(connection) connection.connect(to_region) if chosen_port.HasField("required_door"): door_reqs = world.player_logic.get_door_open_reqs(chosen_port.required_door) - connection.access_rule = make_location_lambda(door_reqs, world, None) + connection.set_access_rule(door_reqs, None) for region in door_reqs.get_referenced_rooms(): world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), @@ -233,12 +232,13 @@ def shuffle_entrances(world: "Lingo2World"): entrance = port_region.create_er_target(connection_name) entrance.randomization_type = BaseClasses.EntranceType.TWO_WAY - er_exit = port_region.create_exit(connection_name) + er_exit = Lingo2Entrance(world, connection_name, port_region) + port_region.exits.append(er_exit) er_exit.randomization_type = BaseClasses.EntranceType.TWO_WAY if port.HasField("required_door"): door_reqs = world.player_logic.get_door_open_reqs(port.required_door) - er_exit.access_rule = make_location_lambda(door_reqs, world, None) + er_exit.set_access_rule(door_reqs, None) for region in door_reqs.get_referenced_rooms(): world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), @@ -265,7 +265,7 @@ def connect_ports_from_ut(port_pairings: dict[int, int], world: "Lingo2World"): from_region = world.multiworld.get_region(from_region_name, world.player) to_region = world.multiworld.get_region(to_region_name, world.player) - connection = Entrance(world.player, f"{from_region_name} - {from_port.display_name}", from_region) + connection = Lingo2Entrance(world, f"{from_region_name} - {from_port.display_name}", from_region) reqs = AccessRequirements() if from_port.HasField("required_door"): @@ -275,7 +275,7 @@ def connect_ports_from_ut(port_pairings: dict[int, int], world: "Lingo2World"): reqs.items.add(f"Worldport {fpid} Entered") if not reqs.is_empty(): - connection.access_rule = make_location_lambda(reqs, world, None) + connection.set_access_rule(reqs, None) for region in reqs.get_referenced_rooms(): world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), -- cgit 1.4.1