about summary refs log tree commit diff stats
path: root/util/generate_gamedata.rb
diff options
context:
space:
mode:
Diffstat (limited to 'util/generate_gamedata.rb')
-rw-r--r--util/generate_gamedata.rb69
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
13panel_to_id = {} 13panel_to_id = {}
14door_groups = {} 14door_groups = {}
15warp_groups = {}
15 16
16panel_output = [] 17panel_output = []
17door_ids_by_item_id = {} 18door_ids_by_item_id = {}
18painting_ids_by_item_id = {} 19painting_ids_by_item_id = {}
20warp_ids_by_item_id = {}
19panel_ids_by_location_id = {} 21panel_ids_by_location_id = {}
20classification_by_location_id = {} 22classification_by_location_id = {}
23sunwarps = Array.new(12) {Hash.new}
21mentioned_doors = Set[] 24mentioned_doors = Set[]
22mentioned_paintings = Set[] 25mentioned_paintings = Set[]
26mentioned_warps = Set[]
23painting_output = {} 27painting_output = {}
28items_by_progressive_id = {}
24 29
25ids_config = YAML.load_file(idspath) 30ids_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
96end 125end
97 126
98config.each do |room_name, room_data| 127config.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
168end 214end
169 215
216warp_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
219end
220
170File.open(outputpath, "w") do |f| 221File.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 "}"
212end 281end