diff options
Diffstat (limited to 'client/Archipelago/manager.gd')
| -rw-r--r-- | client/Archipelago/manager.gd | 525 |
1 files changed, 525 insertions, 0 deletions
| diff --git a/client/Archipelago/manager.gd b/client/Archipelago/manager.gd new file mode 100644 index 0000000..8a15728 --- /dev/null +++ b/client/Archipelago/manager.gd | |||
| @@ -0,0 +1,525 @@ | |||
| 1 | extends Node | ||
| 2 | |||
| 3 | const MOD_VERSION = 2 | ||
| 4 | |||
| 5 | var SCRIPT_client | ||
| 6 | var SCRIPT_keyboard | ||
| 7 | var SCRIPT_locationListener | ||
| 8 | var SCRIPT_uuid | ||
| 9 | var SCRIPT_victoryListener | ||
| 10 | |||
| 11 | var ap_server = "" | ||
| 12 | var ap_user = "" | ||
| 13 | var ap_pass = "" | ||
| 14 | var connection_history = [] | ||
| 15 | |||
| 16 | var client | ||
| 17 | var keyboard | ||
| 18 | |||
| 19 | var _localdata_file = "" | ||
| 20 | var _last_new_item = -1 | ||
| 21 | var _batch_locations = false | ||
| 22 | var _held_locations = [] | ||
| 23 | var _held_location_scouts = [] | ||
| 24 | var _location_scouts = {} | ||
| 25 | var _item_locks = {} | ||
| 26 | var _inverse_item_locks = {} | ||
| 27 | var _held_letters = {} | ||
| 28 | var _letters_setup = false | ||
| 29 | |||
| 30 | const kSHUFFLE_LETTERS_VANILLA = 0 | ||
| 31 | const kSHUFFLE_LETTERS_UNLOCKED = 1 | ||
| 32 | const kSHUFFLE_LETTERS_PROGRESSIVE = 2 | ||
| 33 | const kSHUFFLE_LETTERS_VANILLA_CYAN = 3 | ||
| 34 | const kSHUFFLE_LETTERS_ITEM_CYAN = 4 | ||
| 35 | |||
| 36 | const kLETTER_BEHAVIOR_VANILLA = 0 | ||
| 37 | const kLETTER_BEHAVIOR_ITEM = 1 | ||
| 38 | const kLETTER_BEHAVIOR_UNLOCKED = 2 | ||
| 39 | |||
| 40 | const kCYAN_DOOR_BEHAVIOR_H2 = 0 | ||
| 41 | const kCYAN_DOOR_BEHAVIOR_DOUBLE_LETTER = 1 | ||
| 42 | const kCYAN_DOOR_BEHAVIOR_ITEM = 2 | ||
| 43 | |||
| 44 | var apworld_version = [0, 0] | ||
| 45 | var cyan_door_behavior = kCYAN_DOOR_BEHAVIOR_H2 | ||
| 46 | var daedalus_roof_access = false | ||
| 47 | var keyholder_sanity = false | ||
| 48 | var shuffle_control_center_colors = false | ||
| 49 | var shuffle_doors = false | ||
| 50 | var shuffle_gallery_paintings = false | ||
| 51 | var shuffle_letters = kSHUFFLE_LETTERS_VANILLA | ||
| 52 | var shuffle_symbols = false | ||
| 53 | var victory_condition = -1 | ||
| 54 | |||
| 55 | signal could_not_connect | ||
| 56 | signal connect_status | ||
| 57 | signal ap_connected | ||
| 58 | |||
| 59 | |||
| 60 | func _init(): | ||
| 61 | # Read AP settings from file, if there are any | ||
| 62 | if FileAccess.file_exists("user://ap_settings"): | ||
| 63 | var file = FileAccess.open("user://ap_settings", FileAccess.READ) | ||
| 64 | var data = file.get_var(true) | ||
| 65 | file.close() | ||
| 66 | |||
| 67 | if typeof(data) != TYPE_ARRAY: | ||
| 68 | global._print("AP settings file is corrupted") | ||
| 69 | data = [] | ||
| 70 | |||
| 71 | if data.size() > 0: | ||
| 72 | ap_server = data[0] | ||
| 73 | |||
| 74 | if data.size() > 1: | ||
| 75 | ap_user = data[1] | ||
| 76 | |||
| 77 | if data.size() > 2: | ||
| 78 | ap_pass = data[2] | ||
| 79 | |||
| 80 | if data.size() > 3: | ||
| 81 | connection_history = data[3] | ||
| 82 | |||
| 83 | |||
| 84 | func _ready(): | ||
| 85 | client = SCRIPT_client.new() | ||
| 86 | client.SCRIPT_uuid = SCRIPT_uuid | ||
| 87 | |||
| 88 | client.connect("item_received", _process_item) | ||
| 89 | client.connect("message_received", _process_message) | ||
| 90 | client.connect("location_scout_received", _process_location_scout) | ||
| 91 | client.connect("could_not_connect", _client_could_not_connect) | ||
| 92 | client.connect("connect_status", _client_connect_status) | ||
| 93 | client.connect("client_connected", _client_connected) | ||
| 94 | |||
| 95 | add_child(client) | ||
| 96 | |||
| 97 | keyboard = SCRIPT_keyboard.new() | ||
| 98 | add_child(keyboard) | ||
| 99 | |||
| 100 | |||
| 101 | func saveSettings(): | ||
| 102 | # Save the AP settings to disk. | ||
| 103 | var path = "user://ap_settings" | ||
| 104 | var file = FileAccess.open(path, FileAccess.WRITE) | ||
| 105 | |||
| 106 | var data = [ | ||
| 107 | ap_server, | ||
| 108 | ap_user, | ||
| 109 | ap_pass, | ||
| 110 | connection_history, | ||
| 111 | ] | ||
| 112 | file.store_var(data, true) | ||
| 113 | file.close() | ||
| 114 | |||
| 115 | |||
| 116 | func saveLocaldata(): | ||
| 117 | # Save the MW/slot specific settings to disk. | ||
| 118 | var dir = DirAccess.open("user://") | ||
| 119 | var folder = "archipelago_data" | ||
| 120 | if not dir.dir_exists(folder): | ||
| 121 | dir.make_dir(folder) | ||
| 122 | |||
| 123 | var file = FileAccess.open(_localdata_file, FileAccess.WRITE) | ||
| 124 | |||
| 125 | var data = [ | ||
| 126 | _last_new_item, | ||
| 127 | ] | ||
| 128 | file.store_var(data, true) | ||
| 129 | file.close() | ||
| 130 | |||
| 131 | |||
| 132 | func connectToServer(): | ||
| 133 | _last_new_item = -1 | ||
| 134 | _batch_locations = false | ||
| 135 | _held_locations = [] | ||
| 136 | _held_location_scouts = [] | ||
| 137 | _location_scouts = {} | ||
| 138 | _letters_setup = false | ||
| 139 | _held_letters = {} | ||
| 140 | |||
| 141 | client.connectToServer(ap_server, ap_user, ap_pass) | ||
| 142 | |||
| 143 | |||
| 144 | func getSaveFileName(): | ||
| 145 | return "zzAP_%s_%d" % [client._seed, client._slot] | ||
| 146 | |||
| 147 | |||
| 148 | func disconnect_from_ap(): | ||
| 149 | client.disconnect_from_ap() | ||
| 150 | |||
| 151 | |||
| 152 | func get_item_id_for_door(door_id): | ||
| 153 | return _item_locks.get(door_id, null) | ||
| 154 | |||
| 155 | |||
| 156 | func _process_item(item, index, from, flags, amount): | ||
| 157 | var item_name = "Unknown" | ||
| 158 | if client._item_id_to_name["Lingo 2"].has(item): | ||
| 159 | item_name = client._item_id_to_name["Lingo 2"][item] | ||
| 160 | |||
| 161 | var gamedata = global.get_node("Gamedata") | ||
| 162 | |||
| 163 | var prog_id = null | ||
| 164 | if _inverse_item_locks.has(item): | ||
| 165 | for lock in _inverse_item_locks.get(item): | ||
| 166 | if lock[1] != amount: | ||
| 167 | continue | ||
| 168 | |||
| 169 | if gamedata.progressive_id_by_ap_id.has(item): | ||
| 170 | prog_id = lock[0] | ||
| 171 | |||
| 172 | if gamedata.get_door_map_name(lock[0]) != global.map: | ||
| 173 | continue | ||
| 174 | |||
| 175 | var receivers = gamedata.get_door_receivers(lock[0]) | ||
| 176 | var scene = get_tree().get_root().get_node_or_null("scene") | ||
| 177 | if scene != null: | ||
| 178 | for receiver in receivers: | ||
| 179 | var rnode = scene.get_node_or_null(receiver) | ||
| 180 | if rnode != null: | ||
| 181 | rnode.handleTriggered() | ||
| 182 | |||
| 183 | var letter_id = gamedata.letter_id_by_ap_id.get(item, null) | ||
| 184 | if letter_id != null: | ||
| 185 | var letter = gamedata.objects.get_letters()[letter_id] | ||
| 186 | if not letter.has_level2() or not letter.get_level2(): | ||
| 187 | _process_key_item(letter.get_key(), amount) | ||
| 188 | |||
| 189 | if gamedata.symbol_item_ids.has(item): | ||
| 190 | var player = get_tree().get_root().get_node_or_null("scene/player") | ||
| 191 | if player != null: | ||
| 192 | player.emit_signal("evaluate_solvability") | ||
| 193 | |||
| 194 | # Show a message about the item if it's new. | ||
| 195 | if index != null and index > _last_new_item: | ||
| 196 | _last_new_item = index | ||
| 197 | saveLocaldata() | ||
| 198 | |||
| 199 | var player_name = "Unknown" | ||
| 200 | if client._player_name_by_slot.has(float(from)): | ||
| 201 | player_name = client._player_name_by_slot[float(from)] | ||
| 202 | |||
| 203 | var item_color = colorForItemType(flags) | ||
| 204 | |||
| 205 | var full_item_name = item_name | ||
| 206 | if prog_id != null: | ||
| 207 | var door = gamedata.objects.get_doors()[prog_id] | ||
| 208 | full_item_name = "%s (%s)" % [item_name, door.get_name()] | ||
| 209 | |||
| 210 | var message | ||
| 211 | if from == client._slot: | ||
| 212 | message = "Found [color=%s]%s[/color]" % [item_color, full_item_name] | ||
| 213 | else: | ||
| 214 | message = ( | ||
| 215 | "Received [color=%s]%s[/color] from %s" % [item_color, full_item_name, player_name] | ||
| 216 | ) | ||
| 217 | |||
| 218 | global._print(message) | ||
| 219 | |||
| 220 | global.get_node("Messages").showMessage(message) | ||
| 221 | |||
| 222 | |||
| 223 | func _process_message(message): | ||
| 224 | parse_printjson_for_textclient(message) | ||
| 225 | |||
| 226 | if ( | ||
| 227 | !message.has("receiving") | ||
| 228 | or !message.has("item") | ||
| 229 | or message["item"]["player"] != client._slot | ||
| 230 | ): | ||
| 231 | return | ||
| 232 | |||
| 233 | var item_name = "Unknown" | ||
| 234 | var item_player_game = client._game_by_player[message["receiving"]] | ||
| 235 | if client._item_id_to_name[item_player_game].has(int(message["item"]["item"])): | ||
| 236 | item_name = client._item_id_to_name[item_player_game][int(message["item"]["item"])] | ||
| 237 | |||
| 238 | var location_name = "Unknown" | ||
| 239 | var location_player_game = client._game_by_player[message["item"]["player"]] | ||
| 240 | if client._location_id_to_name[location_player_game].has(int(message["item"]["location"])): | ||
| 241 | location_name = (client._location_id_to_name[location_player_game][int( | ||
| 242 | message["item"]["location"] | ||
| 243 | )]) | ||
| 244 | |||
| 245 | var player_name = "Unknown" | ||
| 246 | if client._player_name_by_slot.has(message["receiving"]): | ||
| 247 | player_name = client._player_name_by_slot[message["receiving"]] | ||
| 248 | |||
| 249 | var item_color = colorForItemType(message["item"]["flags"]) | ||
| 250 | |||
| 251 | if message["type"] == "Hint": | ||
| 252 | var is_for = "" | ||
| 253 | if message["receiving"] != client._slot: | ||
| 254 | is_for = " for %s" % player_name | ||
| 255 | if !message.has("found") || !message["found"]: | ||
| 256 | global.get_node("Messages").showMessage( | ||
| 257 | ( | ||
| 258 | "Hint: [color=%s]%s[/color]%s is on %s" | ||
| 259 | % [item_color, item_name, is_for, location_name] | ||
| 260 | ) | ||
| 261 | ) | ||
| 262 | else: | ||
| 263 | if message["receiving"] != client._slot: | ||
| 264 | var sentMsg = "Sent [color=%s]%s[/color] to %s" % [item_color, item_name, player_name] | ||
| 265 | #if _hinted_locations.has(message["item"]["location"]): | ||
| 266 | # sentMsg += " ([color=#fafad2]Hinted![/color])" | ||
| 267 | global.get_node("Messages").showMessage(sentMsg) | ||
| 268 | |||
| 269 | |||
| 270 | func parse_printjson_for_textclient(message): | ||
| 271 | var parts = [] | ||
| 272 | for message_part in message["data"]: | ||
| 273 | if !message_part.has("type") and message_part.has("text"): | ||
| 274 | parts.append(message_part["text"]) | ||
| 275 | elif message_part["type"] == "player_id": | ||
| 276 | if int(message_part["text"]) == client._slot: | ||
| 277 | parts.append( | ||
| 278 | "[color=#ee00ee]%s[/color]" % client._player_name_by_slot[client._slot] | ||
| 279 | ) | ||
| 280 | else: | ||
| 281 | var from = float(message_part["text"]) | ||
| 282 | parts.append("[color=#fafad2]%s[/color]" % client._player_name_by_slot[from]) | ||
| 283 | elif message_part["type"] == "item_id": | ||
| 284 | var item_name = "Unknown" | ||
| 285 | var item_player_game = client._game_by_player[message_part["player"]] | ||
| 286 | if client._item_id_to_name[item_player_game].has(int(message_part["text"])): | ||
| 287 | item_name = client._item_id_to_name[item_player_game][int(message_part["text"])] | ||
| 288 | |||
| 289 | parts.append( | ||
| 290 | "[color=%s]%s[/color]" % [colorForItemType(message_part["flags"]), item_name] | ||
| 291 | ) | ||
| 292 | elif message_part["type"] == "location_id": | ||
| 293 | var location_name = "Unknown" | ||
| 294 | var location_player_game = client._game_by_player[message_part["player"]] | ||
| 295 | if client._location_id_to_name[location_player_game].has(int(message_part["text"])): | ||
| 296 | location_name = client._location_id_to_name[location_player_game][int( | ||
| 297 | message_part["text"] | ||
| 298 | )] | ||
| 299 | |||
| 300 | parts.append("[color=#00ff7f]%s[/color]" % location_name) | ||
| 301 | elif message_part.has("text"): | ||
| 302 | parts.append(message_part["text"]) | ||
| 303 | |||
| 304 | var textclient_node = global.get_node("Textclient") | ||
| 305 | if textclient_node != null: | ||
| 306 | textclient_node.parse_printjson("".join(parts)) | ||
| 307 | |||
| 308 | |||
| 309 | func _process_location_scout(item_id, location_id, player, flags): | ||
| 310 | _location_scouts[location_id] = {"item": item_id, "player": player, "flags": flags} | ||
| 311 | |||
| 312 | var gamedata = global.get_node("Gamedata") | ||
| 313 | var map_id = gamedata.map_id_by_name.get(global.map) | ||
| 314 | |||
| 315 | var item_name = "Unknown" | ||
| 316 | var item_player_game = client._game_by_player[float(player)] | ||
| 317 | if client._item_id_to_name[item_player_game].has(item_id): | ||
| 318 | item_name = client._item_id_to_name[item_player_game][item_id] | ||
| 319 | |||
| 320 | var letter_id = gamedata.letter_id_by_ap_id.get(location_id, null) | ||
| 321 | if letter_id != null: | ||
| 322 | var letter = gamedata.objects.get_letters()[letter_id] | ||
| 323 | var room = gamedata.objects.get_rooms()[letter.get_room_id()] | ||
| 324 | if room.get_map_id() == map_id: | ||
| 325 | var collectable = get_tree().get_root().get_node("scene").get_node_or_null( | ||
| 326 | letter.get_path() | ||
| 327 | ) | ||
| 328 | if collectable != null: | ||
| 329 | collectable.setScoutedText(item_name) | ||
| 330 | |||
| 331 | |||
| 332 | func _client_could_not_connect(): | ||
| 333 | emit_signal("could_not_connect") | ||
| 334 | |||
| 335 | |||
| 336 | func _client_connect_status(message): | ||
| 337 | emit_signal("connect_status", message) | ||
| 338 | |||
| 339 | |||
| 340 | func _client_connected(slot_data): | ||
| 341 | var gamedata = global.get_node("Gamedata") | ||
| 342 | |||
| 343 | _localdata_file = "user://archipelago_data/%s_%d" % [client._seed, client._slot] | ||
| 344 | _last_new_item = -1 | ||
| 345 | |||
| 346 | if FileAccess.file_exists(_localdata_file): | ||
| 347 | var ap_file = FileAccess.open(_localdata_file, FileAccess.READ) | ||
| 348 | var localdata = [] | ||
| 349 | if ap_file != null: | ||
| 350 | localdata = ap_file.get_var(true) | ||
| 351 | ap_file.close() | ||
| 352 | |||
| 353 | if typeof(localdata) != TYPE_ARRAY: | ||
| 354 | print("AP localdata file is corrupted") | ||
| 355 | localdata = [] | ||
| 356 | |||
| 357 | if localdata.size() > 0: | ||
| 358 | _last_new_item = localdata[0] | ||
| 359 | |||
| 360 | # Read slot data. | ||
| 361 | cyan_door_behavior = int(slot_data.get("cyan_door_behavior", 0)) | ||
| 362 | daedalus_roof_access = bool(slot_data.get("daedalus_roof_access", false)) | ||
| 363 | keyholder_sanity = bool(slot_data.get("keyholder_sanity", false)) | ||
| 364 | shuffle_control_center_colors = bool(slot_data.get("shuffle_control_center_colors", false)) | ||
| 365 | shuffle_doors = bool(slot_data.get("shuffle_doors", false)) | ||
| 366 | shuffle_gallery_paintings = bool(slot_data.get("shuffle_gallery_paintings", false)) | ||
| 367 | shuffle_letters = int(slot_data.get("shuffle_letters", 0)) | ||
| 368 | shuffle_symbols = bool(slot_data.get("shuffle_symbols", false)) | ||
| 369 | victory_condition = int(slot_data.get("victory_condition", 0)) | ||
| 370 | |||
| 371 | if slot_data.has("version"): | ||
| 372 | apworld_version = [int(slot_data["version"][0]), int(slot_data["version"][1])] | ||
| 373 | |||
| 374 | # Set up item locks. | ||
| 375 | _item_locks = {} | ||
| 376 | |||
| 377 | if shuffle_doors: | ||
| 378 | for door in gamedata.objects.get_doors(): | ||
| 379 | if ( | ||
| 380 | door.get_type() == gamedata.SCRIPT_proto.DoorType.STANDARD | ||
| 381 | or door.get_type() == gamedata.SCRIPT_proto.DoorType.ITEM_ONLY | ||
| 382 | ): | ||
| 383 | _item_locks[door.get_id()] = [door.get_ap_id(), 1] | ||
| 384 | |||
| 385 | for progressive in gamedata.objects.get_progressives(): | ||
| 386 | for i in range(0, progressive.get_doors().size()): | ||
| 387 | var door = gamedata.objects.get_doors()[progressive.get_doors()[i]] | ||
| 388 | _item_locks[door.get_id()] = [progressive.get_ap_id(), i + 1] | ||
| 389 | |||
| 390 | for door_group in gamedata.objects.get_door_groups(): | ||
| 391 | if ( | ||
| 392 | door_group.get_type() == gamedata.SCRIPT_proto.DoorGroupType.CONNECTOR | ||
| 393 | or door_group.get_type() == gamedata.SCRIPT_proto.DoorGroupType.SHUFFLE_GROUP | ||
| 394 | ): | ||
| 395 | for door in door_group.get_doors(): | ||
| 396 | _item_locks[door] = [door_group.get_ap_id(), 1] | ||
| 397 | |||
| 398 | if shuffle_control_center_colors: | ||
| 399 | for door in gamedata.objects.get_doors(): | ||
| 400 | if door.get_type() == gamedata.SCRIPT_proto.DoorType.CONTROL_CENTER_COLOR: | ||
| 401 | _item_locks[door.get_id()] = [door.get_ap_id(), 1] | ||
| 402 | |||
| 403 | for door_group in gamedata.objects.get_door_groups(): | ||
| 404 | if door_group.get_type() == gamedata.SCRIPT_proto.DoorGroupType.COLOR_CONNECTOR: | ||
| 405 | for door in door_group.get_doors(): | ||
| 406 | _item_locks[door] = [door_group.get_ap_id(), 1] | ||
| 407 | |||
| 408 | if shuffle_gallery_paintings: | ||
| 409 | for door in gamedata.objects.get_doors(): | ||
| 410 | if door.get_type() == gamedata.SCRIPT_proto.DoorType.GALLERY_PAINTING: | ||
| 411 | _item_locks[door.get_id()] = [door.get_ap_id(), 1] | ||
| 412 | |||
| 413 | if cyan_door_behavior == kCYAN_DOOR_BEHAVIOR_ITEM: | ||
| 414 | for door_group in gamedata.objects.get_door_groups(): | ||
| 415 | if door_group.get_type() == gamedata.SCRIPT_proto.DoorGroupType.CYAN_DOORS: | ||
| 416 | for door in door_group.get_doors(): | ||
| 417 | if not _item_locks.has(door): | ||
| 418 | _item_locks[door] = [door_group.get_ap_id(), 1] | ||
| 419 | |||
| 420 | # Create a reverse item locks map for processing items. | ||
| 421 | _inverse_item_locks = {} | ||
| 422 | |||
| 423 | for door_id in _item_locks.keys(): | ||
| 424 | var lock = _item_locks.get(door_id) | ||
| 425 | |||
| 426 | if not _inverse_item_locks.has(lock[0]): | ||
| 427 | _inverse_item_locks[lock[0]] = [] | ||
| 428 | |||
| 429 | _inverse_item_locks[lock[0]].append([door_id, lock[1]]) | ||
| 430 | |||
| 431 | emit_signal("ap_connected") | ||
| 432 | |||
| 433 | |||
| 434 | func start_batching_locations(): | ||
| 435 | _batch_locations = true | ||
| 436 | |||
| 437 | |||
| 438 | func send_location(loc_id): | ||
| 439 | if _batch_locations: | ||
| 440 | _held_locations.append(loc_id) | ||
| 441 | else: | ||
| 442 | client.sendLocation(loc_id) | ||
| 443 | |||
| 444 | |||
| 445 | func scout_location(loc_id): | ||
| 446 | if _location_scouts.has(loc_id): | ||
| 447 | return _location_scouts.get(loc_id) | ||
| 448 | |||
| 449 | if _batch_locations: | ||
| 450 | _held_location_scouts.append(loc_id) | ||
| 451 | else: | ||
| 452 | client.scoutLocation(loc_id) | ||
| 453 | |||
| 454 | return null | ||
| 455 | |||
| 456 | |||
| 457 | func stop_batching_locations(): | ||
| 458 | _batch_locations = false | ||
| 459 | |||
| 460 | if not _held_locations.is_empty(): | ||
| 461 | client.sendLocations(_held_locations) | ||
| 462 | _held_locations.clear() | ||
| 463 | |||
| 464 | if not _held_location_scouts.is_empty(): | ||
| 465 | client.scoutLocations(_held_location_scouts) | ||
| 466 | _held_location_scouts.clear() | ||
| 467 | |||
| 468 | |||
| 469 | func colorForItemType(flags): | ||
| 470 | var int_flags = int(flags) | ||
| 471 | if int_flags & 1: # progression | ||
| 472 | if int_flags & 2: # proguseful | ||
| 473 | return "#f0d200" | ||
| 474 | else: | ||
| 475 | return "#bc51e0" | ||
| 476 | elif int_flags & 2: # useful | ||
| 477 | return "#2b67ff" | ||
| 478 | elif int_flags & 4: # trap | ||
| 479 | return "#d63a22" | ||
| 480 | else: # filler | ||
| 481 | return "#14de9e" | ||
| 482 | |||
| 483 | |||
| 484 | func get_letter_behavior(key, level2): | ||
| 485 | if shuffle_letters == kSHUFFLE_LETTERS_UNLOCKED: | ||
| 486 | return kLETTER_BEHAVIOR_UNLOCKED | ||
| 487 | |||
| 488 | if [kSHUFFLE_LETTERS_VANILLA_CYAN, kSHUFFLE_LETTERS_ITEM_CYAN].has(shuffle_letters): | ||
| 489 | if level2: | ||
| 490 | if shuffle_letters == kSHUFFLE_LETTERS_VANILLA_CYAN: | ||
| 491 | return kLETTER_BEHAVIOR_VANILLA | ||
| 492 | else: | ||
| 493 | return kLETTER_BEHAVIOR_ITEM | ||
| 494 | else: | ||
| 495 | return kLETTER_BEHAVIOR_UNLOCKED | ||
| 496 | |||
| 497 | if not level2 and ["h", "i", "n", "t"].has(key): | ||
| 498 | # This differs from the equivalent function in the apworld. Logically it is | ||
| 499 | # the same as UNLOCKED since they are in the starting room, but VANILLA | ||
| 500 | # means the player still has to actually pick up the letters. | ||
| 501 | return kLETTER_BEHAVIOR_VANILLA | ||
| 502 | |||
| 503 | if shuffle_letters == kSHUFFLE_LETTERS_PROGRESSIVE: | ||
| 504 | return kLETTER_BEHAVIOR_ITEM | ||
| 505 | |||
| 506 | return kLETTER_BEHAVIOR_VANILLA | ||
| 507 | |||
| 508 | |||
| 509 | func setup_keys(): | ||
| 510 | keyboard.load_seed() | ||
| 511 | |||
| 512 | _letters_setup = true | ||
| 513 | |||
| 514 | for k in _held_letters.keys(): | ||
| 515 | _process_key_item(k, _held_letters[k]) | ||
| 516 | |||
| 517 | _held_letters.clear() | ||
| 518 | |||
| 519 | |||
| 520 | func _process_key_item(key, level): | ||
| 521 | if not _letters_setup: | ||
| 522 | _held_letters[key] = max(_held_letters.get(key, 0), level) | ||
| 523 | return | ||
| 524 | |||
| 525 | keyboard.collect_remote_letter(key, level) | ||
