diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-29 13:34:53 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-29 13:34:53 -0400 |
commit | eff3dff1142876b70e0336f03b4efb12db4e2bba (patch) | |
tree | d0f19c16094706e9c3a6d4b59d9f4ee44e535ad4 /util/generate_gamedata.rb | |
parent | 8b97ed0755c8d950f5cc8f9a957636982f33f012 (diff) | |
parent | 2b0fcdde3144213676324163d721150a8641d610 (diff) | |
download | lingo-archipelago-eff3dff1142876b70e0336f03b4efb12db4e2bba.tar.gz lingo-archipelago-eff3dff1142876b70e0336f03b4efb12db4e2bba.tar.bz2 lingo-archipelago-eff3dff1142876b70e0336f03b4efb12db4e2bba.zip |
Merge branch 'main' into color-hallways
Diffstat (limited to 'util/generate_gamedata.rb')
-rw-r--r-- | util/generate_gamedata.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index f63e062..1f18b7e 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -11,15 +11,20 @@ CLASSIFICATION_INSANITY = 4 | |||
11 | 11 | ||
12 | panel_to_id = {} | 12 | panel_to_id = {} |
13 | door_groups = {} | 13 | door_groups = {} |
14 | warp_groups = {} | ||
14 | 15 | ||
15 | panel_output = [] | 16 | panel_output = [] |
16 | door_ids_by_item_id = {} | 17 | door_ids_by_item_id = {} |
17 | painting_ids_by_item_id = {} | 18 | painting_ids_by_item_id = {} |
19 | warp_ids_by_item_id = {} | ||
18 | panel_ids_by_location_id = {} | 20 | panel_ids_by_location_id = {} |
19 | classification_by_location_id = {} | 21 | classification_by_location_id = {} |
22 | sunwarps = Array.new(12) {Hash.new} | ||
20 | mentioned_doors = Set[] | 23 | mentioned_doors = Set[] |
21 | mentioned_paintings = Set[] | 24 | mentioned_paintings = Set[] |
25 | mentioned_warps = Set[] | ||
22 | painting_output = {} | 26 | painting_output = {} |
27 | items_by_progressive_id = {} | ||
23 | 28 | ||
24 | ids_config = YAML.load_file(idspath) | 29 | ids_config = YAML.load_file(idspath) |
25 | 30 | ||
@@ -88,6 +93,30 @@ config.each do |room_name, room_data| | |||
88 | painting_output[painting["id"]] = painting | 93 | painting_output[painting["id"]] = painting |
89 | end | 94 | end |
90 | end | 95 | end |
96 | |||
97 | if room_data.include? "sunwarps" | ||
98 | room_data["sunwarps"].each do |sunwarp| | ||
99 | index = sunwarp["dots"] - 1 | ||
100 | if sunwarp["direction"] == "exit" then | ||
101 | index += 6 | ||
102 | end | ||
103 | sunwarps[index] = sunwarp | ||
104 | end | ||
105 | end | ||
106 | |||
107 | if room_data.include? "progression" | ||
108 | room_data["progression"].each do |progressive_item_name, progression| | ||
109 | progressive_id = ids_config["progression"][progressive_item_name] | ||
110 | items_by_progressive_id[progressive_id] = [] | ||
111 | |||
112 | progression.each do |item| | ||
113 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | ||
114 | item_item_name = (item.kind_of? Hash) ? item["door"] : item | ||
115 | |||
116 | items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"] | ||
117 | end | ||
118 | end | ||
119 | end | ||
91 | end | 120 | end |
92 | 121 | ||
93 | config.each do |room_name, room_data| | 122 | config.each do |room_name, room_data| |
@@ -152,6 +181,23 @@ config.each do |room_name, room_data| | |||
152 | painting_ids_by_item_id[item_id] = internal_painting_ids | 181 | painting_ids_by_item_id[item_id] = internal_painting_ids |
153 | mentioned_paintings.merge(internal_painting_ids) | 182 | mentioned_paintings.merge(internal_painting_ids) |
154 | end | 183 | end |
184 | |||
185 | if door.include? "warp_id" | ||
186 | internal_warp_ids = [] | ||
187 | if door["warp_id"].kind_of? String | ||
188 | internal_warp_ids = [door["warp_id"]] | ||
189 | else | ||
190 | internal_warp_ids = door["warp_id"] | ||
191 | end | ||
192 | |||
193 | if door.include? "door_group" | ||
194 | warp_groups[door["door_group"]] ||= Set[] | ||
195 | warp_groups[door["door_group"]].merge(internal_warp_ids) | ||
196 | end | ||
197 | |||
198 | warp_ids_by_item_id[item_id] = internal_warp_ids | ||
199 | mentioned_warps.merge(internal_warp_ids) | ||
200 | end | ||
155 | end | 201 | end |
156 | end | 202 | end |
157 | end | 203 | end |
@@ -162,6 +208,11 @@ door_groups.each do |group_name, door_ids| | |||
162 | door_ids_by_item_id[item_id] = door_ids.to_a | 208 | door_ids_by_item_id[item_id] = door_ids.to_a |
163 | end | 209 | end |
164 | 210 | ||
211 | warp_groups.each do |group_name, warp_ids| | ||
212 | item_id = ids_config["door_groups"][group_name] | ||
213 | warp_ids_by_item_id[item_id] = warp_ids.to_a | ||
214 | end | ||
215 | |||
165 | File.open(outputpath, "w") do |f| | 216 | File.open(outputpath, "w") do |f| |
166 | f.write "extends Node\n\nvar panels = [" | 217 | f.write "extends Node\n\nvar panels = [" |
167 | f.write(panel_output.map do |panel| | 218 | f.write(panel_output.map do |panel| |
@@ -181,6 +232,12 @@ File.open(outputpath, "w") do |f| | |||
181 | "\"#{painting_id}\"" | 232 | "\"#{painting_id}\"" |
182 | end.join(",") + "]" | 233 | end.join(",") + "]" |
183 | end.join(",")) | 234 | end.join(",")) |
235 | f.write "}\nvar warp_ids_by_item_id = {" | ||
236 | f.write(warp_ids_by_item_id.map do |item_id, warp_ids| | ||
237 | "#{item_id}:[" + warp_ids.map do |warp_id| | ||
238 | "\"#{warp_id}\"" | ||
239 | end.join(",") + "]" | ||
240 | end.join(",")) | ||
184 | f.write "}\nvar panel_ids_by_location_id = {" | 241 | f.write "}\nvar panel_ids_by_location_id = {" |
185 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| | 242 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| |
186 | "#{location_id}:[" + panel_ids.map do |panel_id| | 243 | "#{location_id}:[" + panel_ids.map do |panel_id| |
@@ -195,6 +252,10 @@ File.open(outputpath, "w") do |f| | |||
195 | f.write(mentioned_paintings.map do |painting_id| | 252 | f.write(mentioned_paintings.map do |painting_id| |
196 | "\"#{painting_id}\"" | 253 | "\"#{painting_id}\"" |
197 | end.join(",")) | 254 | end.join(",")) |
255 | f.write "]\nvar mentioned_warps = [" | ||
256 | f.write(mentioned_warps.map do |warp_id| | ||
257 | "\"#{warp_id}\"" | ||
258 | end.join(",")) | ||
198 | f.write "]\nvar paintings = {" | 259 | f.write "]\nvar paintings = {" |
199 | f.write(painting_output.map do |painting_id, painting| | 260 | f.write(painting_output.map do |painting_id, painting| |
200 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" | 261 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" |
@@ -203,5 +264,13 @@ File.open(outputpath, "w") do |f| | |||
203 | f.write(classification_by_location_id.map do |location_id, classification| | 264 | f.write(classification_by_location_id.map do |location_id, classification| |
204 | "#{location_id}:#{classification}" | 265 | "#{location_id}:#{classification}" |
205 | end.join(",")) | 266 | end.join(",")) |
267 | f.write "}\nvar sunwarps = [" | ||
268 | f.write(sunwarps.map do |sunwarp| | ||
269 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" | ||
270 | end.join(",")) | ||
271 | f.write "]\nvar items_by_progressive_id = {" | ||
272 | f.write(items_by_progressive_id.map do |item_id, progression_ids| | ||
273 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" | ||
274 | end.join(",")) | ||
206 | f.write "}" | 275 | f.write "}" |
207 | end | 276 | end |