diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/generate_gamedata.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index 5e03655..1cce003 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -15,10 +15,12 @@ door_groups = {} | |||
15 | panel_output = [] | 15 | panel_output = [] |
16 | door_ids_by_item_id = {} | 16 | door_ids_by_item_id = {} |
17 | painting_ids_by_item_id = {} | 17 | painting_ids_by_item_id = {} |
18 | warp_ids_by_item_id = {} | ||
18 | panel_ids_by_location_id = {} | 19 | panel_ids_by_location_id = {} |
19 | classification_by_location_id = {} | 20 | classification_by_location_id = {} |
20 | mentioned_doors = Set[] | 21 | mentioned_doors = Set[] |
21 | mentioned_paintings = Set[] | 22 | mentioned_paintings = Set[] |
23 | mentioned_warps = Set[] | ||
22 | painting_output = {} | 24 | painting_output = {} |
23 | 25 | ||
24 | ids_config = YAML.load_file(idspath) | 26 | ids_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"]}}" |