diff options
Diffstat (limited to 'util/generate_gamedata.rb')
-rw-r--r-- | util/generate_gamedata.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index f63e062..a3f9ba5 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -11,14 +11,17 @@ CLASSIFICATION_INSANITY = 4 | |||
11 | 11 | ||
12 | panel_to_id = {} | 12 | panel_to_id = {} |
13 | door_groups = {} | 13 | door_groups = {} |
14 | panel_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 | panel_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 = {} |
20 | mentioned_doors = Set[] | 22 | mentioned_doors = Set[] |
21 | mentioned_paintings = Set[] | 23 | mentioned_paintings = Set[] |
24 | mentioned_panels = Set[] | ||
22 | painting_output = {} | 25 | painting_output = {} |
23 | 26 | ||
24 | ids_config = YAML.load_file(idspath) | 27 | ids_config = YAML.load_file(idspath) |
@@ -155,6 +158,26 @@ config.each do |room_name, room_data| | |||
155 | end | 158 | end |
156 | end | 159 | end |
157 | end | 160 | end |
161 | |||
162 | if room_data.include? "panel_doors" | ||
163 | room_data["panel_doors"].each do |panel_door_name, panel_door| | ||
164 | item_id = ids_config["panel_doors"][room_name][panel_door_name] | ||
165 | |||
166 | panel_ids_by_item_id[item_id] = panel_door["panels"].map do |panel_identifier| | ||
167 | other_room_name = (panel_identifier.kind_of? String) ? room_name : panel_identifier["room"] | ||
168 | other_panel_name = (panel_identifier.kind_of? String) ? panel_identifier : panel_identifier["panel"] | ||
169 | |||
170 | config[other_room_name]["panels"][other_panel_name]["id"] | ||
171 | end | ||
172 | |||
173 | mentioned_panels.merge(panel_ids_by_item_id[item_id]) | ||
174 | |||
175 | if panel_door.include? "panel_group" | ||
176 | panel_groups[panel_door["panel_group"]] ||= Set[] | ||
177 | panel_groups[panel_door["panel_group"]].merge(panel_ids_by_item_id[item_id]) | ||
178 | end | ||
179 | end | ||
180 | end | ||
158 | end | 181 | end |
159 | 182 | ||
160 | door_groups.each do |group_name, door_ids| | 183 | door_groups.each do |group_name, door_ids| |
@@ -162,6 +185,11 @@ door_groups.each do |group_name, door_ids| | |||
162 | door_ids_by_item_id[item_id] = door_ids.to_a | 185 | door_ids_by_item_id[item_id] = door_ids.to_a |
163 | end | 186 | end |
164 | 187 | ||
188 | panel_groups.each do |group_name, panel_ids| | ||
189 | item_id = ids_config["panel_groups"][group_name] | ||
190 | panel_ids_by_item_id[item_id] = panel_ids.to_a | ||
191 | end | ||
192 | |||
165 | File.open(outputpath, "w") do |f| | 193 | File.open(outputpath, "w") do |f| |
166 | f.write "extends Node\n\nvar panels = [" | 194 | f.write "extends Node\n\nvar panels = [" |
167 | f.write(panel_output.map do |panel| | 195 | f.write(panel_output.map do |panel| |
@@ -175,6 +203,12 @@ File.open(outputpath, "w") do |f| | |||
175 | "\"#{door_id}\"" | 203 | "\"#{door_id}\"" |
176 | end.join(",") + "]" | 204 | end.join(",") + "]" |
177 | end.join(",")) | 205 | end.join(",")) |
206 | f.write "}\nvar panel_ids_by_item_id = {" | ||
207 | f.write(panel_ids_by_item_id.map do |item_id, panel_ids| | ||
208 | "#{item_id}:[" + panel_ids.map do |panel_id| | ||
209 | "\"#{panel_id}\"" | ||
210 | end.join(",") + "]" | ||
211 | end.join(",")) | ||
178 | f.write "}\nvar painting_ids_by_item_id = {" | 212 | f.write "}\nvar painting_ids_by_item_id = {" |
179 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| | 213 | f.write(painting_ids_by_item_id.map do |item_id, painting_ids| |
180 | "#{item_id}:[" + painting_ids.map do |painting_id| | 214 | "#{item_id}:[" + painting_ids.map do |painting_id| |
@@ -195,6 +229,10 @@ File.open(outputpath, "w") do |f| | |||
195 | f.write(mentioned_paintings.map do |painting_id| | 229 | f.write(mentioned_paintings.map do |painting_id| |
196 | "\"#{painting_id}\"" | 230 | "\"#{painting_id}\"" |
197 | end.join(",")) | 231 | end.join(",")) |
232 | f.write "]\nvar mentioned_panels = [" | ||
233 | f.write(mentioned_panels.map do |panel_id| | ||
234 | "\"#{panel_id}\"" | ||
235 | end.join(",")) | ||
198 | f.write "]\nvar paintings = {" | 236 | f.write "]\nvar paintings = {" |
199 | f.write(painting_output.map do |painting_id, painting| | 237 | f.write(painting_output.map do |painting_id, painting| |
200 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" | 238 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" |