diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-04-27 12:13:38 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-04-27 12:13:38 -0400 |
commit | 47755e9e28f9b8866d3c41866910594e2d8c979a (patch) | |
tree | 488df5471f58eb0c6a1f7f872a17aa0ebe07231e /util | |
parent | 4302e550cde189d8bc1d111e81270ed7960ad77c (diff) | |
parent | 0c25dc87e5ad9c8c8c2ff0ef5ac6502b166bc405 (diff) | |
download | lingo-archipelago-47755e9e28f9b8866d3c41866910594e2d8c979a.tar.gz lingo-archipelago-47755e9e28f9b8866d3c41866910594e2d8c979a.tar.bz2 lingo-archipelago-47755e9e28f9b8866d3c41866910594e2d8c979a.zip |
Merge branch 'main' into panels
Diffstat (limited to 'util')
-rw-r--r-- | util/generate_gamedata.rb | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index a3f9ba5..4f9dfd7 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -12,17 +12,23 @@ CLASSIFICATION_INSANITY = 4 | |||
12 | panel_to_id = {} | 12 | panel_to_id = {} |
13 | door_groups = {} | 13 | door_groups = {} |
14 | panel_groups = {} | 14 | panel_groups = {} |
15 | warp_groups = {} | ||
15 | 16 | ||
16 | panel_output = [] | 17 | panel_output = [] |
17 | door_ids_by_item_id = {} | 18 | door_ids_by_item_id = {} |
18 | painting_ids_by_item_id = {} | 19 | painting_ids_by_item_id = {} |
19 | panel_ids_by_item_id = {} | 20 | panel_ids_by_item_id = {} |
21 | warp_ids_by_item_id = {} | ||
20 | panel_ids_by_location_id = {} | 22 | panel_ids_by_location_id = {} |
21 | classification_by_location_id = {} | 23 | classification_by_location_id = {} |
24 | sunwarps = Array.new(12) {Hash.new} | ||
22 | mentioned_doors = Set[] | 25 | mentioned_doors = Set[] |
23 | mentioned_paintings = Set[] | 26 | mentioned_paintings = Set[] |
24 | mentioned_panels = Set[] | 27 | mentioned_panels = Set[] |
28 | mentioned_warps = Set[] | ||
25 | painting_output = {} | 29 | painting_output = {} |
30 | door_items_by_progressive_id = {} | ||
31 | panel_items_by_progressive_id = {} | ||
26 | 32 | ||
27 | ids_config = YAML.load_file(idspath) | 33 | ids_config = YAML.load_file(idspath) |
28 | 34 | ||
@@ -91,6 +97,44 @@ config.each do |room_name, room_data| | |||
91 | painting_output[painting["id"]] = painting | 97 | painting_output[painting["id"]] = painting |
92 | end | 98 | end |
93 | end | 99 | end |
100 | |||
101 | if room_data.include? "sunwarps" | ||
102 | room_data["sunwarps"].each do |sunwarp| | ||
103 | index = sunwarp["dots"] - 1 | ||
104 | if sunwarp["direction"] == "exit" then | ||
105 | index += 6 | ||
106 | end | ||
107 | sunwarps[index] = sunwarp | ||
108 | end | ||
109 | end | ||
110 | |||
111 | if room_data.include? "progression" | ||
112 | room_data["progression"].each do |progressive_item_name, pdata| | ||
113 | progressive_id = ids_config["progression"][progressive_item_name] | ||
114 | |||
115 | if pdata.include? "doors" | ||
116 | door_items_by_progressive_id[progressive_id] = [] | ||
117 | |||
118 | pdata["doors"].each do |item| | ||
119 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | ||
120 | item_item_name = (item.kind_of? Hash) ? item["door"] : item | ||
121 | |||
122 | door_items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"] | ||
123 | end | ||
124 | end | ||
125 | |||
126 | if pdata.include? "panel_doors" | ||
127 | panel_items_by_progressive_id[progressive_id] = [] | ||
128 | |||
129 | pdata["panel_doors"].each do |item| | ||
130 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | ||
131 | item_item_name = (item.kind_of? Hash) ? item["panel_door"] : item | ||
132 | |||
133 | panel_items_by_progressive_id[progressive_id] << ids_config["panel_doors"][item_room_name][item_item_name] | ||
134 | end | ||
135 | end | ||
136 | end | ||
137 | end | ||
94 | end | 138 | end |
95 | 139 | ||
96 | config.each do |room_name, room_data| | 140 | config.each do |room_name, room_data| |
@@ -155,6 +199,23 @@ config.each do |room_name, room_data| | |||
155 | painting_ids_by_item_id[item_id] = internal_painting_ids | 199 | painting_ids_by_item_id[item_id] = internal_painting_ids |
156 | mentioned_paintings.merge(internal_painting_ids) | 200 | mentioned_paintings.merge(internal_painting_ids) |
157 | end | 201 | end |
202 | |||
203 | if door.include? "warp_id" | ||
204 | internal_warp_ids = [] | ||
205 | if door["warp_id"].kind_of? String | ||
206 | internal_warp_ids = [door["warp_id"]] | ||
207 | else | ||
208 | internal_warp_ids = door["warp_id"] | ||
209 | end | ||
210 | |||
211 | if door.include? "door_group" | ||
212 | warp_groups[door["door_group"]] ||= Set[] | ||
213 | warp_groups[door["door_group"]].merge(internal_warp_ids) | ||
214 | end | ||
215 | |||
216 | warp_ids_by_item_id[item_id] = internal_warp_ids | ||
217 | mentioned_warps.merge(internal_warp_ids) | ||
218 | end | ||
158 | end | 219 | end |
159 | end | 220 | end |
160 | end | 221 | end |
@@ -190,6 +251,11 @@ panel_groups.each do |group_name, panel_ids| | |||
190 | panel_ids_by_item_id[item_id] = panel_ids.to_a | 251 | panel_ids_by_item_id[item_id] = panel_ids.to_a |
191 | end | 252 | end |
192 | 253 | ||
254 | warp_groups.each do |group_name, warp_ids| | ||
255 | item_id = ids_config["door_groups"][group_name] | ||
256 | warp_ids_by_item_id[item_id] = warp_ids.to_a | ||
257 | end | ||
258 | |||
193 | File.open(outputpath, "w") do |f| | 259 | File.open(outputpath, "w") do |f| |
194 | f.write "extends Node\n\nvar panels = [" | 260 | f.write "extends Node\n\nvar panels = [" |
195 | f.write(panel_output.map do |panel| | 261 | f.write(panel_output.map do |panel| |
@@ -215,6 +281,12 @@ File.open(outputpath, "w") do |f| | |||
215 | "\"#{painting_id}\"" | 281 | "\"#{painting_id}\"" |
216 | end.join(",") + "]" | 282 | end.join(",") + "]" |
217 | end.join(",")) | 283 | end.join(",")) |
284 | f.write "}\nvar warp_ids_by_item_id = {" | ||
285 | f.write(warp_ids_by_item_id.map do |item_id, warp_ids| | ||
286 | "#{item_id}:[" + warp_ids.map do |warp_id| | ||
287 | "\"#{warp_id}\"" | ||
288 | end.join(",") + "]" | ||
289 | end.join(",")) | ||
218 | f.write "}\nvar panel_ids_by_location_id = {" | 290 | f.write "}\nvar panel_ids_by_location_id = {" |
219 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| | 291 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| |
220 | "#{location_id}:[" + panel_ids.map do |panel_id| | 292 | "#{location_id}:[" + panel_ids.map do |panel_id| |
@@ -233,6 +305,10 @@ File.open(outputpath, "w") do |f| | |||
233 | f.write(mentioned_panels.map do |panel_id| | 305 | f.write(mentioned_panels.map do |panel_id| |
234 | "\"#{panel_id}\"" | 306 | "\"#{panel_id}\"" |
235 | end.join(",")) | 307 | end.join(",")) |
308 | f.write "]\nvar mentioned_warps = [" | ||
309 | f.write(mentioned_warps.map do |warp_id| | ||
310 | "\"#{warp_id}\"" | ||
311 | end.join(",")) | ||
236 | f.write "]\nvar paintings = {" | 312 | f.write "]\nvar paintings = {" |
237 | f.write(painting_output.map do |painting_id, painting| | 313 | f.write(painting_output.map do |painting_id, painting| |
238 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" | 314 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" |
@@ -241,5 +317,17 @@ File.open(outputpath, "w") do |f| | |||
241 | f.write(classification_by_location_id.map do |location_id, classification| | 317 | f.write(classification_by_location_id.map do |location_id, classification| |
242 | "#{location_id}:#{classification}" | 318 | "#{location_id}:#{classification}" |
243 | end.join(",")) | 319 | end.join(",")) |
320 | f.write "}\nvar sunwarps = [" | ||
321 | f.write(sunwarps.map do |sunwarp| | ||
322 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" | ||
323 | end.join(",")) | ||
324 | f.write "]\nvar door_items_by_progressive_id = {" | ||
325 | f.write(door_items_by_progressive_id.map do |item_id, progression_ids| | ||
326 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" | ||
327 | end.join(",")) | ||
328 | f.write "}\nvar panel_items_by_progressive_id = {" | ||
329 | f.write(panel_items_by_progressive_id.map do |item_id, progression_ids| | ||
330 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" | ||
331 | end.join(",")) | ||
244 | f.write "}" | 332 | f.write "}" |
245 | end | 333 | end |