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 --- util/generate_gamedata.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'util') 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