diff options
Diffstat (limited to 'util/generate_gamedata.rb')
-rw-r--r-- | util/generate_gamedata.rb | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index 5e03655..7674277 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -11,14 +11,18 @@ CLASSIFICATION_INSANITY = 4 | |||
11 | 11 | ||
12 | panel_to_id = {} | 12 | panel_to_id = {} |
13 | door_groups = {} | 13 | door_groups = {} |
14 | warp_groups = {} | ||
14 | 15 | ||
15 | panel_output = [] | 16 | panel_output = [] |
16 | door_ids_by_item_id = {} | 17 | door_ids_by_item_id = {} |
17 | painting_ids_by_item_id = {} | 18 | painting_ids_by_item_id = {} |
19 | warp_ids_by_item_id = {} | ||
18 | panel_ids_by_location_id = {} | 20 | panel_ids_by_location_id = {} |
19 | classification_by_location_id = {} | 21 | classification_by_location_id = {} |
22 | sunwarps = Array.new(12) {Hash.new} | ||
20 | mentioned_doors = Set[] | 23 | mentioned_doors = Set[] |
21 | mentioned_paintings = Set[] | 24 | mentioned_paintings = Set[] |
25 | mentioned_warps = Set[] | ||
22 | painting_output = {} | 26 | painting_output = {} |
23 | 27 | ||
24 | ids_config = YAML.load_file(idspath) | 28 | ids_config = YAML.load_file(idspath) |
@@ -88,6 +92,16 @@ config.each do |room_name, room_data| | |||
88 | painting_output[painting["id"]] = painting | 92 | painting_output[painting["id"]] = painting |
89 | end | 93 | end |
90 | end | 94 | end |
95 | |||
96 | if room_data.include? "sunwarps" | ||
97 | room_data["sunwarps"].each do |sunwarp| | ||
98 | index = sunwarp["dots"] - 1 | ||
99 | if sunwarp["direction"] == "exit" then | ||
100 | index += 6 | ||
101 | end | ||
102 | sunwarps[index] = sunwarp | ||
103 | end | ||
104 | end | ||
91 | end | 105 | end |
92 | 106 | ||
93 | config.each do |room_name, room_data| | 107 | config.each do |room_name, room_data| |
@@ -152,6 +166,23 @@ config.each do |room_name, room_data| | |||
152 | painting_ids_by_item_id[item_id] = internal_painting_ids | 166 | painting_ids_by_item_id[item_id] = internal_painting_ids |
153 | mentioned_paintings.merge(internal_painting_ids) | 167 | mentioned_paintings.merge(internal_painting_ids) |
154 | end | 168 | end |
169 | |||
170 | if door.include? "warp_id" | ||
171 | internal_warp_ids = [] | ||
172 | if door["warp_id"].kind_of? String | ||
173 | internal_warp_ids = [door["warp_id"]] | ||
174 | else | ||
175 | internal_warp_ids = door["warp_id"] | ||
176 | end | ||
177 | |||
178 | if door.include? "group" | ||
179 | warp_groups[door["group"]] ||= Set[] | ||
180 | warp_groups[door["group"]].merge(internal_warp_ids) | ||
181 | end | ||
182 | |||
183 | warp_ids_by_item_id[item_id] = internal_warp_ids | ||
184 | mentioned_warps.merge(internal_warp_ids) | ||
185 | end | ||
155 | end | 186 | end |
156 | end | 187 | end |
157 | end | 188 | end |
@@ -162,6 +193,11 @@ door_groups.each do |group_name, door_ids| | |||
162 | door_ids_by_item_id[item_id] = door_ids.to_a | 193 | door_ids_by_item_id[item_id] = door_ids.to_a |
163 | end | 194 | end |
164 | 195 | ||
196 | warp_groups.each do |group_name, warp_ids| | ||
197 | item_id = ids_config["door_groups"][group_name] | ||
198 | warp_ids_by_item_id[item_id] = warp_ids.to_a | ||
199 | end | ||
200 | |||
165 | File.open(outputpath, "w") do |f| | 201 | File.open(outputpath, "w") do |f| |
166 | f.write "extends Node\n\nvar panels = [" | 202 | f.write "extends Node\n\nvar panels = [" |
167 | f.write(panel_output.map do |panel| | 203 | f.write(panel_output.map do |panel| |
@@ -181,6 +217,12 @@ File.open(outputpath, "w") do |f| | |||
181 | "\"#{painting_id}\"" | 217 | "\"#{painting_id}\"" |
182 | end.join(",") + "]" | 218 | end.join(",") + "]" |
183 | end.join(",")) | 219 | end.join(",")) |
220 | f.write "}\nvar warp_ids_by_item_id = {" | ||
221 | f.write(warp_ids_by_item_id.map do |item_id, warp_ids| | ||
222 | "#{item_id}:[" + warp_ids.map do |warp_id| | ||
223 | "\"#{warp_id}\"" | ||
224 | end.join(",") + "]" | ||
225 | end.join(",")) | ||
184 | f.write "}\nvar panel_ids_by_location_id = {" | 226 | f.write "}\nvar panel_ids_by_location_id = {" |
185 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| | 227 | f.write(panel_ids_by_location_id.map do |location_id, panel_ids| |
186 | "#{location_id}:[" + panel_ids.map do |panel_id| | 228 | "#{location_id}:[" + panel_ids.map do |panel_id| |
@@ -195,6 +237,10 @@ File.open(outputpath, "w") do |f| | |||
195 | f.write(mentioned_paintings.map do |painting_id| | 237 | f.write(mentioned_paintings.map do |painting_id| |
196 | "\"#{painting_id}\"" | 238 | "\"#{painting_id}\"" |
197 | end.join(",")) | 239 | end.join(",")) |
240 | f.write "]\nvar mentioned_warps = [" | ||
241 | f.write(mentioned_warps.map do |warp_id| | ||
242 | "\"#{warp_id}\"" | ||
243 | end.join(",")) | ||
198 | f.write "]\nvar paintings = {" | 244 | f.write "]\nvar paintings = {" |
199 | f.write(painting_output.map do |painting_id, painting| | 245 | f.write(painting_output.map do |painting_id, painting| |
200 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" | 246 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" |
@@ -203,5 +249,9 @@ File.open(outputpath, "w") do |f| | |||
203 | f.write(classification_by_location_id.map do |location_id, classification| | 249 | f.write(classification_by_location_id.map do |location_id, classification| |
204 | "#{location_id}:#{classification}" | 250 | "#{location_id}:#{classification}" |
205 | end.join(",")) | 251 | end.join(",")) |
206 | f.write "}" | 252 | f.write "}\nvar sunwarps = [" |
253 | f.write(sunwarps.map do |sunwarp| | ||
254 | "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}" | ||
255 | end.join(",")) | ||
256 | f.write "]" | ||
207 | end | 257 | end |