about summary refs log tree commit diff stats
path: root/Archipelago/client.gd
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-09-02 11:49:12 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-09-02 11:49:12 -0400
commit400ad1ed74166d3f01adf6d97f07a16ec391f2a9 (patch)
tree74daf09a579867f1e8715d70a2797bd18025062e /Archipelago/client.gd
parent6b5b85f96fc855810ac21e96e1aeb9cbde0fe88e (diff)
downloadlingo-archipelago-400ad1ed74166d3f01adf6d97f07a16ec391f2a9.tar.gz
lingo-archipelago-400ad1ed74166d3f01adf6d97f07a16ec391f2a9.tar.bz2
lingo-archipelago-400ad1ed74166d3f01adf6d97f07a16ec391f2a9.zip
Added text client
Diffstat (limited to 'Archipelago/client.gd')
-rw-r--r--Archipelago/client.gd44
1 files changed, 44 insertions, 0 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index aa50069..f58b3d6 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd
@@ -8,6 +8,7 @@ var SCRIPT_mypainting
8var SCRIPT_notifier 8var SCRIPT_notifier
9var SCRIPT_panel 9var SCRIPT_panel
10var SCRIPT_pilgrimage_terminator 10var SCRIPT_pilgrimage_terminator
11var SCRIPT_textclient
11var SCRIPT_uuid 12var SCRIPT_uuid
12 13
13var ap_server = "" 14var ap_server = ""
@@ -451,6 +452,8 @@ func _on_data():
451 i += 1 452 i += 1
452 453
453 elif cmd == "PrintJSON": 454 elif cmd == "PrintJSON":
455 parse_printjson(message)
456
454 if ( 457 if (
455 !message.has("receiving") 458 !message.has("receiving")
456 or !message.has("item") 459 or !message.has("item")
@@ -684,6 +687,10 @@ func setValue(key, value, operation = "replace"):
684 ) 687 )
685 688
686 689
690func say(textdata):
691 sendMessage([{"cmd": "Say", "text": textdata}])
692
693
687func completedGoal(): 694func completedGoal():
688 sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL 695 sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL
689 696
@@ -855,6 +862,43 @@ func colorForItemType(flags):
855 return "#14de9e" 862 return "#14de9e"
856 863
857 864
865func parse_printjson(message):
866 var parts = []
867 for message_part in message["data"]:
868 if !message_part.has("type") and message_part.has("text"):
869 parts.append(message_part["text"])
870 elif message_part["type"] == "player_id":
871 if int(message_part["text"]) == _slot:
872 parts.append("[color=#ee00ee]%s[/color]" % _player_name_by_slot[_slot])
873 else:
874 var from = float(message_part["text"])
875 parts.append("[color=#fafad2]%s[/color]" % _player_name_by_slot[from])
876 elif message_part["type"] == "item_id":
877 var item_name = "Unknown"
878 var item_player_game = _game_by_player[message_part["player"]]
879 if _item_id_to_name[item_player_game].has(float(message_part["text"])):
880 item_name = _item_id_to_name[item_player_game][float(message_part["text"])]
881
882 parts.append(
883 "[color=%s]%s[/color]" % [colorForItemType(message_part["flags"]), item_name]
884 )
885 elif message_part["type"] == "location_id":
886 var location_name = "Unknown"
887 var location_player_game = _game_by_player[message_part["player"]]
888 if _location_id_to_name[location_player_game].has(float(message_part["text"])):
889 location_name = _location_id_to_name[location_player_game][float(
890 message_part["text"]
891 )]
892
893 parts.append("[color=#00ff7f]%s[/color]" % location_name)
894 elif message_part.has("text"):
895 parts.append(message_part["text"])
896
897 var textclient_node = get_tree().get_root().get_node_or_null("Spatial/AP_TextClient")
898 if textclient_node != null:
899 textclient_node.parse_printjson("".join(parts))
900
901
858func compareVersion(lhs, rhs): 902func compareVersion(lhs, rhs):
859 if lhs["major"] == rhs["major"]: 903 if lhs["major"] == rhs["major"]:
860 if lhs["minor"] == rhs["minor"]: 904 if lhs["minor"] == rhs["minor"]: