diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-03 18:32:57 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-03 18:32:57 +0100 |
commit | 01f2ad3d1aeec6264015ffdf7965965eab94d745 (patch) | |
tree | 441fd9003256ac06ef11443a4bd990b94ddbe8c4 /crawl-ref/source/test | |
parent | 01a504999000dbb5d9e7482d1fb67794c5d7a914 (diff) | |
download | crawl-ref-01f2ad3d1aeec6264015ffdf7965965eab94d745.tar.gz crawl-ref-01f2ad3d1aeec6264015ffdf7965965eab94d745.zip |
Add a second bounce test.
This one chooses random targets and uses rays returned by find_ray.
That should give a few different angles.
Diffstat (limited to 'crawl-ref/source/test')
-rw-r--r-- | crawl-ref/source/test/bounce2.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/crawl-ref/source/test/bounce2.lua b/crawl-ref/source/test/bounce2.lua new file mode 100644 index 0000000000..b60ae3ccb2 --- /dev/null +++ b/crawl-ref/source/test/bounce2.lua @@ -0,0 +1,46 @@ +-- Check bouncing of lightning bolts around in a box with ragged +-- edges. If there's anything wrong the C/C++ code will assert. + +local checks = 0 +local iters = 10 +local beams = 10 + +local function test_bounce_iter(map) + dgn.reset_level() + -- local width, height = dgn.mapsize(map) -- returns (0,0) + local function place_map() + return dgn.place_map(map, true, true, 30, 30) + end + dgn.with_map_anchors(30, 30, place_map) + + if dgn.grid(31, 31) ~= dgn.find_feature_number("floor") then + assert(false, "Map not placed properly") + end + + -- Move player out of the way + you.moveto(2, 2) + + -- Fire beams to random targets, using a ray as returned by + -- find_ray if available. + for i = 1, beams do + local dx = crawl.random2(9) + local dy = crawl.random2(9) + debug.bouncy_beam(30, 30, 30+dx, 30+dy, 1000, true) + end +end + +local function test_bounces() + debug.flush_map_memory() + dgn.load_des_file("test/des/bounce.des") + local map = dgn.map_by_tag("bounce_test") + assert(map, "Could not find bounce_test map (tag 'bounce_test')") + -- The ragedness of the map edge is randomized on placement, + -- so place the same map multiple times. + for i = 1, iters do + test_bounce_iter(map) + end + + checks = 1 +end + +test_bounces() |