diff options
Diffstat (limited to 'utils/validate_config.rb')
| -rw-r--r-- | utils/validate_config.rb | 88 |
1 files changed, 78 insertions, 10 deletions
| diff --git a/utils/validate_config.rb b/utils/validate_config.rb index 498980b..70f7fc2 100644 --- a/utils/validate_config.rb +++ b/utils/validate_config.rb | |||
| @@ -33,19 +33,23 @@ end | |||
| 33 | configured_rooms = Set["Menu"] | 33 | configured_rooms = Set["Menu"] |
| 34 | configured_doors = Set[] | 34 | configured_doors = Set[] |
| 35 | configured_panels = Set[] | 35 | configured_panels = Set[] |
| 36 | configured_panel_doors = Set[] | ||
| 36 | 37 | ||
| 37 | mentioned_rooms = Set[] | 38 | mentioned_rooms = Set[] |
| 38 | mentioned_doors = Set[] | 39 | mentioned_doors = Set[] |
| 39 | mentioned_panels = Set[] | 40 | mentioned_panels = Set[] |
| 41 | mentioned_panel_doors = Set[] | ||
| 40 | mentioned_sunwarp_entrances = Set[] | 42 | mentioned_sunwarp_entrances = Set[] |
| 41 | mentioned_sunwarp_exits = Set[] | 43 | mentioned_sunwarp_exits = Set[] |
| 42 | mentioned_paintings = Set[] | 44 | mentioned_paintings = Set[] |
| 43 | 45 | ||
| 44 | door_groups = {} | 46 | door_groups = {} |
| 47 | panel_groups = {} | ||
| 45 | 48 | ||
| 46 | directives = Set["entrances", "panels", "doors", "paintings", "sunwarps", "progression"] | 49 | directives = Set["entrances", "panels", "doors", "panel_doors", "paintings", "sunwarps", "progression"] |
| 47 | panel_directives = Set["id", "required_room", "required_door", "required_panel", "colors", "check", "exclude_reduce", "tag", "link", "subtag", "achievement", "copy_to_sign", "non_counting", "hunt", "location_name"] | 50 | panel_directives = Set["id", "required_room", "required_door", "required_panel", "colors", "check", "exclude_reduce", "tag", "link", "subtag", "achievement", "copy_to_sign", "non_counting", "hunt", "location_name"] |
| 48 | door_directives = Set["id", "painting_id", "panels", "item_name", "item_group", "location_name", "skip_location", "skip_item", "door_group", "include_reduce", "event", "warp_id"] | 51 | door_directives = Set["id", "painting_id", "panels", "item_name", "item_group", "location_name", "skip_location", "skip_item", "door_group", "include_reduce", "event", "warp_id"] |
| 52 | panel_door_directives = Set["panels", "item_name", "panel_group"] | ||
| 49 | painting_directives = Set["id", "enter_only", "exit_only", "orientation", "required_door", "required", "required_when_no_doors", "move", "req_blocked", "req_blocked_when_no_doors"] | 53 | painting_directives = Set["id", "enter_only", "exit_only", "orientation", "required_door", "required", "required_when_no_doors", "move", "req_blocked", "req_blocked_when_no_doors"] |
| 50 | 54 | ||
| 51 | non_counting = 0 | 55 | non_counting = 0 |
| @@ -253,6 +257,43 @@ config.each do |room_name, room| | |||
| 253 | end | 257 | end |
| 254 | end | 258 | end |
| 255 | 259 | ||
| 260 | (room["panel_doors"] || {}).each do |panel_door_name, panel_door| | ||
| 261 | configured_panel_doors.add("#{room_name} - #{panel_door_name}") | ||
| 262 | |||
| 263 | if panel_door.include?("panels") | ||
| 264 | panel_door["panels"].each do |panel| | ||
| 265 | if panel.kind_of? Hash then | ||
| 266 | other_room = panel.include?("room") ? panel["room"] : room_name | ||
| 267 | mentioned_panels.add("#{other_room} - #{panel["panel"]}") | ||
| 268 | else | ||
| 269 | other_room = panel.include?("room") ? panel["room"] : room_name | ||
| 270 | mentioned_panels.add("#{room_name} - #{panel}") | ||
| 271 | end | ||
| 272 | end | ||
| 273 | else | ||
| 274 | puts "#{room_name} - #{panel_door_name} :::: Missing panels field" | ||
| 275 | end | ||
| 276 | |||
| 277 | if panel_door.include?("panel_group") | ||
| 278 | panel_groups[panel_door["panel_group"]] ||= 0 | ||
| 279 | panel_groups[panel_door["panel_group"]] += 1 | ||
| 280 | end | ||
| 281 | |||
| 282 | bad_subdirectives = [] | ||
| 283 | panel_door.keys.each do |key| | ||
| 284 | unless panel_door_directives.include?(key) then | ||
| 285 | bad_subdirectives << key | ||
| 286 | end | ||
| 287 | end | ||
| 288 | unless bad_subdirectives.empty? then | ||
| 289 | puts "#{room_name} - #{panel_door_name} :::: Panel door has the following invalid subdirectives: #{bad_subdirectives.join(", ")}" | ||
| 290 | end | ||
| 291 | |||
| 292 | unless ids.include?("panel_doors") and ids["panel_doors"].include?(room_name) and ids["panel_doors"][room_name].include?(panel_door_name) | ||
| 293 | puts "#{room_name} - #{panel_door_name} :::: Panel door is missing an item ID" | ||
| 294 | end | ||
| 295 | end | ||
| 296 | |||
| 256 | (room["paintings"] || []).each do |painting| | 297 | (room["paintings"] || []).each do |painting| |
| 257 | if painting.include?("id") and painting["id"].kind_of? String then | 298 | if painting.include?("id") and painting["id"].kind_of? String then |
| 258 | unless paintings.include? painting["id"] then | 299 | unless paintings.include? painting["id"] then |
| @@ -327,12 +368,24 @@ config.each do |room_name, room| | |||
| 327 | end | 368 | end |
| 328 | end | 369 | end |
| 329 | 370 | ||
| 330 | (room["progression"] || {}).each do |progression_name, door_list| | 371 | (room["progression"] || {}).each do |progression_name, pdata| |
| 331 | door_list.each do |door| | 372 | if pdata.include? "doors" then |
| 332 | if door.kind_of? Hash then | 373 | pdata["doors"].each do |door| |
| 333 | mentioned_doors.add("#{door["room"]} - #{door["door"]}") | 374 | if door.kind_of? Hash then |
| 334 | else | 375 | mentioned_doors.add("#{door["room"]} - #{door["door"]}") |
| 335 | mentioned_doors.add("#{room_name} - #{door}") | 376 | else |
| 377 | mentioned_doors.add("#{room_name} - #{door}") | ||
| 378 | end | ||
| 379 | end | ||
| 380 | end | ||
| 381 | |||
| 382 | if pdata.include? "panel_doors" then | ||
| 383 | pdata["panel_doors"].each do |panel_door| | ||
| 384 | if panel_door.kind_of? Hash then | ||
| 385 | mentioned_panel_doors.add("#{panel_door["room"]} - #{panel_door["panel_door"]}") | ||
| 386 | else | ||
| 387 | mentioned_panel_doors.add("#{room_name} - #{panel_door}") | ||
| 388 | end | ||
| 336 | end | 389 | end |
| 337 | end | 390 | end |
| 338 | 391 | ||
| @@ -344,17 +397,22 @@ end | |||
| 344 | 397 | ||
| 345 | errored_rooms = mentioned_rooms - configured_rooms | 398 | errored_rooms = mentioned_rooms - configured_rooms |
| 346 | unless errored_rooms.empty? then | 399 | unless errored_rooms.empty? then |
| 347 | puts "The folloring rooms are mentioned but do not exist: " + errored_rooms.to_s | 400 | puts "The following rooms are mentioned but do not exist: " + errored_rooms.to_s |
| 348 | end | 401 | end |
| 349 | 402 | ||
| 350 | errored_panels = mentioned_panels - configured_panels | 403 | errored_panels = mentioned_panels - configured_panels |
| 351 | unless errored_panels.empty? then | 404 | unless errored_panels.empty? then |
| 352 | puts "The folloring panels are mentioned but do not exist: " + errored_panels.to_s | 405 | puts "The following panels are mentioned but do not exist: " + errored_panels.to_s |
| 353 | end | 406 | end |
| 354 | 407 | ||
| 355 | errored_doors = mentioned_doors - configured_doors | 408 | errored_doors = mentioned_doors - configured_doors |
| 356 | unless errored_doors.empty? then | 409 | unless errored_doors.empty? then |
| 357 | puts "The folloring doors are mentioned but do not exist: " + errored_doors.to_s | 410 | puts "The following doors are mentioned but do not exist: " + errored_doors.to_s |
| 411 | end | ||
| 412 | |||
| 413 | errored_panel_doors = mentioned_panel_doors - configured_panel_doors | ||
| 414 | unless errored_panel_doors.empty? then | ||
| 415 | puts "The following panel doors are mentioned but do not exist: " + errored_panel_doors.to_s | ||
| 358 | end | 416 | end |
| 359 | 417 | ||
| 360 | door_groups.each do |group,num| | 418 | door_groups.each do |group,num| |
| @@ -367,6 +425,16 @@ door_groups.each do |group,num| | |||
| 367 | end | 425 | end |
| 368 | end | 426 | end |
| 369 | 427 | ||
| 428 | panel_groups.each do |group,num| | ||
| 429 | if num == 1 then | ||
| 430 | puts "Panel group \"#{group}\" only has one panel in it" | ||
| 431 | end | ||
| 432 | |||
| 433 | unless ids.include?("panel_groups") and ids["panel_groups"].include?(group) | ||
| 434 | puts "#{group} :::: Panel group is missing an item ID" | ||
| 435 | end | ||
| 436 | end | ||
| 437 | |||
| 370 | slashed_rooms = configured_rooms.select do |room| | 438 | slashed_rooms = configured_rooms.select do |room| |
| 371 | room.include? "/" | 439 | room.include? "/" |
| 372 | end | 440 | end |
