diff options
Diffstat (limited to 'util/generate_gamedata.rb')
-rw-r--r-- | util/generate_gamedata.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index bf8e3ae..72f0932 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb | |||
@@ -4,6 +4,10 @@ require 'yaml' | |||
4 | configpath = ARGV[0] | 4 | configpath = ARGV[0] |
5 | outputpath = ARGV[1] | 5 | outputpath = ARGV[1] |
6 | 6 | ||
7 | CLASSIFICATION_NORMAL = 1 | ||
8 | CLASSIFICATION_REDUCED = 2 | ||
9 | CLASSIFICATION_INSANITY = 4 | ||
10 | |||
7 | panel_to_id = {} | 11 | panel_to_id = {} |
8 | door_groups = {} | 12 | door_groups = {} |
9 | 13 | ||
@@ -11,6 +15,7 @@ panel_output = [] | |||
11 | door_ids_by_item_id = {} | 15 | door_ids_by_item_id = {} |
12 | painting_ids_by_item_id = {} | 16 | painting_ids_by_item_id = {} |
13 | panel_ids_by_location_id = {} | 17 | panel_ids_by_location_id = {} |
18 | classification_by_location_id = {} | ||
14 | mentioned_doors = Set[] | 19 | mentioned_doors = Set[] |
15 | mentioned_paintings = Set[] | 20 | mentioned_paintings = Set[] |
16 | painting_output = {} | 21 | painting_output = {} |
@@ -54,8 +59,17 @@ config.each do |room_name, room_data| | |||
54 | end | 59 | end |
55 | panel_output << ret | 60 | panel_output << ret |
56 | 61 | ||
62 | panel_ids_by_location_id[full_name] = [panel["id"]] | ||
63 | |||
64 | classification_by_location_id[full_name] ||= 0 | ||
65 | classification_by_location_id[full_name] += CLASSIFICATION_INSANITY | ||
66 | |||
57 | if panel.include? "check" and panel["check"] | 67 | if panel.include? "check" and panel["check"] |
58 | panel_ids_by_location_id[full_name] = [panel["id"]] | 68 | classification_by_location_id[full_name] += CLASSIFICATION_NORMAL |
69 | |||
70 | unless panel.include? "exclude_reduce" and panel["exclude_reduce"] | ||
71 | classification_by_location_id[full_name] += CLASSIFICATION_REDUCED | ||
72 | end | ||
59 | end | 73 | end |
60 | end | 74 | end |
61 | end | 75 | end |
@@ -105,6 +119,13 @@ config.each do |room_name, room_data| | |||
105 | end | 119 | end |
106 | panel_to_id[other_name] | 120 | panel_to_id[other_name] |
107 | end | 121 | end |
122 | |||
123 | classification_by_location_id[chosen_name] ||= 0 | ||
124 | classification_by_location_id[chosen_name] += CLASSIFICATION_NORMAL | ||
125 | |||
126 | if door.include? "include_reduce" and door["include_reduce"] | ||
127 | classification_by_location_id[chosen_name] += CLASSIFICATION_REDUCED | ||
128 | end | ||
108 | end | 129 | end |
109 | 130 | ||
110 | if not (door.include? "skip_item" and door["skip_item"]) and | 131 | if not (door.include? "skip_item" and door["skip_item"]) and |
@@ -189,5 +210,9 @@ File.open(outputpath, "w") do |f| | |||
189 | f.write(painting_output.map do |painting_id, painting| | 210 | f.write(painting_output.map do |painting_id, painting| |
190 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" | 211 | "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" |
191 | end.join(",")) | 212 | end.join(",")) |
213 | f.write "}\nvar classification_by_location_id = {" | ||
214 | f.write(classification_by_location_id.map do |location_id, classification| | ||
215 | "\"#{location_id}\":#{classification}" | ||
216 | end.join(",")) | ||
192 | f.write "}" | 217 | f.write "}" |
193 | end | 218 | end |