From dcecbb87a19c47c7d00f773f8df6bf98d65410ef Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 22 Oct 2025 19:27:09 -0400 Subject: Make icarus optional --- apworld/regions.py | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'apworld/regions.py') diff --git a/apworld/regions.py b/apworld/regions.py index 0c3858d..1118603 100644 --- a/apworld/regions.py +++ b/apworld/regions.py @@ -62,6 +62,9 @@ def create_regions(world: "Lingo2World"): # locations. This allows us to reference the actual region objects in the access rules for the locations, which is # faster than having to look them up during access checking. for room in world.static_logic.objects.rooms: + if room.map_id not in world.player_logic.shuffled_maps: + continue + region = create_region(room, world) regions[region.name] = region region_and_room.append((region, room)) @@ -156,10 +159,42 @@ def shuffle_entrances(world: "Lingo2World"): port_id_by_name: dict[str, int] = {} - for port in world.static_logic.objects.ports: - if port.no_shuffle: - continue + shuffleable_ports = [port for port in world.static_logic.objects.ports + if not port.no_shuffle + and world.static_logic.get_room_object_map_id(port) in world.player_logic.shuffled_maps] + + if len(shuffleable_ports) % 2 == 1: + # We have an odd number of shuffleable ports! Pick a port from a room that has more than one, and make it a + # redundant warp to another port. + redundant_rooms = set(room.id for room in world.static_logic.objects.rooms if len(room.ports) > 1) + redundant_ports = [port for port in shuffleable_ports if port.room_id in redundant_rooms] + chosen_port = world.random.choice(redundant_ports) + + shuffleable_ports.remove(chosen_port) + + chosen_destination = world.random.choice(shuffleable_ports) + + world.port_pairings[chosen_port.id] = chosen_destination.id + + from_region_name = world.static_logic.get_room_region_name(chosen_port.room_id) + to_region_name = world.static_logic.get_room_region_name(chosen_destination.room_id) + + 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) + 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) + + for region in door_reqs.get_referenced_rooms(): + world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), + connection) + for port in shuffleable_ports: port_region_name = world.static_logic.get_room_region_name(port.room_id) port_region = world.multiworld.get_region(port_region_name, world.player) -- cgit 1.4.1