diff options
Diffstat (limited to 'apworld/client/client.gd')
-rw-r--r-- | apworld/client/client.gd | 25 |
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 = [] | |||
21 | var _received_indexes = [] | 21 | var _received_indexes = [] |
22 | var _received_items = {} | 22 | var _received_items = {} |
23 | var _slot_data = {} | 23 | var _slot_data = {} |
24 | var _accessible_locations = [] | ||
24 | 25 | ||
25 | signal could_not_connect | 26 | signal could_not_connect |
26 | signal connect_status | 27 | signal connect_status |
@@ -30,6 +31,8 @@ signal location_scout_received(location_id, item_name, player_name, flags, for_s | |||
30 | signal text_message_received(message) | 31 | signal text_message_received(message) |
31 | signal item_sent_notification(message) | 32 | signal item_sent_notification(message) |
32 | signal hint_received(message) | 33 | signal hint_received(message) |
34 | signal accessible_locations_updated | ||
35 | signal checked_locations_updated | ||
33 | 36 | ||
34 | 37 | ||
35 | func _init(): | 38 | func _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 | ||
56 | func disconnect_from_ap(): | 60 | func 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 | ||
138 | func connectToServer(server, un, pw): | 161 | func connectToServer(server, un, pw): |
139 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) | 162 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) |