diff options
-rw-r--r-- | Archipelago/client.gd | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 78ac845..b3d1359 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -13,6 +13,7 @@ var _should_process = false | |||
13 | 13 | ||
14 | var _datapackages = {} | 14 | var _datapackages = {} |
15 | var _item_id_to_name = {} # All games | 15 | var _item_id_to_name = {} # All games |
16 | var _location_id_to_name = {} # All games | ||
16 | var _item_name_to_id = {} # LINGO only | 17 | var _item_name_to_id = {} # LINGO only |
17 | var _location_name_to_id = {} # LINGO only | 18 | var _location_name_to_id = {} # LINGO only |
18 | 19 | ||
@@ -24,6 +25,7 @@ var _seed = "" | |||
24 | var _team = 0 | 25 | var _team = 0 |
25 | var _slot = 0 | 26 | var _slot = 0 |
26 | var _players = [] | 27 | var _players = [] |
28 | var _player_name_by_slot = {} | ||
27 | var _checked_locations = [] | 29 | var _checked_locations = [] |
28 | var _slot_data = {} | 30 | var _slot_data = {} |
29 | var _door_ids_by_item = {} | 31 | var _door_ids_by_item = {} |
@@ -110,7 +112,8 @@ func _on_data(): | |||
110 | connectToRoom() | 112 | connectToRoom() |
111 | 113 | ||
112 | elif cmd == "DataPackage": | 114 | elif cmd == "DataPackage": |
113 | _datapackages = message["data"]["games"] | 115 | for game in message["data"]["games"].keys(): |
116 | _datapackages[game] = message["data"]["games"][game] | ||
114 | saveSettings() | 117 | saveSettings() |
115 | processDatapackages() | 118 | processDatapackages() |
116 | connectToRoom() | 119 | connectToRoom() |
@@ -123,6 +126,9 @@ func _on_data(): | |||
123 | _checked_locations = message["checked_locations"] | 126 | _checked_locations = message["checked_locations"] |
124 | _slot_data = message["slot_data"] | 127 | _slot_data = message["slot_data"] |
125 | 128 | ||
129 | for player in _players: | ||
130 | _player_name_by_slot[player["slot"]] = player["alias"] | ||
131 | |||
126 | if _slot_data.has("door_ids_by_item_id"): | 132 | if _slot_data.has("door_ids_by_item_id"): |
127 | _door_ids_by_item = _slot_data["door_ids_by_item_id"] | 133 | _door_ids_by_item = _slot_data["door_ids_by_item_id"] |
128 | 134 | ||
@@ -181,6 +187,39 @@ func _on_data(): | |||
181 | ) | 187 | ) |
182 | i += 1 | 188 | i += 1 |
183 | 189 | ||
190 | elif cmd == "PrintJSON": | ||
191 | if ( | ||
192 | !message.has("receiving") | ||
193 | or !message.has("item") | ||
194 | or message["item"]["player"] != _slot | ||
195 | ): | ||
196 | continue | ||
197 | |||
198 | var item_name = "Unknown" | ||
199 | if _item_id_to_name.has(message["item"]["item"]): | ||
200 | item_name = _item_id_to_name[message["item"]["item"]] | ||
201 | |||
202 | var location_name = "Unknown" | ||
203 | if _location_id_to_name.has(message["item"]["location"]): | ||
204 | location_name = _location_id_to_name[message["item"]["location"]] | ||
205 | |||
206 | var player_name = "Unknown" | ||
207 | if _player_name_by_slot.has(message["receiving"]): | ||
208 | player_name = _player_name_by_slot[message["receiving"]] | ||
209 | |||
210 | var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages") | ||
211 | if message["type"] == "Hint": | ||
212 | var is_for = "" | ||
213 | if message["receiving"] != _slot: | ||
214 | is_for = " for %s" % player_name | ||
215 | if !message.has("found") || !message["found"]: | ||
216 | messages_node.showMessage( | ||
217 | "Hint: %s%s is on %s" % [item_name, is_for, location_name] | ||
218 | ) | ||
219 | else: | ||
220 | if message["receiving"] != _slot: | ||
221 | messages_node.showMessage("Sent %s to %s" % [item_name, player_name]) | ||
222 | |||
184 | 223 | ||
185 | func _process(_delta): | 224 | func _process(_delta): |
186 | if _should_process: | 225 | if _should_process: |
@@ -246,10 +285,14 @@ func requestDatapackages(games): | |||
246 | 285 | ||
247 | func processDatapackages(): | 286 | func processDatapackages(): |
248 | _item_id_to_name = {} | 287 | _item_id_to_name = {} |
288 | _location_id_to_name = {} | ||
249 | for package in _datapackages.values(): | 289 | for package in _datapackages.values(): |
250 | for name in package["item_name_to_id"].keys(): | 290 | for name in package["item_name_to_id"].keys(): |
251 | _item_id_to_name[package["item_name_to_id"][name]] = name | 291 | _item_id_to_name[package["item_name_to_id"][name]] = name |
252 | 292 | ||
293 | for name in package["location_name_to_id"].keys(): | ||
294 | _location_id_to_name[package["location_name_to_id"][name]] = name | ||
295 | |||
253 | if _datapackages.has("Lingo"): | 296 | if _datapackages.has("Lingo"): |
254 | _item_name_to_id = _datapackages["Lingo"]["item_name_to_id"] | 297 | _item_name_to_id = _datapackages["Lingo"]["item_name_to_id"] |
255 | _location_name_to_id = _datapackages["Lingo"]["location_name_to_id"] | 298 | _location_name_to_id = _datapackages["Lingo"]["location_name_to_id"] |
@@ -280,9 +323,6 @@ func requestSync(): | |||
280 | func sendLocation(loc_id): | 323 | func sendLocation(loc_id): |
281 | if _map_loaded: | 324 | if _map_loaded: |
282 | sendMessage([{"cmd": "LocationChecks", "locations": [loc_id]}]) | 325 | sendMessage([{"cmd": "LocationChecks", "locations": [loc_id]}]) |
283 | |||
284 | var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages") | ||
285 | messages_node.showMessage("Sent %d" % loc_id) | ||
286 | else: | 326 | else: |
287 | _held_locations.append(loc_id) | 327 | _held_locations.append(loc_id) |
288 | 328 | ||
@@ -333,11 +373,15 @@ func processItem(item, index, from): | |||
333 | if _item_id_to_name.has(item): | 373 | if _item_id_to_name.has(item): |
334 | item_name = _item_id_to_name[item] | 374 | item_name = _item_id_to_name[item] |
335 | 375 | ||
376 | var player_name = "Unknown" | ||
377 | if _player_name_by_slot.has(from): | ||
378 | player_name = _player_name_by_slot[from] | ||
379 | |||
336 | var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages") | 380 | var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages") |
337 | if from == _slot: | 381 | if from == _slot: |
338 | messages_node.showMessage("Found %s" % item_name) | 382 | messages_node.showMessage("Found %s" % item_name) |
339 | else: | 383 | else: |
340 | messages_node.showMessage("Received %s from %d" % [item_name, from]) | 384 | messages_node.showMessage("Received %s from %s" % [item_name, player_name]) |
341 | 385 | ||
342 | 386 | ||
343 | func doorIsVanilla(door): | 387 | func doorIsVanilla(door): |