about summary refs log tree commit diff stats
path: root/util/generate_gamedata.rb
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-05-29 13:34:53 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-05-29 13:34:53 -0400
commiteff3dff1142876b70e0336f03b4efb12db4e2bba (patch)
treed0f19c16094706e9c3a6d4b59d9f4ee44e535ad4 /util/generate_gamedata.rb
parent8b97ed0755c8d950f5cc8f9a957636982f33f012 (diff)
parent2b0fcdde3144213676324163d721150a8641d610 (diff)
downloadlingo-archipelago-eff3dff1142876b70e0336f03b4efb12db4e2bba.tar.gz
lingo-archipelago-eff3dff1142876b70e0336f03b4efb12db4e2bba.tar.bz2
lingo-archipelago-eff3dff1142876b70e0336f03b4efb12db4e2bba.zip
Merge branch 'main' into color-hallways
Diffstat (limited to 'util/generate_gamedata.rb')
-rw-r--r--util/generate_gamedata.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb index f63e062..1f18b7e 100644 --- a/util/generate_gamedata.rb +++ b/util/generate_gamedata.rb
@@ -11,15 +11,20 @@ CLASSIFICATION_INSANITY = 4
11 11
12panel_to_id = {} 12panel_to_id = {}
13door_groups = {} 13door_groups = {}
14warp_groups = {}
14 15
15panel_output = [] 16panel_output = []
16door_ids_by_item_id = {} 17door_ids_by_item_id = {}
17painting_ids_by_item_id = {} 18painting_ids_by_item_id = {}
19warp_ids_by_item_id = {}
18panel_ids_by_location_id = {} 20panel_ids_by_location_id = {}
19classification_by_location_id = {} 21classification_by_location_id = {}
22sunwarps = Array.new(12) {Hash.new}
20mentioned_doors = Set[] 23mentioned_doors = Set[]
21mentioned_paintings = Set[] 24mentioned_paintings = Set[]
25mentioned_warps = Set[]
22painting_output = {} 26painting_output = {}
27items_by_progressive_id = {}
23 28
24ids_config = YAML.load_file(idspath) 29ids_config = YAML.load_file(idspath)
25 30
@@ -88,6 +93,30 @@ config.each do |room_name, room_data|
88 painting_output[painting["id"]] = painting 93 painting_output[painting["id"]] = painting
89 end 94 end
90 end 95 end
96
97 if room_data.include? "sunwarps"
98 room_data["sunwarps"].each do |sunwarp|
99 index = sunwarp["dots"] - 1
100 if sunwarp["direction"] == "exit" then
101 index += 6
102 end
103 sunwarps[index] = sunwarp
104 end
105 end
106
107 if room_data.include? "progression"
108 room_data["progression"].each do |progressive_item_name, progression|
109 progressive_id = ids_config["progression"][progressive_item_name]
110 items_by_progressive_id[progressive_id] = []
111
112 progression.each do |item|
113 item_room_name = (item.kind_of? Hash) ? item["room"] : room_name
114 item_item_name = (item.kind_of? Hash) ? item["door"] : item
115
116 items_by_progressive_id[progressive_id] << ids_config["doors"][item_room_name][item_item_name]["item"]
117 end
118 end
119 end
91end 120end
92 121
93config.each do |room_name, room_data| 122config.each do |room_name, room_data|
@@ -152,6 +181,23 @@ config.each do |room_name, room_data|
152 painting_ids_by_item_id[item_id] = internal_painting_ids 181 painting_ids_by_item_id[item_id] = internal_painting_ids
153 mentioned_paintings.merge(internal_painting_ids) 182 mentioned_paintings.merge(internal_painting_ids)
154 end 183 end
184
185 if door.include? "warp_id"
186 internal_warp_ids = []
187 if door["warp_id"].kind_of? String
188 internal_warp_ids = [door["warp_id"]]
189 else
190 internal_warp_ids = door["warp_id"]
191 end
192
193 if door.include? "door_group"
194 warp_groups[door["door_group"]] ||= Set[]
195 warp_groups[door["door_group"]].merge(internal_warp_ids)
196 end
197
198 warp_ids_by_item_id[item_id] = internal_warp_ids
199 mentioned_warps.merge(internal_warp_ids)
200 end
155 end 201 end
156 end 202 end
157 end 203 end
@@ -162,6 +208,11 @@ door_groups.each do |group_name, door_ids|
162 door_ids_by_item_id[item_id] = door_ids.to_a 208 door_ids_by_item_id[item_id] = door_ids.to_a
163end 209end
164 210
211warp_groups.each do |group_name, warp_ids|
212 item_id = ids_config["door_groups"][group_name]
213 warp_ids_by_item_id[item_id] = warp_ids.to_a
214end
215
165File.open(outputpath, "w") do |f| 216File.open(outputpath, "w") do |f|
166 f.write "extends Node\n\nvar panels = [" 217 f.write "extends Node\n\nvar panels = ["
167 f.write(panel_output.map do |panel| 218 f.write(panel_output.map do |panel|
@@ -181,6 +232,12 @@ File.open(outputpath, "w") do |f|
181 "\"#{painting_id}\"" 232 "\"#{painting_id}\""
182 end.join(",") + "]" 233 end.join(",") + "]"
183 end.join(",")) 234 end.join(","))
235 f.write "}\nvar warp_ids_by_item_id = {"
236 f.write(warp_ids_by_item_id.map do |item_id, warp_ids|
237 "#{item_id}:[" + warp_ids.map do |warp_id|
238 "\"#{warp_id}\""
239 end.join(",") + "]"
240 end.join(","))
184 f.write "}\nvar panel_ids_by_location_id = {" 241 f.write "}\nvar panel_ids_by_location_id = {"
185 f.write(panel_ids_by_location_id.map do |location_id, panel_ids| 242 f.write(panel_ids_by_location_id.map do |location_id, panel_ids|
186 "#{location_id}:[" + panel_ids.map do |panel_id| 243 "#{location_id}:[" + panel_ids.map do |panel_id|
@@ -195,6 +252,10 @@ File.open(outputpath, "w") do |f|
195 f.write(mentioned_paintings.map do |painting_id| 252 f.write(mentioned_paintings.map do |painting_id|
196 "\"#{painting_id}\"" 253 "\"#{painting_id}\""
197 end.join(",")) 254 end.join(","))
255 f.write "]\nvar mentioned_warps = ["
256 f.write(mentioned_warps.map do |warp_id|
257 "\"#{warp_id}\""
258 end.join(","))
198 f.write "]\nvar paintings = {" 259 f.write "]\nvar paintings = {"
199 f.write(painting_output.map do |painting_id, painting| 260 f.write(painting_output.map do |painting_id, painting|
200 "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}" 261 "\"#{painting_id}\":{\"orientation\":\"#{painting["orientation"]}\",\"move\":#{painting.include? "move" and painting["move"]}}"
@@ -203,5 +264,13 @@ File.open(outputpath, "w") do |f|
203 f.write(classification_by_location_id.map do |location_id, classification| 264 f.write(classification_by_location_id.map do |location_id, classification|
204 "#{location_id}:#{classification}" 265 "#{location_id}:#{classification}"
205 end.join(",")) 266 end.join(","))
267 f.write "}\nvar sunwarps = ["
268 f.write(sunwarps.map do |sunwarp|
269 "{\"orientation\":\"#{sunwarp["orientation"]}\",\"entrance_indicator_pos\":#{sunwarp["entrance_indicator_pos"].to_s}}"
270 end.join(","))
271 f.write "]\nvar items_by_progressive_id = {"
272 f.write(items_by_progressive_id.map do |item_id, progression_ids|
273 "#{item_id}:[" + progression_ids.map(&:to_s).join(",") + "]"
274 end.join(","))
206 f.write "}" 275 f.write "}"
207end 276end