diff options
Diffstat (limited to 'apworld/client/client.gd')
-rw-r--r-- | apworld/client/client.gd | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 286ad4b..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,8 @@ 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 | ||
39 | signal keyboard_update_received | ||
36 | 40 | ||
37 | 41 | ||
38 | func _init(): | 42 | func _init(): |
@@ -54,7 +58,9 @@ func _reset_state(): | |||
54 | _should_process = false | 58 | _should_process = false |
55 | _received_items = {} | 59 | _received_items = {} |
56 | _received_indexes = [] | 60 | _received_indexes = [] |
61 | _checked_worldports = [] | ||
57 | _accessible_locations = [] | 62 | _accessible_locations = [] |
63 | _accessible_worldports = [] | ||
58 | 64 | ||
59 | 65 | ||
60 | func disconnect_from_ap(): | 66 | func disconnect_from_ap(): |
@@ -116,6 +122,14 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
116 | 122 | ||
117 | checked_locations_updated.emit() | 123 | checked_locations_updated.emit() |
118 | 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 | |||
119 | elif cmd == "ItemReceived": | 133 | elif cmd == "ItemReceived": |
120 | for item in message["items"]: | 134 | for item in message["items"]: |
121 | var index = int(item["index"]) | 135 | var index = int(item["index"]) |
@@ -151,12 +165,24 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
151 | 165 | ||
152 | elif cmd == "AccessibleLocations": | 166 | elif cmd == "AccessibleLocations": |
153 | _accessible_locations.clear() | 167 | _accessible_locations.clear() |
168 | _accessible_worldports.clear() | ||
154 | 169 | ||
155 | for loc in message["locations"]: | 170 | for loc in message["locations"]: |
156 | _accessible_locations.append(int(loc)) | 171 | _accessible_locations.append(int(loc)) |
157 | 172 | ||
173 | if "worldports" in message: | ||
174 | for port_id in message["worldports"]: | ||
175 | _accessible_worldports.append(int(port_id)) | ||
176 | |||
158 | accessible_locations_updated.emit() | 177 | accessible_locations_updated.emit() |
159 | 178 | ||
179 | elif cmd == "UpdateKeyboard": | ||
180 | var updates = {} | ||
181 | for k in message["updates"]: | ||
182 | updates[k] = int(message["updates"][k]) | ||
183 | |||
184 | keyboard_update_received.emit(updates) | ||
185 | |||
160 | 186 | ||
161 | func connectToServer(server, un, pw): | 187 | func connectToServer(server, un, pw): |
162 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) | 188 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) |
@@ -202,19 +228,6 @@ func sendLocations(loc_ids): | |||
202 | sendMessage([{"cmd": "LocationChecks", "locations": loc_ids}]) | 228 | sendMessage([{"cmd": "LocationChecks", "locations": loc_ids}]) |
203 | 229 | ||
204 | 230 | ||
205 | func setValue(key, value, operation = "replace"): | ||
206 | sendMessage( | ||
207 | [ | ||
208 | { | ||
209 | "cmd": "Set", | ||
210 | "key": "Lingo2_%d_%s" % [_slot, key], | ||
211 | "want_reply": false, | ||
212 | "operations": [{"operation": operation, "value": value}] | ||
213 | } | ||
214 | ] | ||
215 | ) | ||
216 | |||
217 | |||
218 | func say(textdata): | 231 | func say(textdata): |
219 | sendMessage([{"cmd": "Say", "text": textdata}]) | 232 | sendMessage([{"cmd": "Say", "text": textdata}]) |
220 | 233 | ||
@@ -227,6 +240,15 @@ func scoutLocations(loc_ids): | |||
227 | sendMessage([{"cmd": "LocationScouts", "locations": loc_ids}]) | 240 | sendMessage([{"cmd": "LocationScouts", "locations": loc_ids}]) |
228 | 241 | ||
229 | 242 | ||
243 | func updateKeyboard(updates): | ||
244 | sendMessage([{"cmd": "UpdateKeyboard", "keyboard": updates}]) | ||
245 | |||
246 | |||
247 | func checkWorldport(port_id): | ||
248 | if not _checked_worldports.has(port_id): | ||
249 | sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}]) | ||
250 | |||
251 | |||
230 | func sendQuit(): | 252 | func sendQuit(): |
231 | sendMessage([{"cmd": "Quit"}]) | 253 | sendMessage([{"cmd": "Quit"}]) |
232 | 254 | ||