about summary refs log tree commit diff stats
path: root/Archipelago/client.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Archipelago/client.gd')
-rw-r--r--Archipelago/client.gd71
1 files changed, 57 insertions, 14 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index c690986..8a15d03 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd
@@ -18,7 +18,7 @@ var enable_multiplayer = false
18var track_player = false 18var track_player = false
19var connection_history = [] 19var connection_history = []
20 20
21const my_version = "3.0.1" 21const my_version = "3.2.1"
22const ap_version = {"major": 0, "minor": 4, "build": 6, "class": "Version"} 22const ap_version = {"major": 0, "minor": 4, "build": 6, "class": "Version"}
23const color_items = [ 23const color_items = [
24 "White", "Black", "Red", "Blue", "Green", "Brown", "Gray", "Orange", "Purple", "Yellow" 24 "White", "Black", "Red", "Blue", "Green", "Brown", "Gray", "Orange", "Purple", "Yellow"
@@ -81,6 +81,7 @@ var _team = 0
81var _slot = 0 81var _slot = 0
82var _players = [] 82var _players = []
83var _player_name_by_slot = {} 83var _player_name_by_slot = {}
84var _game_by_player = {}
84var _checked_locations = [] 85var _checked_locations = []
85var _slot_data = {} 86var _slot_data = {}
86var _paintings_mapping = {} 87var _paintings_mapping = {}
@@ -116,6 +117,7 @@ var _cached_slowness = 0
116var _cached_iceland = 0 117var _cached_iceland = 0
117var _cached_atbash = 0 118var _cached_atbash = 0
118var _geronimo_skip = false 119var _geronimo_skip = false
120var _checked_paintings = []
119 121
120signal could_not_connect 122signal could_not_connect
121signal connect_status 123signal connect_status
@@ -133,6 +135,10 @@ func _init():
133 var data = file.get_var(true) 135 var data = file.get_var(true)
134 file.close() 136 file.close()
135 137
138 if typeof(data) != TYPE_ARRAY:
139 global._print("AP settings file is corrupted")
140 data = []
141
136 if data.size() > 0: 142 if data.size() > 0:
137 ap_server = data[0] 143 ap_server = data[0]
138 if data.size() > 1: 144 if data.size() > 1:
@@ -257,6 +263,7 @@ func _on_data():
257 263
258 for player in _players: 264 for player in _players:
259 _player_name_by_slot[player["slot"]] = player["alias"] 265 _player_name_by_slot[player["slot"]] = player["alias"]
266 _game_by_player[player["slot"]] = message["slot_info"][str(player["slot"])]["game"]
260 267
261 _death_link = _slot_data.has("death_link") and _slot_data["death_link"] 268 _death_link = _slot_data.has("death_link") and _slot_data["death_link"]
262 if _death_link: 269 if _death_link:
@@ -340,6 +347,10 @@ func _on_data():
340 var localdata = ap_file.get_var(true) 347 var localdata = ap_file.get_var(true)
341 ap_file.close() 348 ap_file.close()
342 349
350 if typeof(localdata) != TYPE_ARRAY:
351 global._print("AP localdata file is corrupted")
352 localdata = []
353
343 if localdata.size() > 0: 354 if localdata.size() > 0:
344 _last_new_item = localdata[0] 355 _last_new_item = localdata[0]
345 else: 356 else:
@@ -370,6 +381,18 @@ func _on_data():
370 381
371 requestSync() 382 requestSync()
372 383
384 sendMessage(
385 [
386 {
387 "cmd": "Set",
388 "key": "Lingo_%d_Paintings" % [_slot],
389 "default": [],
390 "want_reply": true,
391 "operations": [{"operation": "default", "value": []}]
392 }
393 ]
394 )
395
373 emit_signal("client_connected") 396 emit_signal("client_connected")
374 397
375 elif cmd == "ConnectionRefused": 398 elif cmd == "ConnectionRefused":
@@ -437,12 +460,14 @@ func _on_data():
437 continue 460 continue
438 461
439 var item_name = "Unknown" 462 var item_name = "Unknown"
440 if _item_id_to_name.has(message["item"]["item"]): 463 var item_player_game = _game_by_player[message["receiving"]]
441 item_name = _item_id_to_name[message["item"]["item"]] 464 if _item_id_to_name[item_player_game].has(message["item"]["item"]):
465 item_name = _item_id_to_name[item_player_game][message["item"]["item"]]
442 466
443 var location_name = "Unknown" 467 var location_name = "Unknown"
444 if _location_id_to_name.has(message["item"]["location"]): 468 var location_player_game = _game_by_player[message["item"]["player"]]
445 location_name = _location_id_to_name[message["item"]["location"]] 469 if _location_id_to_name[location_player_game].has(message["item"]["location"]):
470 location_name = _location_id_to_name[location_player_game][message["item"]["location"]]
446 471
447 var player_name = "Unknown" 472 var player_name = "Unknown"
448 if _player_name_by_slot.has(message["receiving"]): 473 if _player_name_by_slot.has(message["receiving"]):
@@ -485,6 +510,10 @@ func _on_data():
485 # Return the player home. 510 # Return the player home.
486 get_tree().get_root().get_node("Spatial/player/pause_menu")._reload() 511 get_tree().get_root().get_node("Spatial/player/pause_menu")._reload()
487 512
513 elif cmd == "SetReply":
514 if message.has("key") and message["key"] == ("Lingo_%d_Paintings" % _slot):
515 _checked_paintings = message["value"]
516
488 517
489func _process(_delta): 518func _process(_delta):
490 if _should_process: 519 if _should_process:
@@ -592,12 +621,16 @@ func requestDatapackages(games):
592func processDatapackages(): 621func processDatapackages():
593 _item_id_to_name = {} 622 _item_id_to_name = {}
594 _location_id_to_name = {} 623 _location_id_to_name = {}
595 for package in _datapackages.values(): 624 for game in _datapackages.keys():
625 var package = _datapackages[game]
626
627 _item_id_to_name[game] = {}
596 for name in package["item_name_to_id"].keys(): 628 for name in package["item_name_to_id"].keys():
597 _item_id_to_name[package["item_name_to_id"][name]] = name 629 _item_id_to_name[game][package["item_name_to_id"][name]] = name
598 630
631 _location_id_to_name[game] = {}
599 for name in package["location_name_to_id"].keys(): 632 for name in package["location_name_to_id"].keys():
600 _location_id_to_name[package["location_name_to_id"][name]] = name 633 _location_id_to_name[game][package["location_name_to_id"][name]] = name
601 634
602 if _datapackages.has("Lingo"): 635 if _datapackages.has("Lingo"):
603 _item_name_to_id = _datapackages["Lingo"]["item_name_to_id"] 636 _item_name_to_id = _datapackages["Lingo"]["item_name_to_id"]
@@ -639,13 +672,14 @@ func sendLocation(loc_id):
639 _held_locations.append(loc_id) 672 _held_locations.append(loc_id)
640 673
641 674
642func setValue(key, value): 675func setValue(key, value, operation = "replace"):
643 sendMessage( 676 sendMessage(
644 [ 677 [
645 { 678 {
646 "cmd": "Set", 679 "cmd": "Set",
647 "key": "Lingo_%d_%s" % [_slot, key], 680 "key": "Lingo_%d_%s" % [_slot, key],
648 "operations": [{"operation": "replace", "value": value}] 681 "want_reply": false,
682 "operations": [{"operation": operation, "value": value}]
649 } 683 }
650 ] 684 ]
651 ) 685 )
@@ -686,8 +720,8 @@ func processItem(item, index, from, flags):
686 720
687 var gamedata = $Gamedata 721 var gamedata = $Gamedata
688 var item_name = "Unknown" 722 var item_name = "Unknown"
689 if _item_id_to_name.has(item): 723 if _item_id_to_name["Lingo"].has(item):
690 item_name = _item_id_to_name[item] 724 item_name = _item_id_to_name["Lingo"][item]
691 725
692 if gamedata.door_ids_by_item_id.has(int(item)): 726 if gamedata.door_ids_by_item_id.has(int(item)):
693 var doorsNode = get_tree().get_root().get_node("Spatial/Doors") 727 var doorsNode = get_tree().get_root().get_node("Spatial/Doors")
@@ -725,8 +759,8 @@ func processItem(item, index, from, flags):
725 processItem(subitem_id, null, null, null) 759 processItem(subitem_id, null, null, null)
726 _progressive_progress[int(item)] += 1 760 _progressive_progress[int(item)] += 1
727 761
728 if _color_shuffle and color_items.has(_item_id_to_name[item]): 762 if _color_shuffle and color_items.has(_item_id_to_name["Lingo"][item]):
729 var lcol = _item_id_to_name[item].to_lower() 763 var lcol = _item_id_to_name["Lingo"][item].to_lower()
730 if not _has_colors.has(lcol): 764 if not _has_colors.has(lcol):
731 _has_colors.append(lcol) 765 _has_colors.append(lcol)
732 emit_signal("evaluate_solvability") 766 emit_signal("evaluate_solvability")
@@ -801,6 +835,15 @@ func geronimo():
801 saveLocaldata() 835 saveLocaldata()
802 836
803 837
838func checkPainting(painting_id):
839 if _checked_paintings.has(painting_id):
840 return
841
842 _checked_paintings.append(painting_id)
843
844 setValue("Paintings", [painting_id], "add")
845
846
804func colorForItemType(flags): 847func colorForItemType(flags):
805 var int_flags = int(flags) 848 var int_flags = int(flags)
806 if int_flags & 1: # progression 849 if int_flags & 1: # progression