diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-27 21:06:32 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-27 21:06:32 -0400 |
| commit | 53e0509fcb20cc824e3fe5b3d3a826f09fc9c166 (patch) | |
| tree | d83573fe2209122cc1c87d0a60ab22e6b20d4ec9 /apworld | |
| parent | b0f474bee1c8e1111f7542bf4985136d9aedf340 (diff) | |
| download | lingo2-archipelago-53e0509fcb20cc824e3fe5b3d3a826f09fc9c166.tar.gz lingo2-archipelago-53e0509fcb20cc824e3fe5b3d3a826f09fc9c166.tar.bz2 lingo2-archipelago-53e0509fcb20cc824e3fe5b3d3a826f09fc9c166.zip | |
Treat worldports as items for tracker
Diffstat (limited to 'apworld')
| -rw-r--r-- | apworld/client/client.gd | 23 | ||||
| -rw-r--r-- | apworld/client/gamedata.gd | 5 | ||||
| -rw-r--r-- | apworld/client/manager.gd | 8 | ||||
| -rw-r--r-- | apworld/client/textclient.gd | 5 | ||||
| -rw-r--r-- | apworld/client/worldport.gd | 10 | ||||
| -rw-r--r-- | apworld/context.py | 72 | ||||
| -rw-r--r-- | apworld/locations.py | 2 | ||||
| -rw-r--r-- | apworld/regions.py | 29 | ||||
| -rw-r--r-- | apworld/tracker.py | 15 |
9 files changed, 157 insertions, 12 deletions
| diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 3d4096f..a23e85a 100644 --- a/apworld/client/client.gd +++ b/apworld/client/client.gd | |||
| @@ -18,10 +18,12 @@ var _seed = "" | |||
| 18 | var _team = 0 | 18 | var _team = 0 |
| 19 | var _slot = 0 | 19 | var _slot = 0 |
| 20 | var _checked_locations = [] | 20 | var _checked_locations = [] |
| 21 | var _checked_worldports = [] | ||
| 21 | var _received_indexes = [] | 22 | var _received_indexes = [] |
| 22 | var _received_items = {} | 23 | var _received_items = {} |
| 23 | var _slot_data = {} | 24 | var _slot_data = {} |
| 24 | var _accessible_locations = [] | 25 | var _accessible_locations = [] |
| 26 | var _accessible_worldports = [] | ||
| 25 | 27 | ||
| 26 | signal could_not_connect | 28 | signal could_not_connect |
| 27 | signal connect_status | 29 | signal connect_status |
| @@ -33,6 +35,7 @@ signal item_sent_notification(message) | |||
| 33 | signal hint_received(message) | 35 | signal hint_received(message) |
| 34 | signal accessible_locations_updated | 36 | signal accessible_locations_updated |
| 35 | signal checked_locations_updated | 37 | signal checked_locations_updated |
| 38 | signal checked_worldports_updated | ||
| 36 | signal keyboard_update_received | 39 | signal keyboard_update_received |
| 37 | 40 | ||
| 38 | 41 | ||
| @@ -55,7 +58,9 @@ func _reset_state(): | |||
| 55 | _should_process = false | 58 | _should_process = false |
| 56 | _received_items = {} | 59 | _received_items = {} |
| 57 | _received_indexes = [] | 60 | _received_indexes = [] |
| 61 | _checked_worldports = [] | ||
| 58 | _accessible_locations = [] | 62 | _accessible_locations = [] |
| 63 | _accessible_worldports = [] | ||
| 59 | 64 | ||
| 60 | 65 | ||
| 61 | func disconnect_from_ap(): | 66 | func disconnect_from_ap(): |
| @@ -117,6 +122,14 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
| 117 | 122 | ||
| 118 | checked_locations_updated.emit() | 123 | checked_locations_updated.emit() |
| 119 | 124 | ||
| 125 | elif cmd == "UpdateWorldports": | ||
| 126 | for port_id in message["worldports"]: | ||
| 127 | var lint = int(port_id) | ||
| 128 | if not _checked_worldports.has(lint): | ||
| 129 | _checked_worldports.append(lint) | ||
| 130 | |||
| 131 | checked_worldports_updated.emit() | ||
| 132 | |||
| 120 | elif cmd == "ItemReceived": | 133 | elif cmd == "ItemReceived": |
| 121 | for item in message["items"]: | 134 | for item in message["items"]: |
| 122 | var index = int(item["index"]) | 135 | var index = int(item["index"]) |
| @@ -152,10 +165,15 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
| 152 | 165 | ||
| 153 | elif cmd == "AccessibleLocations": | 166 | elif cmd == "AccessibleLocations": |
| 154 | _accessible_locations.clear() | 167 | _accessible_locations.clear() |
| 168 | _accessible_worldports.clear() | ||
| 155 | 169 | ||
| 156 | for loc in message["locations"]: | 170 | for loc in message["locations"]: |
| 157 | _accessible_locations.append(int(loc)) | 171 | _accessible_locations.append(int(loc)) |
| 158 | 172 | ||
| 173 | if "worldports" in message: | ||
| 174 | for port_id in message["worldports"]: | ||
| 175 | _accessible_worldports.append(int(port_id)) | ||
| 176 | |||
| 159 | accessible_locations_updated.emit() | 177 | accessible_locations_updated.emit() |
| 160 | 178 | ||
| 161 | elif cmd == "UpdateKeyboard": | 179 | elif cmd == "UpdateKeyboard": |
| @@ -226,6 +244,11 @@ func updateKeyboard(updates): | |||
| 226 | sendMessage([{"cmd": "UpdateKeyboard", "keyboard": updates}]) | 244 | sendMessage([{"cmd": "UpdateKeyboard", "keyboard": updates}]) |
| 227 | 245 | ||
| 228 | 246 | ||
| 247 | func checkWorldport(port_id): | ||
| 248 | if not _checked_worldports.has(port_id): | ||
| 249 | sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}]) | ||
| 250 | |||
| 251 | |||
| 229 | func sendQuit(): | 252 | func sendQuit(): |
| 230 | sendMessage([{"cmd": "Quit"}]) | 253 | sendMessage([{"cmd": "Quit"}]) |
| 231 | 254 | ||
| diff --git a/apworld/client/gamedata.gd b/apworld/client/gamedata.gd index 13ec568..e44fa17 100644 --- a/apworld/client/gamedata.gd +++ b/apworld/client/gamedata.gd | |||
| @@ -173,6 +173,11 @@ func get_door_receivers(door_id): | |||
| 173 | return door.get_receivers() | 173 | return door.get_receivers() |
| 174 | 174 | ||
| 175 | 175 | ||
| 176 | func get_worldport_display_name(port_id): | ||
| 177 | var port = objects.get_ports()[port_id] | ||
| 178 | return "%s - %s (Worldport)" % [_get_room_object_map_name(port), port.get_name()] | ||
| 179 | |||
| 180 | |||
| 176 | func _get_map_object_map_name(obj): | 181 | func _get_map_object_map_name(obj): |
| 177 | return objects.get_maps()[obj.get_map_id()].get_display_name() | 182 | return objects.get_maps()[obj.get_map_id()].get_display_name() |
| 178 | 183 | ||
| diff --git a/apworld/client/manager.gd b/apworld/client/manager.gd index afa3ebe..3facfba 100644 --- a/apworld/client/manager.gd +++ b/apworld/client/manager.gd | |||
| @@ -109,6 +109,7 @@ func _ready(): | |||
| 109 | client.hint_received.connect(_process_hint_received) | 109 | client.hint_received.connect(_process_hint_received) |
| 110 | client.accessible_locations_updated.connect(_on_accessible_locations_updated) | 110 | client.accessible_locations_updated.connect(_on_accessible_locations_updated) |
| 111 | client.checked_locations_updated.connect(_on_checked_locations_updated) | 111 | client.checked_locations_updated.connect(_on_checked_locations_updated) |
| 112 | client.checked_worldports_updated.connect(_on_checked_worldports_updated) | ||
| 112 | 113 | ||
| 113 | client.could_not_connect.connect(_client_could_not_connect) | 114 | client.could_not_connect.connect(_client_could_not_connect) |
| 114 | client.connect_status.connect(_client_connect_status) | 115 | client.connect_status.connect(_client_connect_status) |
| @@ -195,6 +196,7 @@ func _process_item(item, amount): | |||
| 195 | if gamedata.get_door_map_name(lock[0]) != global.map: | 196 | if gamedata.get_door_map_name(lock[0]) != global.map: |
| 196 | continue | 197 | continue |
| 197 | 198 | ||
| 199 | # TODO: fix doors opening from door groups | ||
| 198 | var receivers = gamedata.get_door_receivers(lock[0]) | 200 | var receivers = gamedata.get_door_receivers(lock[0]) |
| 199 | var scene = get_tree().get_root().get_node_or_null("scene") | 201 | var scene = get_tree().get_root().get_node_or_null("scene") |
| 200 | if scene != null: | 202 | if scene != null: |
| @@ -327,6 +329,12 @@ func _on_checked_locations_updated(): | |||
| 327 | textclient_node.update_locations() | 329 | textclient_node.update_locations() |
| 328 | 330 | ||
| 329 | 331 | ||
| 332 | func _on_checked_worldports_updated(): | ||
| 333 | var textclient_node = global.get_node("Textclient") | ||
| 334 | if textclient_node != null: | ||
| 335 | textclient_node.update_locations() | ||
| 336 | |||
| 337 | |||
| 330 | func _client_could_not_connect(message): | 338 | func _client_could_not_connect(message): |
| 331 | could_not_connect.emit(message) | 339 | could_not_connect.emit(message) |
| 332 | 340 | ||
| diff --git a/apworld/client/textclient.gd b/apworld/client/textclient.gd index 1b36c29..af155fb 100644 --- a/apworld/client/textclient.gd +++ b/apworld/client/textclient.gd | |||
| @@ -150,6 +150,11 @@ func update_locations(): | |||
| 150 | var location_name = gamedata.location_name_by_id.get(location_id, "(Unknown)") | 150 | var location_name = gamedata.location_name_by_id.get(location_id, "(Unknown)") |
| 151 | location_names.append(location_name) | 151 | location_names.append(location_name) |
| 152 | 152 | ||
| 153 | for port_id in ap.client._accessible_worldports: | ||
| 154 | if not ap.client._checked_worldports.has(port_id): | ||
| 155 | var port_name = gamedata.get_worldport_display_name(port_id) | ||
| 156 | location_names.append(port_name) | ||
| 157 | |||
| 153 | location_names.sort() | 158 | location_names.sort() |
| 154 | 159 | ||
| 155 | var count = 0 | 160 | var count = 0 |
| diff --git a/apworld/client/worldport.gd b/apworld/client/worldport.gd index cdca248..ed9891e 100644 --- a/apworld/client/worldport.gd +++ b/apworld/client/worldport.gd | |||
| @@ -3,6 +3,8 @@ extends "res://scripts/nodes/worldport.gd" | |||
| 3 | var absolute_rotation = false | 3 | var absolute_rotation = false |
| 4 | var target_rotation = 0 | 4 | var target_rotation = 0 |
| 5 | 5 | ||
| 6 | var port_id = null | ||
| 7 | |||
| 6 | 8 | ||
| 7 | func _ready(): | 9 | func _ready(): |
| 8 | var node_path = String( | 10 | var node_path = String( |
| @@ -13,7 +15,7 @@ func _ready(): | |||
| 13 | 15 | ||
| 14 | if ap.shuffle_worldports: | 16 | if ap.shuffle_worldports: |
| 15 | var gamedata = global.get_node("Gamedata") | 17 | var gamedata = global.get_node("Gamedata") |
| 16 | var port_id = gamedata.get_port_for_map_node_path(global.map, node_path) | 18 | port_id = gamedata.get_port_for_map_node_path(global.map, node_path) |
| 17 | if port_id != null: | 19 | if port_id != null: |
| 18 | if port_id in ap.port_pairings: | 20 | if port_id in ap.port_pairings: |
| 19 | var target_port = gamedata.objects.get_ports()[ap.port_pairings[port_id]] | 21 | var target_port = gamedata.objects.get_ports()[ap.port_pairings[port_id]] |
| @@ -29,6 +31,8 @@ func _ready(): | |||
| 29 | sets_entry_point = true | 31 | sets_entry_point = true |
| 30 | invisible = false | 32 | invisible = false |
| 31 | fades = true | 33 | fades = true |
| 34 | else: | ||
| 35 | port_id = null | ||
| 32 | 36 | ||
| 33 | if global.map == "icarus" and exit == "daedalus": | 37 | if global.map == "icarus" and exit == "daedalus": |
| 34 | if not ap.daedalus_roof_access: | 38 | if not ap.daedalus_roof_access: |
| @@ -39,6 +43,10 @@ func _ready(): | |||
| 39 | 43 | ||
| 40 | func bodyEntered(body): | 44 | func bodyEntered(body): |
| 41 | if body.is_in_group("player"): | 45 | if body.is_in_group("player"): |
| 46 | if port_id != null: | ||
| 47 | var ap = global.get_node("Archipelago") | ||
| 48 | ap.client.checkWorldport(port_id) | ||
| 49 | |||
| 42 | if absolute_rotation: | 50 | if absolute_rotation: |
| 43 | entry_rotate.y = target_rotation - body.rotation_degrees.y | 51 | entry_rotate.y = target_rotation - body.rotation_degrees.y |
| 44 | 52 | ||
| diff --git a/apworld/context.py b/apworld/context.py index bc3b1bf..4a85868 100644 --- a/apworld/context.py +++ b/apworld/context.py | |||
| @@ -35,6 +35,7 @@ class Lingo2Manager: | |||
| 35 | tracker: Tracker | 35 | tracker: Tracker |
| 36 | 36 | ||
| 37 | keyboard: dict[str, int] | 37 | keyboard: dict[str, int] |
| 38 | worldports: set[int] | ||
| 38 | 39 | ||
| 39 | def __init__(self, game_ctx: "Lingo2GameContext", client_ctx: "Lingo2ClientContext"): | 40 | def __init__(self, game_ctx: "Lingo2GameContext", client_ctx: "Lingo2ClientContext"): |
| 40 | self.game_ctx = game_ctx | 41 | self.game_ctx = game_ctx |
| @@ -43,6 +44,7 @@ class Lingo2Manager: | |||
| 43 | self.client_ctx.manager = self | 44 | self.client_ctx.manager = self |
| 44 | self.tracker = Tracker(self) | 45 | self.tracker = Tracker(self) |
| 45 | self.keyboard = {} | 46 | self.keyboard = {} |
| 47 | self.worldports = set() | ||
| 46 | 48 | ||
| 47 | self.reset() | 49 | self.reset() |
| 48 | 50 | ||
| @@ -50,6 +52,8 @@ class Lingo2Manager: | |||
| 50 | for k in ALL_LETTERS: | 52 | for k in ALL_LETTERS: |
| 51 | self.keyboard[k] = 0 | 53 | self.keyboard[k] = 0 |
| 52 | 54 | ||
| 55 | self.worldports = set() | ||
| 56 | |||
| 53 | def update_keyboard(self, new_keyboard: dict[str, int]) -> dict[str, int]: | 57 | def update_keyboard(self, new_keyboard: dict[str, int]) -> dict[str, int]: |
| 54 | ret: dict[str, int] = {} | 58 | ret: dict[str, int] = {} |
| 55 | 59 | ||
| @@ -64,6 +68,16 @@ class Lingo2Manager: | |||
| 64 | 68 | ||
| 65 | return ret | 69 | return ret |
| 66 | 70 | ||
| 71 | def update_worldports(self, new_worldports: set[int]) -> set[int]: | ||
| 72 | ret = new_worldports.difference(self.worldports) | ||
| 73 | self.worldports.update(new_worldports) | ||
| 74 | |||
| 75 | if len(ret) > 0: | ||
| 76 | self.tracker.refresh_state() | ||
| 77 | self.game_ctx.send_accessible_locations() | ||
| 78 | |||
| 79 | return ret | ||
| 80 | |||
| 67 | 81 | ||
| 68 | class Lingo2GameContext: | 82 | class Lingo2GameContext: |
| 69 | server: Endpoint | None | 83 | server: Endpoint | None |
| @@ -160,6 +174,9 @@ class Lingo2GameContext: | |||
| 160 | "locations": list(self.manager.tracker.accessible_locations), | 174 | "locations": list(self.manager.tracker.accessible_locations), |
| 161 | } | 175 | } |
| 162 | 176 | ||
| 177 | if len(self.manager.tracker.accessible_worldports) > 0: | ||
| 178 | msg["worldports"] = list(self.manager.tracker.accessible_worldports) | ||
| 179 | |||
| 163 | async_start(self.send_msgs([msg]), name="accessible locations") | 180 | async_start(self.send_msgs([msg]), name="accessible locations") |
| 164 | 181 | ||
| 165 | def send_update_locations(self, locations): | 182 | def send_update_locations(self, locations): |
| @@ -184,6 +201,17 @@ class Lingo2GameContext: | |||
| 184 | 201 | ||
| 185 | async_start(self.send_msgs([msg]), name="update keyboard") | 202 | async_start(self.send_msgs([msg]), name="update keyboard") |
| 186 | 203 | ||
| 204 | def send_update_worldports(self, worldports): | ||
| 205 | if self.server is None: | ||
| 206 | return | ||
| 207 | |||
| 208 | msg = { | ||
| 209 | "cmd": "UpdateWorldports", | ||
| 210 | "worldports": worldports, | ||
| 211 | } | ||
| 212 | |||
| 213 | async_start(self.send_msgs([msg]), name="update worldports") | ||
| 214 | |||
| 187 | async def send_msgs(self, msgs: list[Any]) -> None: | 215 | async def send_msgs(self, msgs: list[Any]) -> None: |
| 188 | """ `msgs` JSON serializable """ | 216 | """ `msgs` JSON serializable """ |
| 189 | if not self.server or not self.server.socket.open or self.server.socket.closed: | 217 | if not self.server or not self.server.socket.open or self.server.socket.closed: |
| @@ -226,7 +254,7 @@ class Lingo2ClientContext(CommonContext): | |||
| 226 | self.manager.game_ctx.send_accessible_locations() | 254 | self.manager.game_ctx.send_accessible_locations() |
| 227 | 255 | ||
| 228 | self.set_notify(self.get_datastorage_key("keyboard1"), self.get_datastorage_key("keyboard2")) | 256 | self.set_notify(self.get_datastorage_key("keyboard1"), self.get_datastorage_key("keyboard2")) |
| 229 | async_start(self.send_msgs([{ | 257 | msg_batch = [{ |
| 230 | "cmd": "Set", | 258 | "cmd": "Set", |
| 231 | "key": self.get_datastorage_key("keyboard1"), | 259 | "key": self.get_datastorage_key("keyboard1"), |
| 232 | "default": 0, | 260 | "default": 0, |
| @@ -238,7 +266,19 @@ class Lingo2ClientContext(CommonContext): | |||
| 238 | "default": 0, | 266 | "default": 0, |
| 239 | "want_reply": True, | 267 | "want_reply": True, |
| 240 | "operations": [{"operation": "default", "value": 0}] | 268 | "operations": [{"operation": "default", "value": 0}] |
| 241 | }]), name="default keys") | 269 | }] |
| 270 | |||
| 271 | if self.slot_data["shuffle_worldports"]: | ||
| 272 | self.set_notify(self.get_datastorage_key("worldports")) | ||
| 273 | msg_batch.append({ | ||
| 274 | "cmd": "Set", | ||
| 275 | "key": self.get_datastorage_key("worldports"), | ||
| 276 | "default": [], | ||
| 277 | "want_reply": True, | ||
| 278 | "operations": [{"operation": "default", "value": []}] | ||
| 279 | }) | ||
| 280 | |||
| 281 | async_start(self.send_msgs(msg_batch), name="default keys") | ||
| 242 | elif cmd == "RoomUpdate": | 282 | elif cmd == "RoomUpdate": |
| 243 | self.manager.tracker.set_checked_locations(self.checked_locations) | 283 | self.manager.tracker.set_checked_locations(self.checked_locations) |
| 244 | self.manager.game_ctx.send_update_locations(args["checked_locations"]) | 284 | self.manager.game_ctx.send_update_locations(args["checked_locations"]) |
| @@ -276,7 +316,7 @@ class Lingo2ClientContext(CommonContext): | |||
| 276 | 316 | ||
| 277 | if args["type"] == "Hint" and not args.get("found", False): | 317 | if args["type"] == "Hint" and not args.get("found", False): |
| 278 | self.manager.game_ctx.send_hint_received(item_name, location_name, receiver_name, args["item"].flags, | 318 | self.manager.game_ctx.send_hint_received(item_name, location_name, receiver_name, args["item"].flags, |
| 279 | int(args["receiving"]) == self.slot) | 319 | int(args["receiving"]) == self.slot) |
| 280 | elif args["receiving"] != self.slot: | 320 | elif args["receiving"] != self.slot: |
| 281 | self.manager.game_ctx.send_item_sent_notification(item_name, receiver_name, args["item"].flags) | 321 | self.manager.game_ctx.send_item_sent_notification(item_name, receiver_name, args["item"].flags) |
| 282 | 322 | ||
| @@ -324,6 +364,10 @@ class Lingo2ClientContext(CommonContext): | |||
| 324 | self.handle_keyboard_update(1, args) | 364 | self.handle_keyboard_update(1, args) |
| 325 | elif args["key"] == self.get_datastorage_key("keyboard2"): | 365 | elif args["key"] == self.get_datastorage_key("keyboard2"): |
| 326 | self.handle_keyboard_update(2, args) | 366 | self.handle_keyboard_update(2, args) |
| 367 | elif args["key"] == self.get_datastorage_key("worldports"): | ||
| 368 | updates = self.manager.update_worldports(set(args["value"])) | ||
| 369 | if len(updates) > 0: | ||
| 370 | self.manager.game_ctx.send_update_worldports(updates) | ||
| 327 | 371 | ||
| 328 | def get_datastorage_key(self, name: str): | 372 | def get_datastorage_key(self, name: str): |
| 329 | return f"Lingo2_{self.slot}_{name}" | 373 | return f"Lingo2_{self.slot}_{name}" |
| @@ -373,8 +417,6 @@ class Lingo2ClientContext(CommonContext): | |||
| 373 | }) | 417 | }) |
| 374 | 418 | ||
| 375 | if len(msgs) > 0: | 419 | if len(msgs) > 0: |
| 376 | print(updates) | ||
| 377 | print(msgs) | ||
| 378 | await self.send_msgs(msgs) | 420 | await self.send_msgs(msgs) |
| 379 | 421 | ||
| 380 | def handle_keyboard_update(self, field: int, args: dict[str, Any]): | 422 | def handle_keyboard_update(self, field: int, args: dict[str, Any]): |
| @@ -391,6 +433,17 @@ class Lingo2ClientContext(CommonContext): | |||
| 391 | if len(updates) > 0: | 433 | if len(updates) > 0: |
| 392 | self.manager.game_ctx.send_update_keyboard(updates) | 434 | self.manager.game_ctx.send_update_keyboard(updates) |
| 393 | 435 | ||
| 436 | async def update_worldports(self, updates: set[int]): | ||
| 437 | await self.send_msgs([{ | ||
| 438 | "cmd": "Set", | ||
| 439 | "key": self.get_datastorage_key("worldports"), | ||
| 440 | "want_reply": True, | ||
| 441 | "operations": [{ | ||
| 442 | "operation": "update", | ||
| 443 | "value": updates | ||
| 444 | }] | ||
| 445 | }]) | ||
| 446 | |||
| 394 | 447 | ||
| 395 | async def pipe_loop(manager: Lingo2Manager): | 448 | async def pipe_loop(manager: Lingo2Manager): |
| 396 | while not manager.client_ctx.exit_event.is_set(): | 449 | while not manager.client_ctx.exit_event.is_set(): |
| @@ -433,6 +486,15 @@ async def process_game_cmd(manager: Lingo2Manager, args: dict): | |||
| 433 | updates = manager.update_keyboard(args["keyboard"]) | 486 | updates = manager.update_keyboard(args["keyboard"]) |
| 434 | if len(updates) > 0: | 487 | if len(updates) > 0: |
| 435 | async_start(manager.client_ctx.update_keyboard(updates), name="client update keyboard") | 488 | async_start(manager.client_ctx.update_keyboard(updates), name="client update keyboard") |
| 489 | elif cmd == "CheckWorldport": | ||
| 490 | port_id = args["port_id"] | ||
| 491 | worldports = {port_id} | ||
| 492 | if str(port_id) in manager.client_ctx.slot_data["port_pairings"]: | ||
| 493 | worldports.add(manager.client_ctx.slot_data["port_pairings"][str(port_id)]) | ||
| 494 | |||
| 495 | updates = manager.update_worldports(worldports) | ||
| 496 | if len(updates) > 0: | ||
| 497 | async_start(manager.client_ctx.update_worldports(updates), name="client update worldports") | ||
| 436 | elif cmd == "Quit": | 498 | elif cmd == "Quit": |
| 437 | manager.client_ctx.exit_event.set() | 499 | manager.client_ctx.exit_event.set() |
| 438 | 500 | ||
| diff --git a/apworld/locations.py b/apworld/locations.py index 108decb..a502931 100644 --- a/apworld/locations.py +++ b/apworld/locations.py | |||
| @@ -3,3 +3,5 @@ from BaseClasses import Location | |||
| 3 | 3 | ||
| 4 | class Lingo2Location(Location): | 4 | class Lingo2Location(Location): |
| 5 | game: str = "Lingo 2" | 5 | game: str = "Lingo 2" |
| 6 | |||
| 7 | port_id: int | ||
| diff --git a/apworld/regions.py b/apworld/regions.py index a7d9a1c..9f44682 100644 --- a/apworld/regions.py +++ b/apworld/regions.py | |||
| @@ -32,6 +32,22 @@ def create_locations(room, new_region: Region, world: "Lingo2World", regions: di | |||
| 32 | new_location.place_locked_item(event_item) | 32 | new_location.place_locked_item(event_item) |
| 33 | new_region.locations.append(new_location) | 33 | new_region.locations.append(new_location) |
| 34 | 34 | ||
| 35 | if world.for_tracker and world.options.shuffle_worldports: | ||
| 36 | for port_id in room.ports: | ||
| 37 | port = world.static_logic.objects.ports[port_id] | ||
| 38 | if port.no_shuffle: | ||
| 39 | continue | ||
| 40 | |||
| 41 | new_location = Lingo2Location(world.player, f"Worldport {port.id} Entered", None, new_region) | ||
| 42 | new_location.port_id = port.id | ||
| 43 | |||
| 44 | if port.HasField("required_door"): | ||
| 45 | new_location.access_rule = \ | ||
| 46 | make_location_lambda(world.player_logic.get_door_open_reqs(port.required_door), world, regions) | ||
| 47 | |||
| 48 | new_region.locations.append(new_location) | ||
| 49 | |||
| 50 | |||
| 35 | def create_regions(world: "Lingo2World"): | 51 | def create_regions(world: "Lingo2World"): |
| 36 | regions = { | 52 | regions = { |
| 37 | "Menu": Region("Menu", world.player, world.multiworld) | 53 | "Menu": Region("Menu", world.player, world.multiworld) |
| @@ -52,7 +68,6 @@ def create_regions(world: "Lingo2World"): | |||
| 52 | 68 | ||
| 53 | regions["Menu"].connect(regions["The Entry - Starting Room"], "Start Game") | 69 | regions["Menu"].connect(regions["The Entry - Starting Room"], "Start Game") |
| 54 | 70 | ||
| 55 | # TODO: The requirements of the opposite trigger also matter. | ||
| 56 | for connection in world.static_logic.objects.connections: | 71 | for connection in world.static_logic.objects.connections: |
| 57 | if connection.roof_access and not world.options.daedalus_roof_access: | 72 | if connection.roof_access and not world.options.daedalus_roof_access: |
| 58 | continue | 73 | continue |
| @@ -176,11 +191,17 @@ def connect_ports_from_ut(port_pairings: dict[int, int], world: "Lingo2World"): | |||
| 176 | 191 | ||
| 177 | connection = Entrance(world.player, f"{from_region_name} - {from_port.name}", from_region) | 192 | connection = Entrance(world.player, f"{from_region_name} - {from_port.name}", from_region) |
| 178 | 193 | ||
| 194 | reqs = AccessRequirements() | ||
| 179 | if from_port.HasField("required_door"): | 195 | if from_port.HasField("required_door"): |
| 180 | door_reqs = world.player_logic.get_door_open_reqs(from_port.required_door) | 196 | reqs = world.player_logic.get_door_open_reqs(from_port.required_door).copy() |
| 181 | connection.access_rule = make_location_lambda(door_reqs, world, None) | ||
| 182 | 197 | ||
| 183 | for region in door_reqs.get_referenced_rooms(): | 198 | if world.for_tracker: |
| 199 | reqs.items.add(f"Worldport {fpid} Entered") | ||
| 200 | |||
| 201 | if not reqs.is_empty(): | ||
| 202 | connection.access_rule = make_location_lambda(reqs, world, None) | ||
| 203 | |||
| 204 | for region in reqs.get_referenced_rooms(): | ||
| 184 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), | 205 | world.multiworld.register_indirect_condition(world.multiworld.get_region(region, world.player), |
| 185 | connection) | 206 | connection) |
| 186 | 207 | ||
| diff --git a/apworld/tracker.py b/apworld/tracker.py index 2c3d0f3..cf2dbe1 100644 --- a/apworld/tracker.py +++ b/apworld/tracker.py | |||
| @@ -21,6 +21,7 @@ class Tracker: | |||
| 21 | collected_items: dict[int, int] | 21 | collected_items: dict[int, int] |
| 22 | checked_locations: set[int] | 22 | checked_locations: set[int] |
| 23 | accessible_locations: set[int] | 23 | accessible_locations: set[int] |
| 24 | accessible_worldports: set[int] | ||
| 24 | 25 | ||
| 25 | state: CollectionState | 26 | state: CollectionState |
| 26 | 27 | ||
| @@ -29,6 +30,7 @@ class Tracker: | |||
| 29 | self.collected_items = {} | 30 | self.collected_items = {} |
| 30 | self.checked_locations = set() | 31 | self.checked_locations = set() |
| 31 | self.accessible_locations = set() | 32 | self.accessible_locations = set() |
| 33 | self.accessible_worldports = set() | ||
| 32 | 34 | ||
| 33 | def setup_slot(self, slot_data): | 35 | def setup_slot(self, slot_data): |
| 34 | Lingo2World.for_tracker = True | 36 | Lingo2World.for_tracker = True |
| @@ -84,12 +86,21 @@ class Tracker: | |||
| 84 | self.state.collect(Lingo2Item(k.upper(), ItemClassification.progression, None, PLAYER_NUM), | 86 | self.state.collect(Lingo2Item(k.upper(), ItemClassification.progression, None, PLAYER_NUM), |
| 85 | prevent_sweep=True) | 87 | prevent_sweep=True) |
| 86 | 88 | ||
| 89 | for port_id in self.manager.worldports: | ||
| 90 | self.state.collect(Lingo2Item(f"Worldport {port_id} Entered", ItemClassification.progression, None, | ||
| 91 | PLAYER_NUM), prevent_sweep=True) | ||
| 92 | |||
| 87 | self.state.sweep_for_advancements() | 93 | self.state.sweep_for_advancements() |
| 88 | 94 | ||
| 89 | self.accessible_locations = set() | 95 | self.accessible_locations = set() |
| 96 | self.accessible_worldports = set() | ||
| 90 | 97 | ||
| 91 | for region in self.state.reachable_regions[PLAYER_NUM]: | 98 | for region in self.state.reachable_regions[PLAYER_NUM]: |
| 92 | for location in region.locations: | 99 | for location in region.locations: |
| 93 | if location.address not in self.checked_locations and location.access_rule(self.state): | 100 | if location.access_rule(self.state): |
| 94 | if location.address is not None: | 101 | if location.address is not None: |
| 95 | self.accessible_locations.add(location.address) | 102 | if location.address not in self.checked_locations: |
| 103 | self.accessible_locations.add(location.address) | ||
| 104 | elif hasattr(location, "port_id"): | ||
| 105 | if location.port_id not in self.manager.worldports: | ||
| 106 | self.accessible_worldports.add(location.port_id) | ||
