diff options
Diffstat (limited to 'apworld/client')
-rw-r--r-- | apworld/client/client.gd | 25 | ||||
-rw-r--r-- | apworld/client/gamedata.gd | 7 | ||||
-rw-r--r-- | apworld/client/keyboard.gd | 36 | ||||
-rw-r--r-- | apworld/client/manager.gd | 1 |
4 files changed, 54 insertions, 15 deletions
diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 286ad4b..3d4096f 100644 --- a/apworld/client/client.gd +++ b/apworld/client/client.gd | |||
@@ -33,6 +33,7 @@ signal item_sent_notification(message) | |||
33 | signal hint_received(message) | 33 | signal hint_received(message) |
34 | signal accessible_locations_updated | 34 | signal accessible_locations_updated |
35 | signal checked_locations_updated | 35 | signal checked_locations_updated |
36 | signal keyboard_update_received | ||
36 | 37 | ||
37 | 38 | ||
38 | func _init(): | 39 | func _init(): |
@@ -157,6 +158,13 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
157 | 158 | ||
158 | accessible_locations_updated.emit() | 159 | accessible_locations_updated.emit() |
159 | 160 | ||
161 | elif cmd == "UpdateKeyboard": | ||
162 | var updates = {} | ||
163 | for k in message["updates"]: | ||
164 | updates[k] = int(message["updates"][k]) | ||
165 | |||
166 | keyboard_update_received.emit(updates) | ||
167 | |||
160 | 168 | ||
161 | func connectToServer(server, un, pw): | 169 | func connectToServer(server, un, pw): |
162 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) | 170 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) |
@@ -202,19 +210,6 @@ func sendLocations(loc_ids): | |||
202 | sendMessage([{"cmd": "LocationChecks", "locations": loc_ids}]) | 210 | sendMessage([{"cmd": "LocationChecks", "locations": loc_ids}]) |
203 | 211 | ||
204 | 212 | ||
205 | func setValue(key, value, operation = "replace"): | ||
206 | sendMessage( | ||
207 | [ | ||
208 | { | ||
209 | "cmd": "Set", | ||
210 | "key": "Lingo2_%d_%s" % [_slot, key], | ||
211 | "want_reply": false, | ||
212 | "operations": [{"operation": operation, "value": value}] | ||
213 | } | ||
214 | ] | ||
215 | ) | ||
216 | |||
217 | |||
218 | func say(textdata): | 213 | func say(textdata): |
219 | sendMessage([{"cmd": "Say", "text": textdata}]) | 214 | sendMessage([{"cmd": "Say", "text": textdata}]) |
220 | 215 | ||
@@ -227,6 +222,10 @@ func scoutLocations(loc_ids): | |||
227 | sendMessage([{"cmd": "LocationScouts", "locations": loc_ids}]) | 222 | sendMessage([{"cmd": "LocationScouts", "locations": loc_ids}]) |
228 | 223 | ||
229 | 224 | ||
225 | func updateKeyboard(updates): | ||
226 | sendMessage([{"cmd": "UpdateKeyboard", "keyboard": updates}]) | ||
227 | |||
228 | |||
230 | func sendQuit(): | 229 | func sendQuit(): |
231 | sendMessage([{"cmd": "Quit"}]) | 230 | sendMessage([{"cmd": "Quit"}]) |
232 | 231 | ||
diff --git a/apworld/client/gamedata.gd b/apworld/client/gamedata.gd index 39e0583..13ec568 100644 --- a/apworld/client/gamedata.gd +++ b/apworld/client/gamedata.gd | |||
@@ -161,6 +161,13 @@ func get_door_ap_id(door_id): | |||
161 | return null | 161 | return null |
162 | 162 | ||
163 | 163 | ||
164 | func get_door_map_name(door_id): | ||
165 | var door = objects.get_doors()[door_id] | ||
166 | var room = objects.get_rooms()[door.get_room_id()] | ||
167 | var map = objects.get_maps()[room.get_map_id()] | ||
168 | return map.get_name() | ||
169 | |||
170 | |||
164 | func get_door_receivers(door_id): | 171 | func get_door_receivers(door_id): |
165 | var door = objects.get_doors()[door_id] | 172 | var door = objects.get_doors()[door_id] |
166 | return door.get_receivers() | 173 | return door.get_receivers() |
diff --git a/apworld/client/keyboard.gd b/apworld/client/keyboard.gd index 450566d..a59c4d0 100644 --- a/apworld/client/keyboard.gd +++ b/apworld/client/keyboard.gd | |||
@@ -48,6 +48,9 @@ func load_seed(): | |||
48 | if localdata.size() > 2: | 48 | if localdata.size() > 2: |
49 | keyholder_state = localdata[2] | 49 | keyholder_state = localdata[2] |
50 | 50 | ||
51 | if not letters_saved.is_empty(): | ||
52 | ap.client.updateKeyboard(letters_saved) | ||
53 | |||
51 | for k in kALL_LETTERS: | 54 | for k in kALL_LETTERS: |
52 | var level = 0 | 55 | var level = 0 |
53 | 56 | ||
@@ -105,10 +108,20 @@ func update_unlocks(): | |||
105 | 108 | ||
106 | 109 | ||
107 | func collect_local_letter(key, level): | 110 | func collect_local_letter(key, level): |
108 | if level < 0 or level > 2 or level < letters_saved.get(key, 0): | 111 | var ap = global.get_node("Archipelago") |
112 | var true_level = 0 | ||
113 | |||
114 | if ap.get_letter_behavior(key, false) == ap.kLETTER_BEHAVIOR_VANILLA: | ||
115 | true_level += 1 | ||
116 | if level == 2 and ap.get_letter_behavior(key, true) == ap.kLETTER_BEHAVIOR_VANILLA: | ||
117 | true_level += 1 | ||
118 | |||
119 | if true_level < letters_saved.get(key, 0): | ||
109 | return | 120 | return |
110 | 121 | ||
111 | letters_saved[key] = level | 122 | letters_saved[key] = true_level |
123 | |||
124 | ap.client.updateKeyboard({key: true_level}) | ||
112 | 125 | ||
113 | if letters_blocked.has(key): | 126 | if letters_blocked.has(key): |
114 | letters_blocked.erase(key) | 127 | letters_blocked.erase(key) |
@@ -197,3 +210,22 @@ func reset_keyholders(): | |||
197 | save() | 210 | save() |
198 | 211 | ||
199 | return cleared_anything | 212 | return cleared_anything |
213 | |||
214 | |||
215 | func remote_keyboard_updated(updates): | ||
216 | var reverse = {} | ||
217 | var should_update = false | ||
218 | |||
219 | for k in updates: | ||
220 | if not letters_saved.has(k) or updates[k] > letters_saved[k]: | ||
221 | letters_saved[k] = updates[k] | ||
222 | should_update = true | ||
223 | elif updates[k] < letters_saved[k]: | ||
224 | reverse[k] = letters_saved[k] | ||
225 | |||
226 | if should_update: | ||
227 | update_unlocks() | ||
228 | |||
229 | if not reverse.is_empty(): | ||
230 | var ap = global.get_node("Archipelago") | ||
231 | ap.client.updateKeyboard(reverse) | ||
diff --git a/apworld/client/manager.gd b/apworld/client/manager.gd index e7765dd..afa3ebe 100644 --- a/apworld/client/manager.gd +++ b/apworld/client/manager.gd | |||
@@ -118,6 +118,7 @@ func _ready(): | |||
118 | 118 | ||
119 | keyboard = SCRIPT_keyboard.new() | 119 | keyboard = SCRIPT_keyboard.new() |
120 | add_child(keyboard) | 120 | add_child(keyboard) |
121 | client.keyboard_update_received.connect(keyboard.remote_keyboard_updated) | ||
121 | 122 | ||
122 | 123 | ||
123 | func saveSettings(): | 124 | func saveSettings(): |