From 34602a22dd85a675a91adcecb93972876ec518fd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 22 Apr 2024 14:11:05 -0400 Subject: Make progression items resistant to renames --- Archipelago/client.gd | 74 +++++++++++------------------------------------ util/generate_gamedata.rb | 21 +++++++++++++- 2 files changed, 37 insertions(+), 58 deletions(-) diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 2229916..853be2d 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -25,56 +25,15 @@ const color_items = [ ] const progressive_items = { "Progressive Orange Tower": - [ - {"item": "Orange Tower - Second Floor", "display": "Second Floor"}, - {"item": "Orange Tower - Third Floor", "display": "Third Floor"}, - {"item": "Orange Tower - Fourth Floor", "display": "Fourth Floor"}, - {"item": "Orange Tower - Fifth Floor", "display": "Fifth Floor"}, - {"item": "Orange Tower - Sixth Floor", "display": "Sixth Floor"}, - {"item": "Orange Tower - Seventh Floor", "display": "Seventh Floor"}, - ], + ["Second Floor", "Third Floor", "Fourth Floor", "Fifth Floor", "Sixth Floor", "Seventh Floor"], "Progressive Art Gallery": - [ - {"item": "Art Gallery - Second Floor", "display": "Second Floor"}, - {"item": "Art Gallery - Third Floor", "display": "Third Floor"}, - {"item": "Art Gallery - Fourth Floor", "display": "Fourth Floor"}, - {"item": "Art Gallery - Fifth Floor", "display": "Fifth Floor"}, - {"item": "Art Gallery - Exit", "display": "Exit"}, - ], - "Progressive Hallway Room": - [ - {"item": "Hallway Room (1) - Exit", "display": "First Door"}, - {"item": "Hallway Room (2) - Exit", "display": "Second Door"}, - {"item": "Hallway Room (3) - Exit", "display": "Third Door"}, - {"item": "Hallway Room (4) - Exit", "display": "Fourth Door"}, - ], - "Progressive Fearless": - [ - {"item": "The Fearless (First Floor) - Second Floor", "display": "Second Floor"}, - {"item": "The Fearless (Second Floor) - Third Floor", "display": "Third Floor"}, - ], + ["Second Floor", "Third Floor", "Fourth Floor", "Fifth Floor", "Exit"], + "Progressive Hallway Room": ["First Door", "Second Door", "Third Door", "Fourth Door"], + "Progressive Fearless": ["Second Floor", "Third Floor"], "Progressive Colorful": - [ - {"item": "The Colorful - White Door", "display": "White"}, - {"item": "The Colorful - Black Door", "display": "Black"}, - {"item": "The Colorful - Red Door", "display": "Red"}, - {"item": "The Colorful - Yellow Door", "display": "Yellow"}, - {"item": "The Colorful - Blue Door", "display": "Blue"}, - {"item": "The Colorful - Purple Door", "display": "Purple"}, - {"item": "The Colorful - Orange Door", "display": "Orange"}, - {"item": "The Colorful - Green Door", "display": "Green"}, - {"item": "The Colorful - Brown Door", "display": "Brown"}, - {"item": "The Colorful - Gray Door", "display": "Gray"}, - ], + ["White", "Black", "Red", "Yellow", "Blue", "Purple", "Orange", "Green", "Brown", "Gray"], "Progressive Pilgrimage": - [ - {"item": "1 Sunwarp", "display": "1 Sunwarp"}, - {"item": "2 Sunwarp", "display": "2 Sunwarp"}, - {"item": "3 Sunwarp", "display": "3 Sunwarp"}, - {"item": "4 Sunwarp", "display": "4 Sunwarp"}, - {"item": "5 Sunwarp", "display": "5 Sunwarp"}, - {"item": "6 Sunwarp", "display": "6 Sunwarp"}, - ] + ["1 Sunwarp", "2 Sunwarp", "3 Sunwarp", "4 Sunwarp", "5 Sunwarp", "6 Sunwarp"] } const kTHE_END = 0 @@ -741,15 +700,16 @@ func processItem(item, index, from, flags): warpsNode.get_node(warp_id).unlock_warp() # Handle progressive items. - if item_name in progressive_items.keys(): - if not item_name in _progressive_progress: - _progressive_progress[item_name] = 0 + if int(item) in gamedata.items_by_progressive_id.keys(): + if not int(item) in _progressive_progress: + _progressive_progress[int(item)] = 0 - if _progressive_progress[item_name] < progressive_items[item_name].size(): - var subitem_name = 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 _progressive_progress[int(item)] < gamedata.items_by_progressive_id[int(item)].size(): + var subitems = gamedata.items_by_progressive_id[int(item)] + var subitem_id = subitems[_progressive_progress[int(item)]] + global._print("Subitem: %d" % subitem_id) + processItem(subitem_id, null, null, null) + _progressive_progress[int(item)] += 1 if _color_shuffle and color_items.has(_item_id_to_name[item]): var lcol = _item_id_to_name[item].to_lower() @@ -763,8 +723,8 @@ func processItem(item, index, from, flags): saveLocaldata() if item_name in progressive_items: - var subitem = progressive_items[item_name][_progressive_progress[item_name] - 1] - item_name += " (%s)" % subitem["display"] + var subitem = progressive_items[item_name][_progressive_progress[int(item)] - 1] + item_name += " (%s)" % subitem var player_name = "Unknown" if _player_name_by_slot.has(from): diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index cf57395..1f18b7e 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb @@ -24,6 +24,7 @@ mentioned_doors = Set[] mentioned_paintings = Set[] mentioned_warps = Set[] painting_output = {} +items_by_progressive_id = {} ids_config = YAML.load_file(idspath) @@ -102,6 +103,20 @@ config.each do |room_name, room_data| sunwarps[index] = sunwarp end end + + if room_data.include? "progression" + room_data["progression"].each do |progressive_item_name, progression| + progressive_id = ids_config["progression"][progressive_item_name] + items_by_progressive_id[progressive_id] = [] + + progression.each do |item| + item_room_name = (item.kind_of? Hash) ? item["room"] : room_name + item_item_name = (item.kind_of? Hash) ? item["door"] : item + + items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"] + end + end + end end config.each do |room_name, room_data| @@ -253,5 +268,9 @@ File.open(outputpath, "w") do |f| f.write(sunwarps.map do |sunwarp| "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" end.join(",")) - f.write "]" + f.write "]\nvar items_by_progressive_id = {" + f.write(items_by_progressive_id.map do |item_id, progression_ids| + "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" + end.join(",")) + f.write "}" end -- cgit 1.4.1