From e448f5b318f05cae1b40a949e11ef2d7fb613645 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 15 Apr 2024 11:39:52 -0400 Subject: Implemented panels mode door shuffle --- Archipelago/client.gd | 70 ++++++++++++++++++++++++++++++++++++++++++----- Archipelago/load.gd | 2 ++ Archipelago/panel.gd | 9 +++++- util/generate_gamedata.rb | 38 +++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 8 deletions(-) diff --git a/Archipelago/client.gd b/Archipelago/client.gd index f15afe6..cafe2f9 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -21,7 +21,7 @@ const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"} const color_items = [ "White", "Black", "Red", "Blue", "Green", "Brown", "Gray", "Orange", "Purple", "Yellow" ] -const progressive_items = { +const door_progressive_items = { "Progressive Orange Tower": [ {"item": "Orange Tower - Second Floor", "display": "Second Floor"}, @@ -65,6 +65,40 @@ const progressive_items = { {"item": "The Colorful - Gray Door", "display": "Gray"}, ] } +const panel_progressive_items = { + "Progressive Hallway Room": + [ + {"item": "Hallway Room - First Room Panels", "display": "First Door"}, + {"item": "Hallway Room - Second Room Panels", "display": "Second Door"}, + {"item": "Hallway Room - Third Room Panels", "display": "Third Door"}, + {"item": "Hallway Room - WHEEL", "display": "Fourth Door"}, + ], + "Progressive Colorful": + [ + {"item": "The Colorful - BEGIN (Panel)", "display": "White"}, + {"item": "The Colorful - FOUND (Panel)", "display": "Black"}, + {"item": "The Colorful - LOAF (Panel)", "display": "Red"}, + {"item": "The Colorful - CREAM (Panel)", "display": "Yellow"}, + {"item": "The Colorful - SUN (Panel)", "display": "Blue"}, + {"item": "The Colorful - SPOON (Panel)", "display": "Purple"}, + {"item": "The Colorful - LETTERS (Panel)", "display": "Orange"}, + {"item": "The Colorful - WALLS (Panel)", "display": "Green"}, + {"item": "The Colorful - IRON (Panel)", "display": "Brown"}, + {"item": "The Colorful - OBSTACLE (Panel)", "display": "Gray"}, + ], + "Progressive Number Hunt": + [ + {"item": "Two Panels", "display": "Two"}, + {"item": "Three Panels", "display": "Three"}, + {"item": "Four Panels", "display": "Four"}, + {"item": "Five Panels", "display": "Five"}, + {"item": "Six Panels", "display": "Six"}, + {"item": "Seven Panels", "display": "Seven"}, + {"item": "Eight Panels", "display": "Eight"}, + {"item": "Nine Panels", "display": "Nine"}, + {"item": "Outside The Undeterred - ZERO (Panel)", "display": "Zero"}, + ] +} const kTHE_END = 0 const kTHE_MASTER = 1 @@ -109,6 +143,7 @@ var _localdata_file = "" var _death_link = false var _victory_condition = 0 # THE END, THE MASTER, LEVEL 2 var _door_shuffle = false +var _panel_door_shuffle = false var _color_shuffle = false var _panel_shuffle = 0 # none, rearrange var _painting_shuffle = false @@ -278,7 +313,8 @@ func _on_data(): if _slot_data.has("shuffle_colors"): _color_shuffle = _slot_data["shuffle_colors"] if _slot_data.has("shuffle_doors"): - _door_shuffle = (_slot_data["shuffle_doors"] > 0) + _door_shuffle = (_slot_data["shuffle_doors"] == 2) + _panel_door_shuffle = (_slot_data["shuffle_doors"] == 1) if _slot_data.has("shuffle_paintings"): _painting_shuffle = _slot_data["shuffle_paintings"] if _slot_data.has("shuffle_panels"): @@ -668,6 +704,12 @@ func processItem(item, index, from, flags): for door_id in gamedata.door_ids_by_item_id[int(item)]: doorsNode.get_node(door_id).openDoor() + if gamedata.panel_ids_by_item_id.has(int(item)): + var panelsNode = get_tree().get_root().get_node("Spatial/Panels") + for panel_id in gamedata.panel_ids_by_item_id[int(item)]: + panelsNode.get_node(panel_id).get_node("AP_Panel").locked = false + emit_signal("evaluate_solvability") + if gamedata.painting_ids_by_item_id.has(int(item)): var real_parent_node = get_tree().get_root().get_node("Spatial/Decorations/Paintings") var fake_parent_node = get_tree().get_root().get_node_or_null("Spatial/AP_Paintings") @@ -683,12 +725,22 @@ func processItem(item, index, from, flags): painting_node.get_node("Script").movePainting() # Handle progressive items. - if item_name in progressive_items.keys(): + if _door_shuffle and item_name in door_progressive_items.keys(): + if not item_name in _progressive_progress: + _progressive_progress[item_name] = 0 + + if _progressive_progress[item_name] < door_progressive_items[item_name].size(): + var subitem_name = door_progressive_items[item_name][_progressive_progress[item_name]]["item"] + global._print(subitem_name) + processItem(_item_name_to_id[subitem_name], null, null, null) + _progressive_progress[item_name] += 1 + + if _panel_door_shuffle and item_name in panel_progressive_items.keys(): if not item_name in _progressive_progress: _progressive_progress[item_name] = 0 - if _progressive_progress[item_name] < progressive_items[item_name].size(): - var subitem_name = progressive_items[item_name][_progressive_progress[item_name]]["item"] + if _progressive_progress[item_name] < panel_progressive_items[item_name].size(): + var subitem_name = panel_progressive_items[item_name][_progressive_progress[item_name]]["item"] global._print(subitem_name) processItem(_item_name_to_id[subitem_name], null, null, null) _progressive_progress[item_name] += 1 @@ -704,8 +756,12 @@ func processItem(item, index, from, flags): _last_new_item = index saveLocaldata() - if item_name in progressive_items: - var subitem = progressive_items[item_name][_progressive_progress[item_name] - 1] + if _door_shuffle and item_name in door_progressive_items: + var subitem = door_progressive_items[item_name][_progressive_progress[item_name] - 1] + item_name += " (%s)" % subitem["display"] + + if _panel_door_shuffle and item_name in panel_progressive_items: + var subitem = panel_progressive_items[item_name][_progressive_progress[item_name] - 1] item_name += " (%s)" % subitem["display"] var player_name = "Unknown" diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 566ee39..82f8e94 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd @@ -568,6 +568,8 @@ func _load(): var script_instance = panel_script.new() script_instance.name = "AP_Panel" script_instance.data = panel + if apclient._panel_door_shuffle and gamedata.mentioned_panels.has(panel["id"]): + script_instance.locked = true panel_node.add_child(script_instance) apclient.connect("evaluate_solvability", script_instance, "evaluate_solvability") diff --git a/Archipelago/panel.gd b/Archipelago/panel.gd index aec18e8..0e8f1df 100644 --- a/Archipelago/panel.gd +++ b/Archipelago/panel.gd @@ -5,6 +5,7 @@ var orig_text = "" var atbash_text = "" var orig_color = Color(0, 0, 0, 0) var solvable = true +var locked = false const kAtbashPre = "abcdefghijklmnopqrstuvwxyz1234567890+-" const kAtbashPost = "zyxwvutsrqponmlkjihgfedcba0987654321-+" @@ -45,7 +46,13 @@ func evaluate_solvability(): missing.append(color) solvable = false - if solvable: + if locked: + self.get_parent().get_node("Viewport/GUI/Panel/Label").text = "Locked" + self.get_parent().get_node("Viewport/GUI/Panel/TextEdit").editable = false + self.get_parent().get_node("Quad").get_surface_material(0).albedo_color = Color( + 0.2, 0.7, 0.7 + ) + elif solvable: if effects.atbash_remaining > 0: self.get_parent().get_node("Viewport/GUI/Panel/Label").text = atbash_text else: diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index f63e062..a3f9ba5 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb @@ -11,14 +11,17 @@ CLASSIFICATION_INSANITY = 4 panel_to_id = {} door_groups = {} +panel_groups = {} panel_output = [] door_ids_by_item_id = {} painting_ids_by_item_id = {} +panel_ids_by_item_id = {} panel_ids_by_location_id = {} classification_by_location_id = {} mentioned_doors = Set[] mentioned_paintings = Set[] +mentioned_panels = Set[] painting_output = {} ids_config = YAML.load_file(idspath) @@ -155,6 +158,26 @@ config.each do |room_name, room_data| end end end + + if room_data.include? "panel_doors" + room_data["panel_doors"].each do |panel_door_name, panel_door| + item_id = ids_config["panel_doors"][room_name][panel_door_name] + + panel_ids_by_item_id[item_id] = panel_door["panels"].map do |panel_identifier| + other_room_name = (panel_identifier.kind_of? String) ? room_name : panel_identifier["room"] + other_panel_name = (panel_identifier.kind_of? String) ? panel_identifier : panel_identifier["panel"] + + config[other_room_name]["panels"][other_panel_name]["id"] + end + + mentioned_panels.merge(panel_ids_by_item_id[item_id]) + + if panel_door.include? "panel_group" + panel_groups[panel_door["panel_group"]] ||= Set[] + panel_groups[panel_door["panel_group"]].merge(panel_ids_by_item_id[item_id]) + end + end + end end door_groups.each do |group_name, door_ids| @@ -162,6 +185,11 @@ door_groups.each do |group_name, door_ids| door_ids_by_item_id[item_id] = door_ids.to_a end +panel_groups.each do |group_name, panel_ids| + item_id = ids_config["panel_groups"][group_name] + panel_ids_by_item_id[item_id] = panel_ids.to_a +end + File.open(outputpath, "w") do |f| f.write "extends Node\n\nvar panels = [" f.write(panel_output.map do |panel| @@ -175,6 +203,12 @@ File.open(outputpath, "w") do |f| "\"#{door_id}\"" end.join(",") + "]" end.join(",")) + f.write "}\nvar panel_ids_by_item_id = {" + f.write(panel_ids_by_item_id.map do |item_id, panel_ids| + "#{item_id}:[" + panel_ids.map do |panel_id| + "\"#{panel_id}\"" + end.join(",") + "]" + end.join(",")) f.write "}\nvar painting_ids_by_item_id = {" f.write(painting_ids_by_item_id.map do |item_id, painting_ids| "#{item_id}:[" + painting_ids.map do |painting_id| @@ -195,6 +229,10 @@ File.open(outputpath, "w") do |f| f.write(mentioned_paintings.map do |painting_id| "\"#{painting_id}\"" end.join(",")) + f.write "]\nvar mentioned_panels = [" + f.write(mentioned_panels.map do |panel_id| + "\"#{panel_id}\"" + end.join(",")) f.write "]\nvar paintings = {" f.write(painting_output.map do |painting_id, painting| "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" -- cgit 1.4.1