Apply the new ground_level method.
[crawl.git] / crawl-ref / source / test / vault_generation.lua
blobb8892fd4ce9f164abc9040704c27e1c107c92f32
1 -- Check specific map generation, useful for testing portal vault
2 -- generation (SUBSTs, NSBUSTs, SHUFFLEs, etc).
4 -- Name of the map!
5 local map_to_test = ""
6 -- Which des file is the map in?
7 local des_file = ""
8 -- Change to true if the des file isn't specificed in dat/clua/loadmaps.lua
9 local need_to_load_des = false
10 -- How many times should we generate?
11 local checks = 10
12 -- Output to this file, will append iteration to the end, ie,
13 -- output_to.map.1, output_to.map.2, etc.
14 local output_to = ""
16 -- Should we run these tests?
17 local run_test = map_to_test ~= ""
19 local function generate_map()
20 output_to = output_to == "" and map_to_test or output_to
21 if map_to_test == "" or
22 (des_file == "" and need_to_load_des) or
23 output_to == "" then
24 assert(false, "Need a map, a des file (if not already loaded), and an output.")
25 end
27 if need_to_load_des then
28 dgn.load_des_file(des_file)
29 end
31 local map = dgn.map_by_name(map_to_test)
33 if not map then
34 assert(false, "Couldn't find the map named " .. map_to_test)
35 end
37 for iter_i = 1, checks do
38 debug.flush_map_memory()
39 dgn.reset_level()
40 dgn.tags(map, "no_rotate no_vmirror no_hmirror no_pool_fixup")
41 dgn.place_map(map, true, true)
42 crawl.message("Placed " .. map_to_test .. ":" .. iter_i .. ", dumping to " .. output_to .. "." .. iter_i)
43 debug.dump_map(output_to .. "." .. iter_i)
44 end
45 end
47 if run_test then
48 generate_map()
49 else
50 crawl.message("Not running vault generation test.")
51 end