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.gd25
1 files changed, 24 insertions, 1 deletions
diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 67edf29..05b2b6c 100644 --- a/apworld/client/client.gd +++ b/apworld/client/client.gd
@@ -21,6 +21,7 @@ var _checked_locations = []
21var _received_indexes = [] 21var _received_indexes = []
22var _received_items = {} 22var _received_items = {}
23var _slot_data = {} 23var _slot_data = {}
24var _accessible_locations = []
24 25
25signal could_not_connect 26signal could_not_connect
26signal connect_status 27signal connect_status
@@ -30,6 +31,8 @@ signal location_scout_received(location_id, item_name, player_name, flags, for_s
30signal text_message_received(message) 31signal text_message_received(message)
31signal item_sent_notification(message) 32signal item_sent_notification(message)
32signal hint_received(message) 33signal hint_received(message)
34signal accessible_locations_updated
35signal checked_locations_updated
33 36
34 37
35func _init(): 38func _init():
@@ -51,6 +54,7 @@ func _reset_state():
51 _should_process = false 54 _should_process = false
52 _received_items = {} 55 _received_items = {}
53 _received_indexes = [] 56 _received_indexes = []
57 _accessible_locations = []
54 58
55 59
56func disconnect_from_ap(): 60func disconnect_from_ap():
@@ -92,15 +96,26 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo
92 _gen_version = message["generator_version"] 96 _gen_version = message["generator_version"]
93 _team = message["team"] 97 _team = message["team"]
94 _slot = message["slot"] 98 _slot = message["slot"]
95 _checked_locations = message["checked_locations"]
96 _slot_data = message["slot_data"] 99 _slot_data = message["slot_data"]
97 100
101 _checked_locations = []
102 for location in message["checked_locations"]:
103 _checked_locations.append(int(message["checked_locations"]))
104
98 client_connected.emit(_slot_data) 105 client_connected.emit(_slot_data)
99 106
100 elif cmd == "ConnectionRefused": 107 elif cmd == "ConnectionRefused":
101 could_not_connect.emit(message["text"]) 108 could_not_connect.emit(message["text"])
102 global._print("Connection to AP refused") 109 global._print("Connection to AP refused")
103 110
111 elif cmd == "UpdateLocations":
112 for location in message["locations"]:
113 var lint = int(location)
114 if not _checked_locations.has(lint):
115 _checked_locations.append(lint)
116
117 checked_locations_updated.emit()
118
104 elif cmd == "ItemReceived": 119 elif cmd == "ItemReceived":
105 for item in message["items"]: 120 for item in message["items"]:
106 var index = int(item["index"]) 121 var index = int(item["index"])
@@ -134,6 +149,14 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo
134 int(loc["for_self"]) 149 int(loc["for_self"])
135 ) 150 )
136 151
152 elif cmd == "AccessibleLocations":
153 _accessible_locations.clear()
154
155 for loc in message["locations"]:
156 _accessible_locations.append(int(loc))
157
158 accessible_locations_updated.emit()
159
137 160
138func connectToServer(server, un, pw): 161func connectToServer(server, un, pw):
139 sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) 162 sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}])