diff options
Diffstat (limited to 'util')
-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 3f610b1..ce8df43 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -12,15 +12,20 @@ CLASSIFICATION_SMALL_SPHERE_ONE = 8 | |||
12 | 12 | ||
13 | panel_to_id = {} | 13 | panel_to_id = {} |
14 | door_groups = {} | 14 | door_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 | warp_ids_by_item_id = {} | ||
19 | panel_ids_by_location_id = {} | 21 | panel_ids_by_location_id = {} |
20 | classification_by_location_id = {} | 22 | classification_by_location_id = {} |
23 | sunwarps = Array.new(12) {Hash.new} | ||
21 | mentioned_doors = Set[] | 24 | mentioned_doors = Set[] |
22 | mentioned_paintings = Set[] | 25 | mentioned_paintings = Set[] |
26 | mentioned_warps = Set[] | ||
23 | painting_output = {} | 27 | painting_output = {} |
28 | items_by_progressive_id = {} | ||
24 | 29 | ||
25 | ids_config = YAML.load_file(idspath) | 30 | ids_config = YAML.load_file(idspath) |
26 | 31 | ||
@@ -93,6 +98,30 @@ config.each do |room_name, room_data| | |||
93 | painting_output[painting["id"]] = painting | 98 | painting_output[painting["id"]] = painting |
94 | end | 99 | end |
95 | end | 100 | end |
101 | |||
102 | if room_data.include? "sunwarps" | ||
103 | room_data["sunwarps"].each do |sunwarp| | ||
104 | index = sunwarp["dots"] - 1 | ||
105 | if sunwarp["direction"] == "exit" then | ||
106 | index += 6 | ||
107 | end | ||
108 | sunwarps[index] = sunwarp | ||
109 | end | ||
110 | end | ||
111 | |||
112 | if room_data.include? "progression" | ||
113 | room_data["progression"].each do |progressive_item_name, progression| | ||
114 | progressive_id = ids_config["progression"][progressive_item_name] | ||
115 | items_by_progressive_id[progressive_id] = [] | ||
116 | |||
117 | progression.each do |item| | ||
118 | item_room_name = (item.kind_of? Hash) ? item["room"] : room_name | ||
119 | item_item_name = (item.kind_of? Hash) ? item["door"] : item | ||
120 | |||
121 | items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"] | ||
122 | end | ||
123 | end | ||
124 | end | ||
96 | end | 125 | end |
97 | 126 | ||
98 | config.each do |room_name, room_data| | 127 | config.each do |room_name, room_data| |
@@ -157,6 +186,23 @@ config.each do |room_name, room_data| | |||
157 | painting_ids_by_item_id[item_id] = internal_painting_ids | 186 | painting_ids_by_item_id[item_id] = internal_painting_ids |
158 | mentioned_paintings.merge(internal_painting_ids) | 187 | mentioned_paintings.merge(internal_painting_ids) |
159 | end | 188 | end |
189 | |||
190 | if door.include? "warp_id" | ||
191 | internal_warp_ids = [] | ||
192 | if door["warp_id"].kind_of? String | ||
193 | internal_warp_ids = [door["warp_id"]] | ||
194 | else | ||
195 | internal_warp_ids = door["warp_id"] | ||
196 | end | ||
197 | |||
198 | if door.include? "door_group" | ||
199 | warp_groups[door["door_group"]] ||= Set[] | ||
200 | warp_groups[door["door_group"]].merge(internal_warp_ids) | ||
201 | end | ||
202 | |||
203 | warp_ids_by_item_id[item_id] = internal_warp_ids | ||
204 | mentioned_warps.merge(internal_warp_ids) | ||
205 | end | ||
160 | end | 206 | end |
161 | end | 207 | end |
162 | end | 208 | end |
@@ -167,6 +213,11 @@ door_groups.each do |group_name, door_ids| | |||
167 | door_ids_by_item_id[item_id] = door_ids.to_a | 213 | door_ids_by_item_id[item_id] = door_ids.to_a |
168 | end | 214 | end |
169 | 215 | ||
216 | warp_groups.each do |group_name, warp_ids| | ||
217 | item_id = ids_config["door_groups"][group_name] | ||
218 | warp_ids_by_item_id[item_id] = warp_ids.to_a | ||
219 | end | ||
220 | |||
170 | File.open(outputpath, "w") do |f| | 221 | File.open(outputpath, "w") do |f| |
171 | f.write "extends Node\n\nvar panels = [" | 222 | f.write "extends Node\n\nvar panels = [" |
172 | f.write(panel_output.map do |panel| | 223 | f.write(panel_output.map do |panel| |
@@ -186,6 +237,12 @@ File.open(outputpath, "w") do |f| | |||
186 | "\"#{painting_id}\"" | 237 | "\"#{painting_id}\"" |
187 | end.join(",") + "]" | 238 | end.join(",") + "]" |
188 | end.join(",")) | 239 | end.join(",")) |
240 | f.write "}\nvar warp_ids_by_item_id = {" | ||
241 | f.write(warp_ids_by_item_id.map do |item_id, warp_ids| | ||
242 | "#{item_id}:[" + warp_ids.map do |warp_id| | ||
243 | "\"#{warp_id}\"" | ||
244 | end.join(",") + "]" | ||
245 | end.join(",")) | ||
189 | f.write "}\nvar panel_ids_by_location_id = {" | 246 | f.write "}\nvar panel_ids_by_location_id = {" |
190 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| | 247 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| |
191 | "#{location_id}:[" + panel_ids.map do |panel_id| | 248 | "#{location_id}:[" + panel_ids.map do |panel_id| |
@@ -200,6 +257,10 @@ File.open(outputpath, "w") do |f| | |||
200 | f.write(mentioned_paintings.map do |painting_id| | 257 | f.write(mentioned_paintings.map do |painting_id| |
201 | "\"#{painting_id}\"" | 258 | "\"#{painting_id}\"" |
202 | end.join(",")) | 259 | end.join(",")) |
260 | f.write "]\nvar mentioned_warps = [" | ||
261 | f.write(mentioned_warps.map do |warp_id| | ||
262 | "\"#{warp_id}\"" | ||
263 | end.join(",")) | ||
203 | f.write "]\nvar paintings = {" | 264 | f.write "]\nvar paintings = {" |
204 | f.write(painting_output.map do |painting_id, painting| | 265 | f.write(painting_output.map do |painting_id, painting| |
205 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" | 266 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" |
@@ -208,5 +269,13 @@ File.open(outputpath, "w") do |f| | |||
208 | f.write(classification_by_location_id.map do |location_id, classification| | 269 | f.write(classification_by_location_id.map do |location_id, classification| |
209 | "#{location_id}:#{classification}" | 270 | "#{location_id}:#{classification}" |
210 | end.join(",")) | 271 | end.join(",")) |
272 | f.write "}\nvar sunwarps = [" | ||
273 | f.write(sunwarps.map do |sunwarp| | ||
274 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" | ||
275 | end.join(",")) | ||
276 | f.write "]\nvar items_by_progressive_id = {" | ||
277 | f.write(items_by_progressive_id.map do |item_id, progression_ids| | ||
278 | "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]" | ||
279 | end.join(",")) | ||
211 | f.write "}" | 280 | f.write "}" |
212 | end | 281 | end |