diff options
Diffstat (limited to 'regions.py')
| -rw-r--r-- | regions.py | 38 |
1 files changed, 17 insertions, 21 deletions
| diff --git a/regions.py b/regions.py index 464e9a1..5fddabd 100644 --- a/regions.py +++ b/regions.py | |||
| @@ -4,7 +4,6 @@ from BaseClasses import Entrance, ItemClassification, Region | |||
| 4 | from .datatypes import Room, RoomAndDoor | 4 | from .datatypes import Room, RoomAndDoor |
| 5 | from .items import LingoItem | 5 | from .items import LingoItem |
| 6 | from .locations import LingoLocation | 6 | from .locations import LingoLocation |
| 7 | from .player_logic import LingoPlayerLogic | ||
| 8 | from .rules import lingo_can_use_entrance, make_location_lambda | 7 | from .rules import lingo_can_use_entrance, make_location_lambda |
| 9 | from .static_logic import ALL_ROOMS, PAINTINGS | 8 | from .static_logic import ALL_ROOMS, PAINTINGS |
| 10 | 9 | ||
| @@ -12,14 +11,14 @@ if TYPE_CHECKING: | |||
| 12 | from . import LingoWorld | 11 | from . import LingoWorld |
| 13 | 12 | ||
| 14 | 13 | ||
| 15 | def create_region(room: Room, world: "LingoWorld", player_logic: LingoPlayerLogic) -> Region: | 14 | def create_region(room: Room, world: "LingoWorld") -> Region: |
| 16 | new_region = Region(room.name, world.player, world.multiworld) | 15 | new_region = Region(room.name, world.player, world.multiworld) |
| 17 | for location in player_logic.locations_by_room.get(room.name, {}): | 16 | for location in world.player_logic.locations_by_room.get(room.name, {}): |
| 18 | new_location = LingoLocation(world.player, location.name, location.code, new_region) | 17 | new_location = LingoLocation(world.player, location.name, location.code, new_region) |
| 19 | new_location.access_rule = make_location_lambda(location, world, player_logic) | 18 | new_location.access_rule = make_location_lambda(location, world) |
| 20 | new_region.locations.append(new_location) | 19 | new_region.locations.append(new_location) |
| 21 | if location.name in player_logic.event_loc_to_item: | 20 | if location.name in world.player_logic.event_loc_to_item: |
| 22 | event_name = player_logic.event_loc_to_item[location.name] | 21 | event_name = world.player_logic.event_loc_to_item[location.name] |
| 23 | event_item = LingoItem(event_name, ItemClassification.progression, None, world.player) | 22 | event_item = LingoItem(event_name, ItemClassification.progression, None, world.player) |
| 24 | new_location.place_locked_item(event_item) | 23 | new_location.place_locked_item(event_item) |
| 25 | 24 | ||
| @@ -27,22 +26,21 @@ def create_region(room: Room, world: "LingoWorld", player_logic: LingoPlayerLogi | |||
| 27 | 26 | ||
| 28 | 27 | ||
| 29 | def connect_entrance(regions: Dict[str, Region], source_region: Region, target_region: Region, description: str, | 28 | def connect_entrance(regions: Dict[str, Region], source_region: Region, target_region: Region, description: str, |
| 30 | door: Optional[RoomAndDoor], world: "LingoWorld", player_logic: LingoPlayerLogic): | 29 | door: Optional[RoomAndDoor], world: "LingoWorld"): |
| 31 | connection = Entrance(world.player, description, source_region) | 30 | connection = Entrance(world.player, description, source_region) |
| 32 | connection.access_rule = lambda state: lingo_can_use_entrance(state, target_region.name, door, world, player_logic) | 31 | connection.access_rule = lambda state: lingo_can_use_entrance(state, target_region.name, door, world) |
| 33 | 32 | ||
| 34 | source_region.exits.append(connection) | 33 | source_region.exits.append(connection) |
| 35 | connection.connect(target_region) | 34 | connection.connect(target_region) |
| 36 | 35 | ||
| 37 | if door is not None: | 36 | if door is not None: |
| 38 | effective_room = target_region.name if door.room is None else door.room | 37 | effective_room = target_region.name if door.room is None else door.room |
| 39 | if door.door not in player_logic.item_by_door.get(effective_room, {}): | 38 | if door.door not in world.player_logic.item_by_door.get(effective_room, {}): |
| 40 | for region in player_logic.calculate_door_requirements(effective_room, door.door, world).rooms: | 39 | for region in world.player_logic.calculate_door_requirements(effective_room, door.door, world).rooms: |
| 41 | world.multiworld.register_indirect_condition(regions[region], connection) | 40 | world.multiworld.register_indirect_condition(regions[region], connection) |
| 42 | 41 | ||
| 43 | 42 | ||
| 44 | def connect_painting(regions: Dict[str, Region], warp_enter: str, warp_exit: str, world: "LingoWorld", | 43 | def connect_painting(regions: Dict[str, Region], warp_enter: str, warp_exit: str, world: "LingoWorld") -> None: |
| 45 | player_logic: LingoPlayerLogic) -> None: | ||
| 46 | source_painting = PAINTINGS[warp_enter] | 44 | source_painting = PAINTINGS[warp_enter] |
| 47 | target_painting = PAINTINGS[warp_exit] | 45 | target_painting = PAINTINGS[warp_exit] |
| 48 | 46 | ||
| @@ -50,11 +48,10 @@ def connect_painting(regions: Dict[str, Region], warp_enter: str, warp_exit: str | |||
| 50 | source_region = regions[source_painting.room] | 48 | source_region = regions[source_painting.room] |
| 51 | 49 | ||
| 52 | entrance_name = f"{source_painting.room} to {target_painting.room} ({source_painting.id} Painting)" | 50 | entrance_name = f"{source_painting.room} to {target_painting.room} ({source_painting.id} Painting)" |
| 53 | connect_entrance(regions, source_region, target_region, entrance_name, source_painting.required_door, world, | 51 | connect_entrance(regions, source_region, target_region, entrance_name, source_painting.required_door, world) |
| 54 | player_logic) | ||
| 55 | 52 | ||
| 56 | 53 | ||
| 57 | def create_regions(world: "LingoWorld", player_logic: LingoPlayerLogic) -> None: | 54 | def create_regions(world: "LingoWorld") -> None: |
| 58 | regions = { | 55 | regions = { |
| 59 | "Menu": Region("Menu", world.player, world.multiworld) | 56 | "Menu": Region("Menu", world.player, world.multiworld) |
| 60 | } | 57 | } |
| @@ -64,7 +61,7 @@ def create_regions(world: "LingoWorld", player_logic: LingoPlayerLogic) -> None: | |||
| 64 | 61 | ||
| 65 | # Instantiate all rooms as regions with their locations first. | 62 | # Instantiate all rooms as regions with their locations first. |
| 66 | for room in ALL_ROOMS: | 63 | for room in ALL_ROOMS: |
| 67 | regions[room.name] = create_region(room, world, player_logic) | 64 | regions[room.name] = create_region(room, world) |
| 68 | 65 | ||
| 69 | # Connect all created regions now that they exist. | 66 | # Connect all created regions now that they exist. |
| 70 | for room in ALL_ROOMS: | 67 | for room in ALL_ROOMS: |
| @@ -80,18 +77,17 @@ def create_regions(world: "LingoWorld", player_logic: LingoPlayerLogic) -> None: | |||
| 80 | else: | 77 | else: |
| 81 | entrance_name += f" (through {room.name} - {entrance.door.door})" | 78 | entrance_name += f" (through {room.name} - {entrance.door.door})" |
| 82 | 79 | ||
| 83 | connect_entrance(regions, regions[entrance.room], regions[room.name], entrance_name, entrance.door, world, | 80 | connect_entrance(regions, regions[entrance.room], regions[room.name], entrance_name, entrance.door, world) |
| 84 | player_logic) | ||
| 85 | 81 | ||
| 86 | # Add the fake pilgrimage. | 82 | # Add the fake pilgrimage. |
| 87 | connect_entrance(regions, regions["Outside The Agreeable"], regions["Pilgrim Antechamber"], "Pilgrimage", | 83 | connect_entrance(regions, regions["Outside The Agreeable"], regions["Pilgrim Antechamber"], "Pilgrimage", |
| 88 | RoomAndDoor("Pilgrim Antechamber", "Pilgrimage"), world, player_logic) | 84 | RoomAndDoor("Pilgrim Antechamber", "Pilgrimage"), world) |
| 89 | 85 | ||
| 90 | if early_color_hallways: | 86 | if early_color_hallways: |
| 91 | regions["Starting Room"].connect(regions["Outside The Undeterred"], "Early Color Hallways") | 87 | regions["Starting Room"].connect(regions["Outside The Undeterred"], "Early Color Hallways") |
| 92 | 88 | ||
| 93 | if painting_shuffle: | 89 | if painting_shuffle: |
| 94 | for warp_enter, warp_exit in player_logic.painting_mapping.items(): | 90 | for warp_enter, warp_exit in world.player_logic.painting_mapping.items(): |
| 95 | connect_painting(regions, warp_enter, warp_exit, world, player_logic) | 91 | connect_painting(regions, warp_enter, warp_exit, world) |
| 96 | 92 | ||
| 97 | world.multiworld.regions += regions.values() | 93 | world.multiworld.regions += regions.values() |
