diff options
Diffstat (limited to 'apworld/regions.py')
| -rw-r--r-- | apworld/regions.py | 40 |
1 files changed, 20 insertions, 20 deletions
| 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 | |||
| 4 | from BaseClasses import Region, ItemClassification, Entrance | 4 | from BaseClasses import Region, ItemClassification, Entrance |
| 5 | from entrance_rando import randomize_entrances | 5 | from entrance_rando import randomize_entrances |
| 6 | from .items import Lingo2Item | 6 | from .items import Lingo2Item |
| 7 | from .locations import Lingo2Location, LetterPlacementType | 7 | from .locations import Lingo2Location, LetterPlacementType, Lingo2Entrance |
| 8 | from .options import FastTravelAccess | 8 | from .options import FastTravelAccess |
| 9 | from .player_logic import AccessRequirements | 9 | from .player_logic import AccessRequirements |
| 10 | from .rules import make_location_lambda | ||
| 11 | 10 | ||
| 12 | if TYPE_CHECKING: | 11 | if TYPE_CHECKING: |
| 13 | from . import Lingo2World | 12 | from . import Lingo2World |
| @@ -22,9 +21,8 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di | |||
| 22 | reqs = location.reqs.copy() | 21 | reqs = location.reqs.copy() |
| 23 | reqs.remove_room(new_region.name) | 22 | reqs.remove_room(new_region.name) |
| 24 | 23 | ||
| 25 | new_location = Lingo2Location(world.player, world.static_logic.location_id_to_name[location.code], | 24 | new_location = Lingo2Location.non_event_location(world, location.code, new_region) |
| 26 | location.code, new_region) | 25 | new_location.set_access_rule(reqs, regions) |
| 27 | new_location.access_rule = make_location_lambda(reqs, world, regions) | ||
| 28 | if world.options.restrict_letter_placements: | 26 | if world.options.restrict_letter_placements: |
| 29 | if location.is_letter: | 27 | if location.is_letter: |
| 30 | new_location.set_up_letter_rule(LetterPlacementType.FORCE) | 28 | new_location.set_up_letter_rule(LetterPlacementType.FORCE) |
| @@ -33,7 +31,7 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di | |||
| 33 | new_region.locations.append(new_location) | 31 | new_region.locations.append(new_location) |
| 34 | 32 | ||
| 35 | for event_name, item_name in world.player_logic.event_loc_item_by_room.get(room.id, {}).items(): | 33 | for event_name, item_name in world.player_logic.event_loc_item_by_room.get(room.id, {}).items(): |
| 36 | new_location = Lingo2Location(world.player, event_name, None, new_region) | 34 | new_location = Lingo2Location.event_location(world, event_name, new_region) |
| 37 | if world.for_tracker and item_name == "Victory": | 35 | if world.for_tracker and item_name == "Victory": |
| 38 | new_location.goal = True | 36 | new_location.goal = True |
| 39 | 37 | ||
| @@ -47,12 +45,11 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di | |||
| 47 | if port.no_shuffle: | 45 | if port.no_shuffle: |
| 48 | continue | 46 | continue |
| 49 | 47 | ||
| 50 | new_location = Lingo2Location(world.player, f"Worldport {port.id} Entered", None, new_region) | 48 | new_location = Lingo2Location.event_location(world, f"Worldport {port.id} Entered", new_region) |
| 51 | new_location.port_id = port.id | 49 | new_location.port_id = port.id |
| 52 | 50 | ||
| 53 | if port.HasField("required_door"): | 51 | if port.HasField("required_door"): |
| 54 | new_location.access_rule = \ | 52 | new_location.set_access_rule(world.player_logic.get_door_open_reqs(port.required_door), regions) |
| 55 | make_location_lambda(world.player_logic.get_door_open_reqs(port.required_door), world, regions) | ||
| 56 | 53 | ||
| 57 | new_region.locations.append(new_location) | 54 | new_region.locations.append(new_location) |
| 58 | 55 | ||
| @@ -154,8 +151,8 @@ def create_regions(world: "Lingo2World"): | |||
| 154 | # what regions are dead ends. | 151 | # what regions are dead ends. |
| 155 | continue | 152 | continue |
| 156 | 153 | ||
| 157 | connection = Entrance(world.player, connection_name, regions[from_region]) | 154 | connection = Lingo2Entrance(world, connection_name, regions[from_region]) |
| 158 | connection.access_rule = make_location_lambda(reqs, world, regions) | 155 | connection.set_access_rule(reqs, regions) |
| 159 | 156 | ||
| 160 | regions[from_region].exits.append(connection) | 157 | regions[from_region].exits.append(connection) |
| 161 | connection.connect(regions[to_region]) | 158 | connection.connect(regions[to_region]) |
| @@ -172,13 +169,15 @@ def create_regions(world: "Lingo2World"): | |||
| 172 | continue | 169 | continue |
| 173 | 170 | ||
| 174 | connection_name = f"Return to {to_region}" | 171 | connection_name = f"Return to {to_region}" |
| 175 | 172 | connection = Lingo2Entrance(world, connection_name, regions["Menu"]) | |
| 176 | reqs = AccessRequirements() | 173 | regions["Menu"].exits.append(connection) |
| 174 | connection.connect(regions[to_region]) | ||
| 177 | 175 | ||
| 178 | if world.options.fast_travel_access == FastTravelAccess.option_items: | 176 | if world.options.fast_travel_access == FastTravelAccess.option_items: |
| 177 | reqs = AccessRequirements() | ||
| 179 | reqs.items.add(world.static_logic.get_map_rte_item_name(rte_map_id)) | 178 | reqs.items.add(world.static_logic.get_map_rte_item_name(rte_map_id)) |
| 180 | 179 | ||
| 181 | regions["Menu"].connect(regions[to_region], connection_name, make_location_lambda(reqs, world, None)) | 180 | connection.set_access_rule(reqs, regions) |
| 182 | 181 | ||
| 183 | world.multiworld.regions += regions.values() | 182 | world.multiworld.regions += regions.values() |
| 184 | 183 | ||
| @@ -211,13 +210,13 @@ def shuffle_entrances(world: "Lingo2World"): | |||
| 211 | from_region = world.multiworld.get_region(from_region_name, world.player) | 210 | from_region = world.multiworld.get_region(from_region_name, world.player) |
| 212 | to_region = world.multiworld.get_region(to_region_name, world.player) | 211 | to_region = world.multiworld.get_region(to_region_name, world.player) |
| 213 | 212 | ||
| 214 | connection = Entrance(world.player, f"{from_region_name} - {chosen_port.display_name}", from_region) | 213 | connection = Lingo2Entrance(world, f"{from_region_name} - {chosen_port.display_name}", from_region) |
| 215 | from_region.exits.append(connection) | 214 | from_region.exits.append(connection) |
| 216 | connection.connect(to_region) | 215 | connection.connect(to_region) |
| 217 | 216 | ||
| 218 | if chosen_port.HasField("required_door"): | 217 | if chosen_port.HasField("required_door"): |
| 219 | door_reqs = world.player_logic.get_door_open_reqs(chosen_port.required_door) | 218 | door_reqs = world.player_logic.get_door_open_reqs(chosen_port.required_door) |
| 220 | connection.access_rule = make_location_lambda(door_reqs, world, None) | 219 | connection.set_access_rule(door_reqs, None) |
| 221 | 220 | ||
| 222 | for region in door_reqs.get_referenced_rooms(): | 221 | for region in door_reqs.get_referenced_rooms(): |
| 223 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), | 222 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), |
| @@ -233,12 +232,13 @@ def shuffle_entrances(world: "Lingo2World"): | |||
| 233 | entrance = port_region.create_er_target(connection_name) | 232 | entrance = port_region.create_er_target(connection_name) |
| 234 | entrance.randomization_type = BaseClasses.EntranceType.TWO_WAY | 233 | entrance.randomization_type = BaseClasses.EntranceType.TWO_WAY |
| 235 | 234 | ||
| 236 | er_exit = port_region.create_exit(connection_name) | 235 | er_exit = Lingo2Entrance(world, connection_name, port_region) |
| 236 | port_region.exits.append(er_exit) | ||
| 237 | er_exit.randomization_type = BaseClasses.EntranceType.TWO_WAY | 237 | er_exit.randomization_type = BaseClasses.EntranceType.TWO_WAY |
| 238 | 238 | ||
| 239 | if port.HasField("required_door"): | 239 | if port.HasField("required_door"): |
| 240 | door_reqs = world.player_logic.get_door_open_reqs(port.required_door) | 240 | door_reqs = world.player_logic.get_door_open_reqs(port.required_door) |
| 241 | er_exit.access_rule = make_location_lambda(door_reqs, world, None) | 241 | er_exit.set_access_rule(door_reqs, None) |
| 242 | 242 | ||
| 243 | for region in door_reqs.get_referenced_rooms(): | 243 | for region in door_reqs.get_referenced_rooms(): |
| 244 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), | 244 | 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"): | |||
| 265 | from_region = world.multiworld.get_region(from_region_name, world.player) | 265 | from_region = world.multiworld.get_region(from_region_name, world.player) |
| 266 | to_region = world.multiworld.get_region(to_region_name, world.player) | 266 | to_region = world.multiworld.get_region(to_region_name, world.player) |
| 267 | 267 | ||
| 268 | connection = Entrance(world.player, f"{from_region_name} - {from_port.display_name}", from_region) | 268 | connection = Lingo2Entrance(world, f"{from_region_name} - {from_port.display_name}", from_region) |
| 269 | 269 | ||
| 270 | reqs = AccessRequirements() | 270 | reqs = AccessRequirements() |
| 271 | if from_port.HasField("required_door"): | 271 | if from_port.HasField("required_door"): |
| @@ -275,7 +275,7 @@ def connect_ports_from_ut(port_pairings: dict[int, int], world: "Lingo2World"): | |||
| 275 | reqs.items.add(f"Worldport {fpid} Entered") | 275 | reqs.items.add(f"Worldport {fpid} Entered") |
| 276 | 276 | ||
| 277 | if not reqs.is_empty(): | 277 | if not reqs.is_empty(): |
| 278 | connection.access_rule = make_location_lambda(reqs, world, None) | 278 | connection.set_access_rule(reqs, None) |
| 279 | 279 | ||
| 280 | for region in reqs.get_referenced_rooms(): | 280 | for region in reqs.get_referenced_rooms(): |
| 281 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), | 281 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), |
