diff options
Diffstat (limited to 'util/generate_gamedata.rb')
-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 1f18b7e..4f9dfd7 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -11,20 +11,24 @@ CLASSIFICATION_INSANITY = 4 | |||
11 | 11 | ||
12 | panel_to_id = {} | 12 | panel_to_id = {} |
13 | door_groups = {} | 13 | door_groups = {} |
14 | panel_groups = {} | ||
14 | warp_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 = {} |
20 | panel_ids_by_item_id = {} | ||
19 | warp_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 = {} |
22 | sunwarps = Array.new(12) {Hash.new} | 24 | sunwarps = Array.new(12) {Hash.new} |
23 | mentioned_doors = Set[] | 25 | mentioned_doors = Set[] |
24 | mentioned_paintings = Set[] | 26 | mentioned_paintings = Set[] |
27 | mentioned_panels = Set[] | ||
25 | mentioned_warps = Set[] | 28 | mentioned_warps = Set[] |
26 | painting_output = {} | 29 | painting_output = {} |
27 | items_by_progressive_id = {} | 30 | door_items_by_progressive_id = {} |
31 | panel_items_by_progressive_id = {} | ||
28 | 32 | ||
29 | ids_config = YAML.load_file(idspath) | 33 | ids_config = YAML.load_file(idspath) |
30 | 34 | ||
@@ -105,15 +109,29 @@ config.each do |room_name, room_data| | |||
105 | end | 109 | end |
106 | 110 | ||
107 | if room_data.include? "progression" | 111 | if room_data.include? "progression" |
108 | room_data["progression"].each do |progressive_item_name, progression| | 112 | room_data["progression"].each do |progressive_item_name, pdata| |
109 | progressive_id = ids_config["progression"][progressive_item_name] | 113 | progressive_id = ids_config["progression"][progressive_item_name] |
110 | items_by_progressive_id[progressive_id] = [] | ||
111 | 114 | ||
112 | progression.each do |item| | 115 | if pdata.include? "doors" |
113 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | 116 | door_items_by_progressive_id[progressive_id] = [] |
114 | item_item_name = (item.kind_of? Hash) ? item["door"] : item | ||
115 | 117 | ||
116 | items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"] | 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 | ||
117 | end | 135 | end |
118 | end | 136 | end |
119 | end | 137 | end |
@@ -201,6 +219,26 @@ config.each do |room_name, room_data| | |||
201 | end | 219 | end |
202 | end | 220 | end |
203 | end | 221 | end |
222 | |||
223 | if room_data.include? "panel_doors" | ||
224 | room_data["panel_doors"].each do |panel_door_name, panel_door| | ||
225 | item_id = ids_config["panel_doors"][room_name][panel_door_name] | ||
226 | |||
227 | panel_ids_by_item_id[item_id] = panel_door["panels"].map do |panel_identifier| | ||
228 | other_room_name = (panel_identifier.kind_of? String) ? room_name : panel_identifier["room"] | ||
229 | other_panel_name = (panel_identifier.kind_of? String) ? panel_identifier : panel_identifier["panel"] | ||
230 | |||
231 | config[other_room_name]["panels"][other_panel_name]["id"] | ||
232 | end | ||
233 | |||
234 | mentioned_panels.merge(panel_ids_by_item_id[item_id]) | ||
235 | |||
236 | if panel_door.include? "panel_group" | ||
237 | panel_groups[panel_door["panel_group"]] ||= Set[] | ||
238 | panel_groups[panel_door["panel_group"]].merge(panel_ids_by_item_id[item_id]) | ||
239 | end | ||
240 | end | ||
241 | end | ||
204 | end | 242 | end |
205 | 243 | ||
206 | door_groups.each do |group_name, door_ids| | 244 | door_groups.each do |group_name, door_ids| |
@@ -208,6 +246,11 @@ door_groups.each do |group_name, door_ids| | |||
208 | door_ids_by_item_id[item_id] = door_ids.to_a | 246 | door_ids_by_item_id[item_id] = door_ids.to_a |
209 | end | 247 | end |
210 | 248 | ||
249 | panel_groups.each do |group_name, panel_ids| | ||
250 | item_id = ids_config["panel_groups"][group_name] | ||
251 | panel_ids_by_item_id[item_id] = panel_ids.to_a | ||
252 | end | ||
253 | |||
211 | warp_groups.each do |group_name, warp_ids| | 254 | warp_groups.each do |group_name, warp_ids| |
212 | item_id = ids_config["door_groups"][group_name] | 255 | item_id = ids_config["door_groups"][group_name] |
213 | warp_ids_by_item_id[item_id] = warp_ids.to_a | 256 | warp_ids_by_item_id[item_id] = warp_ids.to_a |
@@ -226,6 +269,12 @@ File.open(outputpath, "w") do |f| | |||
226 | "\"#{door_id}\"" | 269 | "\"#{door_id}\"" |
227 | end.join(",") + "]" | 270 | end.join(",") + "]" |
228 | end.join(",")) | 271 | end.join(",")) |
272 | f.write "}\nvar panel_ids_by_item_id = {" | ||
273 | f.write(panel_ids_by_item_id.map do |item_id, panel_ids| | ||
274 | "#{item_id}:[" + panel_ids.map do |panel_id| | ||
275 | "\"#{panel_id}\"" | ||
276 | end.join(",") + "]" | ||
277 | end.join(",")) | ||
229 | f.write "}\nvar painting_ids_by_item_id = {" | 278 | f.write "}\nvar painting_ids_by_item_id = {" |
230 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| | 279 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| |
231 | "#{item_id}:[" + painting_ids.map do |painting_id| | 280 | "#{item_id}:[" + painting_ids.map do |painting_id| |
@@ -252,6 +301,10 @@ File.open(outputpath, "w") do |f| | |||
252 | f.write(mentioned_paintings.map do |painting_id| | 301 | f.write(mentioned_paintings.map do |painting_id| |
253 | "\"#{painting_id}\"" | 302 | "\"#{painting_id}\"" |
254 | end.join(",")) | 303 | end.join(",")) |
304 | f.write "]\nvar mentioned_panels = [" | ||
305 | f.write(mentioned_panels.map do |panel_id| | ||
306 | "\"#{panel_id}\"" | ||
307 | end.join(",")) | ||
255 | f.write "]\nvar mentioned_warps = [" | 308 | f.write "]\nvar mentioned_warps = [" |
256 | f.write(mentioned_warps.map do |warp_id| | 309 | f.write(mentioned_warps.map do |warp_id| |
257 | "\"#{warp_id}\"" | 310 | "\"#{warp_id}\"" |
@@ -268,8 +321,12 @@ File.open(outputpath, "w") do |f| | |||
268 | f.write(sunwarps.map do |sunwarp| | 321 | f.write(sunwarps.map do |sunwarp| |
269 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" | 322 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" |
270 | end.join(",")) | 323 | end.join(",")) |
271 | f.write "]\nvar items_by_progressive_id = {" | 324 | f.write "]\nvar door_items_by_progressive_id = {" |
272 | f.write(items_by_progressive_id.map do |item_id, progression_ids| | 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| | ||
273 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" | 330 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" |
274 | end.join(",")) | 331 | end.join(",")) |
275 | f.write "}" | 332 | f.write "}" |