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.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index f63e062..8275ab7 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb
@@ -15,10 +15,12 @@ door_groups = {}
15panel_output = [] 15panel_output = []
16door_ids_by_item_id = {} 16door_ids_by_item_id = {}
17painting_ids_by_item_id = {} 17painting_ids_by_item_id = {}
18warp_ids_by_item_id = {}
18panel_ids_by_location_id = {} 19panel_ids_by_location_id = {}
19classification_by_location_id = {} 20classification_by_location_id = {}
20mentioned_doors = Set[] 21mentioned_doors = Set[]
21mentioned_paintings = Set[] 22mentioned_paintings = Set[]
23mentioned_warps = Set[]
22painting_output = {} 24painting_output = {}
23 25
24ids_config = YAML.load_file(idspath) 26ids_config = YAML.load_file(idspath)
@@ -152,6 +154,18 @@ config.each do |room_name, room_data|
152 painting_ids_by_item_id[item_id] = internal_painting_ids 154 painting_ids_by_item_id[item_id] = internal_painting_ids
153 mentioned_paintings.merge(internal_painting_ids) 155 mentioned_paintings.merge(internal_painting_ids)
154 end 156 end
157
158 if door.include? "warp_id"
159 internal_warp_ids = []
160 if door["warp_id"].kind_of? String
161 internal_warp_ids = [door["warp_id"]]
162 else
163 internal_warp_ids = door["warp_id"]
164 end
165
166 warp_ids_by_item_id[item_id] = internal_warp_ids
167 mentioned_warps.merge(internal_warp_ids)
168 end
155 end 169 end
156 end 170 end
157 end 171 end
@@ -181,6 +195,12 @@ File.open(outputpath, "w") do |f|
181 "\"#{painting_id}\"" 195 "\"#{painting_id}\""
182 end.join(",") + "]" 196 end.join(",") + "]"
183 end.join(",")) 197 end.join(","))
198 f.write "}\nvar warp_ids_by_item_id = {"
199 f.write(warp_ids_by_item_id.map do |item_id, warp_ids|
200 "#{item_id}:[" + warp_ids.map do |warp_id|
201 "\"#{warp_id}\""
202 end.join(",") + "]"
203 end.join(","))
184 f.write "}\nvar panel_ids_by_location_id = {" 204 f.write "}\nvar panel_ids_by_location_id = {"
185 f.write(panel_ids_by_location_id.map do |location_id, panel_ids| 205 f.write(panel_ids_by_location_id.map do |location_id, panel_ids|
186 "#{location_id}:[" + panel_ids.map do |panel_id| 206 "#{location_id}:[" + panel_ids.map do |panel_id|
@@ -195,6 +215,10 @@ File.open(outputpath, "w") do |f|
195 f.write(mentioned_paintings.map do |painting_id| 215 f.write(mentioned_paintings.map do |painting_id|
196 "\"#{painting_id}\"" 216 "\"#{painting_id}\""
197 end.join(",")) 217 end.join(","))
218 f.write "]\nvar mentioned_warps = ["
219 f.write(mentioned_warps.map do |warp_id|
220 "\"#{warp_id}\""
221 end.join(","))
198 f.write "]\nvar paintings = {" 222 f.write "]\nvar paintings = {"
199 f.write(painting_output.map do |painting_id, painting| 223 f.write(painting_output.map do |painting_id, painting|
200 "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" 224 "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}"