about summary refs log tree commit diff stats
path: root/apworld/client/client.gd
diff options
context:
space:
mode:
Diffstat (limited to 'apworld/client/client.gd')
-rw-r--r--apworld/client/client.gd23
1 files changed, 23 insertions, 0 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 = ""
18var _team = 0 18var _team = 0
19var _slot = 0 19var _slot = 0
20var _checked_locations = [] 20var _checked_locations = []
21var _checked_worldports = []
21var _received_indexes = [] 22var _received_indexes = []
22var _received_items = {} 23var _received_items = {}
23var _slot_data = {} 24var _slot_data = {}
24var _accessible_locations = [] 25var _accessible_locations = []
26var _accessible_worldports = []
25 27
26signal could_not_connect 28signal could_not_connect
27signal connect_status 29signal connect_status
@@ -33,6 +35,7 @@ signal item_sent_notification(message)
33signal hint_received(message) 35signal hint_received(message)
34signal accessible_locations_updated 36signal accessible_locations_updated
35signal checked_locations_updated 37signal checked_locations_updated
38signal checked_worldports_updated
36signal keyboard_update_received 39signal 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
61func disconnect_from_ap(): 66func 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
247func checkWorldport(port_id):
248 if not _checked_worldports.has(port_id):
249 sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}])
250
251
229func sendQuit(): 252func sendQuit():
230 sendMessage([{"cmd": "Quit"}]) 253 sendMessage([{"cmd": "Quit"}])
231 254