diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-10-06 09:58:45 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-10-06 09:58:45 -0400 |
commit | 9864382c9e4b2015c05214ebc177b410edc24bce (patch) | |
tree | 9c9ca3f93abc078a07d8a5a94c83152fd3eee642 /apworld/regions.py | |
parent | d861b203529add969038278dba9d2696d1248cc3 (diff) | |
download | lingo2-archipelago-9864382c9e4b2015c05214ebc177b410edc24bce.tar.gz lingo2-archipelago-9864382c9e4b2015c05214ebc177b410edc24bce.tar.bz2 lingo2-archipelago-9864382c9e4b2015c05214ebc177b410edc24bce.zip |
trying something cc-colors
Diffstat (limited to 'apworld/regions.py')
-rw-r--r-- | apworld/regions.py | 75 |
1 files changed, 54 insertions, 21 deletions
diff --git a/apworld/regions.py b/apworld/regions.py index 1215f5a..b5ec9c6 100644 --- a/apworld/regions.py +++ b/apworld/regions.py | |||
@@ -6,14 +6,14 @@ from entrance_rando import randomize_entrances | |||
6 | from .items import Lingo2Item | 6 | from .items import Lingo2Item |
7 | from .locations import Lingo2Location | 7 | from .locations import Lingo2Location |
8 | from .player_logic import AccessRequirements | 8 | from .player_logic import AccessRequirements |
9 | from .rules import make_location_lambda | 9 | from .rules import make_location_lambda, Lingo2Entrance, ControlCenterColor, CONTROL_CENTER_COLOR_NAMES, Lingo2Region |
10 | 10 | ||
11 | if TYPE_CHECKING: | 11 | if TYPE_CHECKING: |
12 | from . import Lingo2World | 12 | from . import Lingo2World |
13 | 13 | ||
14 | 14 | ||
15 | def create_region(room, world: "Lingo2World") -> Region: | 15 | def create_region(room, world: "Lingo2World") -> Region: |
16 | return Region(world.static_logic.get_room_region_name(room.id), world.player, world.multiworld) | 16 | return Lingo2Region(world.static_logic.get_room_region_name(room.id), world.player, world.multiworld) |
17 | 17 | ||
18 | 18 | ||
19 | def create_locations(room, new_region: Region, world: "Lingo2World", regions: dict[str, Region]): | 19 | def create_locations(room, new_region: Region, world: "Lingo2World", regions: dict[str, Region]): |
@@ -53,7 +53,7 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di | |||
53 | 53 | ||
54 | def create_regions(world: "Lingo2World"): | 54 | def create_regions(world: "Lingo2World"): |
55 | regions = { | 55 | regions = { |
56 | "Menu": Region("Menu", world.player, world.multiworld) | 56 | "Menu": Lingo2Region("Menu", world.player, world.multiworld) |
57 | } | 57 | } |
58 | 58 | ||
59 | region_and_room = [] | 59 | region_and_room = [] |
@@ -69,7 +69,10 @@ def create_regions(world: "Lingo2World"): | |||
69 | for (region, room) in region_and_room: | 69 | for (region, room) in region_and_room: |
70 | create_locations(room, region, world, regions) | 70 | create_locations(room, region, world, regions) |
71 | 71 | ||
72 | regions["Menu"].connect(regions["The Entry - Starting Room"], "Start Game") | 72 | start_game = Lingo2Entrance(world.player, "Start Game", regions["Menu"]) |
73 | start_game.set_lingo2_rule(world, regions, AccessRequirements(), ControlCenterColor.ALL) | ||
74 | regions["Menu"].exits.append(start_game) | ||
75 | start_game.connect(regions["The Entry - Starting Room"]) | ||
73 | 76 | ||
74 | for connection in world.static_logic.objects.connections: | 77 | for connection in world.static_logic.objects.connections: |
75 | if connection.roof_access and not world.options.daedalus_roof_access: | 78 | if connection.roof_access and not world.options.daedalus_roof_access: |
@@ -87,6 +90,7 @@ def create_regions(world: "Lingo2World"): | |||
87 | connection_name = f"{from_region} -> {to_region}" | 90 | connection_name = f"{from_region} -> {to_region}" |
88 | 91 | ||
89 | reqs = AccessRequirements() | 92 | reqs = AccessRequirements() |
93 | control_center_colors = ControlCenterColor.ALL | ||
90 | 94 | ||
91 | if connection.HasField("required_door"): | 95 | if connection.HasField("required_door"): |
92 | reqs.merge(world.player_logic.get_door_open_reqs(connection.required_door)) | 96 | reqs.merge(world.player_logic.get_door_open_reqs(connection.required_door)) |
@@ -95,6 +99,10 @@ def create_regions(world: "Lingo2World"): | |||
95 | wmap = world.static_logic.objects.maps[door.map_id] | 99 | wmap = world.static_logic.objects.maps[door.map_id] |
96 | connection_name = f"{connection_name} (using {wmap.name} - {door.name})" | 100 | connection_name = f"{connection_name} (using {wmap.name} - {door.name})" |
97 | 101 | ||
102 | if door.HasField("control_center_color"): | ||
103 | control_center_colors = control_center_colors & CONTROL_CENTER_COLOR_NAMES.get( | ||
104 | door.control_center_color, ControlCenterColor.NONE) | ||
105 | |||
98 | if connection.HasField("port"): | 106 | if connection.HasField("port"): |
99 | port = world.static_logic.objects.ports[connection.port] | 107 | port = world.static_logic.objects.ports[connection.port] |
100 | connection_name = f"{connection_name} (via {port.display_name})" | 108 | connection_name = f"{connection_name} (via {port.display_name})" |
@@ -105,6 +113,11 @@ def create_regions(world: "Lingo2World"): | |||
105 | if port.HasField("required_door"): | 113 | if port.HasField("required_door"): |
106 | reqs.merge(world.player_logic.get_door_open_reqs(port.required_door)) | 114 | reqs.merge(world.player_logic.get_door_open_reqs(port.required_door)) |
107 | 115 | ||
116 | req_door = world.static_logic.objects.doors[port.required_door] | ||
117 | if req_door.HasField("control_center_color"): | ||
118 | control_center_colors = control_center_colors & CONTROL_CENTER_COLOR_NAMES.get( | ||
119 | req_door.control_center_color, ControlCenterColor.NONE) | ||
120 | |||
108 | if connection.HasField("painting"): | 121 | if connection.HasField("painting"): |
109 | painting = world.static_logic.objects.paintings[connection.painting] | 122 | painting = world.static_logic.objects.paintings[connection.painting] |
110 | connection_name = f"{connection_name} (via painting {painting.name})" | 123 | connection_name = f"{connection_name} (via painting {painting.name})" |
@@ -112,6 +125,11 @@ def create_regions(world: "Lingo2World"): | |||
112 | if painting.HasField("required_door"): | 125 | if painting.HasField("required_door"): |
113 | reqs.merge(world.player_logic.get_door_open_reqs(painting.required_door)) | 126 | reqs.merge(world.player_logic.get_door_open_reqs(painting.required_door)) |
114 | 127 | ||
128 | req_door = world.static_logic.objects.doors[painting.required_door] | ||
129 | if req_door.HasField("control_center_color"): | ||
130 | control_center_colors = control_center_colors & CONTROL_CENTER_COLOR_NAMES.get( | ||
131 | req_door.control_center_color, ControlCenterColor.NONE) | ||
132 | |||
115 | if connection.HasField("panel"): | 133 | if connection.HasField("panel"): |
116 | proxy = connection.panel | 134 | proxy = connection.panel |
117 | reqs.merge(world.player_logic.get_panel_reqs(proxy.panel, | 135 | reqs.merge(world.player_logic.get_panel_reqs(proxy.panel, |
@@ -132,14 +150,14 @@ def create_regions(world: "Lingo2World"): | |||
132 | reqs.simplify() | 150 | reqs.simplify() |
133 | reqs.remove_room(from_region) | 151 | reqs.remove_room(from_region) |
134 | 152 | ||
135 | connection = Entrance(world.player, connection_name, regions[from_region]) | 153 | entrance = Lingo2Entrance(world.player, connection_name, regions[from_region]) |
136 | connection.access_rule = make_location_lambda(reqs, world, regions) | 154 | entrance.set_lingo2_rule(world, regions, reqs, control_center_colors) |
137 | 155 | ||
138 | regions[from_region].exits.append(connection) | 156 | regions[from_region].exits.append(entrance) |
139 | connection.connect(regions[to_region]) | 157 | entrance.connect(regions[to_region]) |
140 | 158 | ||
141 | for region in reqs.get_referenced_rooms(): | 159 | for region in reqs.get_referenced_rooms(): |
142 | world.multiworld.register_indirect_condition(regions[region], connection) | 160 | world.multiworld.register_indirect_condition(regions[region], entrance) |
143 | 161 | ||
144 | world.multiworld.regions += regions.values() | 162 | world.multiworld.regions += regions.values() |
145 | 163 | ||
@@ -160,19 +178,29 @@ def shuffle_entrances(world: "Lingo2World"): | |||
160 | connection_name = f"{port_region_name} - {port.display_name}" | 178 | connection_name = f"{port_region_name} - {port.display_name}" |
161 | port_id_by_name[connection_name] = port.id | 179 | port_id_by_name[connection_name] = port.id |
162 | 180 | ||
163 | entrance = port_region.create_er_target(connection_name) | 181 | entrance = Lingo2Entrance(world.player, connection_name) |
182 | entrance.connect(port_region) | ||
164 | entrance.randomization_type = BaseClasses.EntranceType.TWO_WAY | 183 | entrance.randomization_type = BaseClasses.EntranceType.TWO_WAY |
165 | 184 | ||
166 | er_exit = port_region.create_exit(connection_name) | 185 | er_exit = Lingo2Entrance(world.player, connection_name, port_region) |
186 | port_region.exits.append(er_exit) | ||
167 | er_exit.randomization_type = BaseClasses.EntranceType.TWO_WAY | 187 | er_exit.randomization_type = BaseClasses.EntranceType.TWO_WAY |
168 | 188 | ||
189 | door_reqs = AccessRequirements() | ||
190 | control_center_colors = ControlCenterColor.ALL | ||
169 | if port.HasField("required_door"): | 191 | if port.HasField("required_door"): |
170 | door_reqs = world.player_logic.get_door_open_reqs(port.required_door) | 192 | door_reqs = world.player_logic.get_door_open_reqs(port.required_door) |
171 | er_exit.access_rule = make_location_lambda(door_reqs, world, None) | ||
172 | 193 | ||
173 | for region in door_reqs.get_referenced_rooms(): | 194 | req_door = world.static_logic.objects.doors[port.required_door] |
174 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), | 195 | if req_door.HasField("control_center_color"): |
175 | er_exit) | 196 | control_center_colors = CONTROL_CENTER_COLOR_NAMES.get(req_door.control_center_color, |
197 | ControlCenterColor.NONE) | ||
198 | |||
199 | er_exit.set_lingo2_rule(world, None, door_reqs, control_center_colors) | ||
200 | |||
201 | for region in door_reqs.get_referenced_rooms(): | ||
202 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), | ||
203 | er_exit) | ||
176 | 204 | ||
177 | er_entrances.append(entrance) | 205 | er_entrances.append(entrance) |
178 | er_exits.append(er_exit) | 206 | er_exits.append(er_exit) |
@@ -195,21 +223,26 @@ def connect_ports_from_ut(port_pairings: dict[int, int], world: "Lingo2World"): | |||
195 | from_region = world.multiworld.get_region(from_region_name, world.player) | 223 | from_region = world.multiworld.get_region(from_region_name, world.player) |
196 | to_region = world.multiworld.get_region(to_region_name, world.player) | 224 | to_region = world.multiworld.get_region(to_region_name, world.player) |
197 | 225 | ||
198 | connection = Entrance(world.player, f"{from_region_name} - {from_port.display_name}", from_region) | 226 | connection = Lingo2Entrance(world.player, f"{from_region_name} - {from_port.display_name}", from_region) |
199 | 227 | ||
200 | reqs = AccessRequirements() | 228 | reqs = AccessRequirements() |
229 | control_center_colors = ControlCenterColor.ALL | ||
201 | if from_port.HasField("required_door"): | 230 | if from_port.HasField("required_door"): |
202 | reqs = world.player_logic.get_door_open_reqs(from_port.required_door).copy() | 231 | reqs = world.player_logic.get_door_open_reqs(from_port.required_door).copy() |
203 | 232 | ||
233 | req_door = world.static_logic.objects.doors[from_port.required_door] | ||
234 | if req_door.HasField("control_center_color"): | ||
235 | control_center_colors = CONTROL_CENTER_COLOR_NAMES.get(req_door.control_center_color, | ||
236 | ControlCenterColor.NONE) | ||
237 | |||
204 | if world.for_tracker: | 238 | if world.for_tracker: |
205 | reqs.items.add(f"Worldport {fpid} Entered") | 239 | reqs.items.add(f"Worldport {fpid} Entered") |
206 | 240 | ||
207 | if not reqs.is_empty(): | 241 | connection.set_lingo2_rule(world, None, reqs, control_center_colors) |
208 | connection.access_rule = make_location_lambda(reqs, world, None) | ||
209 | 242 | ||
210 | for region in reqs.get_referenced_rooms(): | 243 | for region in reqs.get_referenced_rooms(): |
211 | 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), |
212 | connection) | 245 | connection) |
213 | 246 | ||
214 | from_region.exits.append(connection) | 247 | from_region.exits.append(connection) |
215 | connection.connect(to_region) | 248 | connection.connect(to_region) |