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