diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-26 14:57:43 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-26 14:57:43 -0500 |
commit | 8a7b2ac6955cbcbe3a71d28c328feb8893552529 (patch) | |
tree | 9206fa05cda0b8d977016c0d6591f138a4c6e131 /util | |
parent | 5d4df9284173c457dfa70da67f3274a4069abc92 (diff) | |
parent | f72463fda100ea858a154d6473111bc8edc1f697 (diff) | |
download | lingo-archipelago-8a7b2ac6955cbcbe3a71d28c328feb8893552529.tar.gz lingo-archipelago-8a7b2ac6955cbcbe3a71d28c328feb8893552529.tar.bz2 lingo-archipelago-8a7b2ac6955cbcbe3a71d28c328feb8893552529.zip |
Merge branch 'panels'
Diffstat (limited to 'util')
-rw-r--r-- | util/generate_gamedata.rb | 75 |
1 files changed, 66 insertions, 9 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index ce8df43..83099ad 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -12,20 +12,24 @@ CLASSIFICATION_SMALL_SPHERE_ONE = 8 | |||
12 | 12 | ||
13 | panel_to_id = {} | 13 | panel_to_id = {} |
14 | door_groups = {} | 14 | door_groups = {} |
15 | panel_groups = {} | ||
15 | warp_groups = {} | 16 | warp_groups = {} |
16 | 17 | ||
17 | panel_output = [] | 18 | panel_output = [] |
18 | door_ids_by_item_id = {} | 19 | door_ids_by_item_id = {} |
19 | painting_ids_by_item_id = {} | 20 | painting_ids_by_item_id = {} |
21 | panel_ids_by_item_id = {} | ||
20 | warp_ids_by_item_id = {} | 22 | warp_ids_by_item_id = {} |
21 | panel_ids_by_location_id = {} | 23 | panel_ids_by_location_id = {} |
22 | classification_by_location_id = {} | 24 | classification_by_location_id = {} |
23 | sunwarps = Array.new(12) {Hash.new} | 25 | sunwarps = Array.new(12) {Hash.new} |
24 | mentioned_doors = Set[] | 26 | mentioned_doors = Set[] |
25 | mentioned_paintings = Set[] | 27 | mentioned_paintings = Set[] |
28 | mentioned_panels = Set[] | ||
26 | mentioned_warps = Set[] | 29 | mentioned_warps = Set[] |
27 | painting_output = {} | 30 | painting_output = {} |
28 | items_by_progressive_id = {} | 31 | door_items_by_progressive_id = {} |
32 | panel_items_by_progressive_id = {} | ||
29 | 33 | ||
30 | ids_config = YAML.load_file(idspath) | 34 | ids_config = YAML.load_file(idspath) |
31 | 35 | ||
@@ -110,15 +114,29 @@ config.each do |room_name, room_data| | |||
110 | end | 114 | end |
111 | 115 | ||
112 | if room_data.include? "progression" | 116 | if room_data.include? "progression" |
113 | room_data["progression"].each do |progressive_item_name, progression| | 117 | room_data["progression"].each do |progressive_item_name, pdata| |
114 | progressive_id = ids_config["progression"][progressive_item_name] | 118 | progressive_id = ids_config["progression"][progressive_item_name] |
115 | items_by_progressive_id[progressive_id] = [] | ||
116 | 119 | ||
117 | progression.each do |item| | 120 | if pdata.include? "doors" |
118 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | 121 | door_items_by_progressive_id[progressive_id] = [] |
119 | item_item_name = (item.kind_of? Hash) ? item["door"] : item | ||
120 | 122 | ||
121 | items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"] | 123 | pdata["doors"].each do |item| |
124 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | ||
125 | item_item_name = (item.kind_of? Hash) ? item["door"] : item | ||
126 | |||
127 | door_items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"] | ||
128 | end | ||
129 | end | ||
130 | |||
131 | if pdata.include? "panel_doors" | ||
132 | panel_items_by_progressive_id[progressive_id] = [] | ||
133 | |||
134 | pdata["panel_doors"].each do |item| | ||
135 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | ||
136 | item_item_name = (item.kind_of? Hash) ? item["panel_door"] : item | ||
137 | |||
138 | panel_items_by_progressive_id[progressive_id] << ids_config["panel_doors"][item_room_name][item_item_name] | ||
139 | end | ||
122 | end | 140 | end |
123 | end | 141 | end |
124 | end | 142 | end |
@@ -206,6 +224,26 @@ config.each do |room_name, room_data| | |||
206 | end | 224 | end |
207 | end | 225 | end |
208 | end | 226 | end |
227 | |||
228 | if room_data.include? "panel_doors" | ||
229 | room_data["panel_doors"].each do |panel_door_name, panel_door| | ||
230 | item_id = ids_config["panel_doors"][room_name][panel_door_name] | ||
231 | |||
232 | panel_ids_by_item_id[item_id] = panel_door["panels"].map do |panel_identifier| | ||
233 | other_room_name = (panel_identifier.kind_of? String) ? room_name : panel_identifier["room"] | ||
234 | other_panel_name = (panel_identifier.kind_of? String) ? panel_identifier : panel_identifier["panel"] | ||
235 | |||
236 | config[other_room_name]["panels"][other_panel_name]["id"] | ||
237 | end | ||
238 | |||
239 | mentioned_panels.merge(panel_ids_by_item_id[item_id]) | ||
240 | |||
241 | if panel_door.include? "panel_group" | ||
242 | panel_groups[panel_door["panel_group"]] ||= Set[] | ||
243 | panel_groups[panel_door["panel_group"]].merge(panel_ids_by_item_id[item_id]) | ||
244 | end | ||
245 | end | ||
246 | end | ||
209 | end | 247 | end |
210 | 248 | ||
211 | door_groups.each do |group_name, door_ids| | 249 | door_groups.each do |group_name, door_ids| |
@@ -213,6 +251,11 @@ door_groups.each do |group_name, door_ids| | |||
213 | door_ids_by_item_id[item_id] = door_ids.to_a | 251 | door_ids_by_item_id[item_id] = door_ids.to_a |
214 | end | 252 | end |
215 | 253 | ||
254 | panel_groups.each do |group_name, panel_ids| | ||
255 | item_id = ids_config["panel_groups"][group_name] | ||
256 | panel_ids_by_item_id[item_id] = panel_ids.to_a | ||
257 | end | ||
258 | |||
216 | warp_groups.each do |group_name, warp_ids| | 259 | warp_groups.each do |group_name, warp_ids| |
217 | item_id = ids_config["door_groups"][group_name] | 260 | item_id = ids_config["door_groups"][group_name] |
218 | warp_ids_by_item_id[item_id] = warp_ids.to_a | 261 | warp_ids_by_item_id[item_id] = warp_ids.to_a |
@@ -231,6 +274,12 @@ File.open(outputpath, "w") do |f| | |||
231 | "\"#{door_id}\"" | 274 | "\"#{door_id}\"" |
232 | end.join(",") + "]" | 275 | end.join(",") + "]" |
233 | end.join(",")) | 276 | end.join(",")) |
277 | f.write "}\nvar panel_ids_by_item_id = {" | ||
278 | f.write(panel_ids_by_item_id.map do |item_id, panel_ids| | ||
279 | "#{item_id}:[" + panel_ids.map do |panel_id| | ||
280 | "\"#{panel_id}\"" | ||
281 | end.join(",") + "]" | ||
282 | end.join(",")) | ||
234 | f.write "}\nvar painting_ids_by_item_id = {" | 283 | f.write "}\nvar painting_ids_by_item_id = {" |
235 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| | 284 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| |
236 | "#{item_id}:[" + painting_ids.map do |painting_id| | 285 | "#{item_id}:[" + painting_ids.map do |painting_id| |
@@ -257,6 +306,10 @@ File.open(outputpath, "w") do |f| | |||
257 | f.write(mentioned_paintings.map do |painting_id| | 306 | f.write(mentioned_paintings.map do |painting_id| |
258 | "\"#{painting_id}\"" | 307 | "\"#{painting_id}\"" |
259 | end.join(",")) | 308 | end.join(",")) |
309 | f.write "]\nvar mentioned_panels = [" | ||
310 | f.write(mentioned_panels.map do |panel_id| | ||
311 | "\"#{panel_id}\"" | ||
312 | end.join(",")) | ||
260 | f.write "]\nvar mentioned_warps = [" | 313 | f.write "]\nvar mentioned_warps = [" |
261 | f.write(mentioned_warps.map do |warp_id| | 314 | f.write(mentioned_warps.map do |warp_id| |
262 | "\"#{warp_id}\"" | 315 | "\"#{warp_id}\"" |
@@ -273,8 +326,12 @@ File.open(outputpath, "w") do |f| | |||
273 | f.write(sunwarps.map do |sunwarp| | 326 | f.write(sunwarps.map do |sunwarp| |
274 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" | 327 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" |
275 | end.join(",")) | 328 | end.join(",")) |
276 | f.write "]\nvar items_by_progressive_id = {" | 329 | f.write "]\nvar door_items_by_progressive_id = {" |
277 | f.write(items_by_progressive_id.map do |item_id, progression_ids| | 330 | f.write(door_items_by_progressive_id.map do |item_id, progression_ids| |
331 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" | ||
332 | end.join(",")) | ||
333 | f.write "}\nvar panel_items_by_progressive_id = {" | ||
334 | f.write(panel_items_by_progressive_id.map do |item_id, progression_ids| | ||
278 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" | 335 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" |
279 | end.join(",")) | 336 | end.join(",")) |
280 | f.write "}" | 337 | f.write "}" |