summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/test/bounce.lua
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-03 02:54:13 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-03 02:54:13 -0800
commit96aa6d3c847192863507a282e38664cca693af07 (patch)
tree9ebb0668076bc260493f284bcc88b54e994f0acd /crawl-ref/source/test/bounce.lua
parent972b9190917be720fd5510f951f25e8f13d0fefd (diff)
downloadcrawl-ref-96aa6d3c847192863507a282e38664cca693af07.tar.gz
crawl-ref-96aa6d3c847192863507a282e38664cca693af07.zip
Unit test for beams bouncing
Diffstat (limited to 'crawl-ref/source/test/bounce.lua')
-rw-r--r--crawl-ref/source/test/bounce.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/crawl-ref/source/test/bounce.lua b/crawl-ref/source/test/bounce.lua
new file mode 100644
index 0000000000..357f2072e3
--- /dev/null
+++ b/crawl-ref/source/test/bounce.lua
@@ -0,0 +1,47 @@
+-- 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 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 slightly off of compass directions, to get the
+ -- beam to bounce all over the place.
+ debug.bouncy_beam(30, 30, 30 - 8, 30 - 7, 1000)
+ debug.bouncy_beam(30, 30, 30 - 1, 30 - 8, 1000)
+ debug.bouncy_beam(30, 30, 30 + 8, 30 - 7, 1000)
+ debug.bouncy_beam(30, 30, 30 + 1, 30 - 8, 1000)
+ debug.bouncy_beam(30, 30, 30 - 8, 30 + 7, 1000)
+ debug.bouncy_beam(30, 30, 30 - 1, 30 + 8, 1000)
+ debug.bouncy_beam(30, 30, 30 + 8, 30 + 7, 1000)
+ debug.bouncy_beam(30, 30, 30 + 1, 30 + 8, 1000)
+end
+
+local function test_bounces()
+ 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()