Apply the new ground_level method.
[crawl.git] / crawl-ref / source / test / bounce2.lua
blobb60ae3ccb2fe9332c568b9e5fe4311352ae32140
1 -- Check bouncing of lightning bolts around in a box with ragged
2 -- edges. If there's anything wrong the C/C++ code will assert.
4 local checks = 0
5 local iters = 10
6 local beams = 10
8 local function test_bounce_iter(map)
9 dgn.reset_level()
10 -- local width, height = dgn.mapsize(map) -- returns (0,0)
11 local function place_map()
12 return dgn.place_map(map, true, true, 30, 30)
13 end
14 dgn.with_map_anchors(30, 30, place_map)
16 if dgn.grid(31, 31) ~= dgn.find_feature_number("floor") then
17 assert(false, "Map not placed properly")
18 end
20 -- Move player out of the way
21 you.moveto(2, 2)
23 -- Fire beams to random targets, using a ray as returned by
24 -- find_ray if available.
25 for i = 1, beams do
26 local dx = crawl.random2(9)
27 local dy = crawl.random2(9)
28 debug.bouncy_beam(30, 30, 30+dx, 30+dy, 1000, true)
29 end
30 end
32 local function test_bounces()
33 debug.flush_map_memory()
34 dgn.load_des_file("test/des/bounce.des")
35 local map = dgn.map_by_tag("bounce_test")
36 assert(map, "Could not find bounce_test map (tag 'bounce_test')")
37 -- The ragedness of the map edge is randomized on placement,
38 -- so place the same map multiple times.
39 for i = 1, iters do
40 test_bounce_iter(map)
41 end
43 checks = 1
44 end
46 test_bounces()