summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/test/uniquegen.lua
blob: 9addafd2f987f3be188a29c26ee31d994648828f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- Test that randomly generated monsters aren't uniques.

local place = dgn.point(20, 20)
local place2 = dgn.point(50, 50) -- out-of-view of place, to avoid message spam
local count = 100

local function test_place_random_monster()
  dgn.dismiss_monsters()
  dgn.grid(place.x, place.y, "floor")
  m = dgn.create_monster(place.x, place.y, "random")
  assert(not m.unique,
         "random monster is unique " .. m.name)
end

local function test_random_unique(branch, depth)
  crawl.message("Running random monster unique tests in branch " .. branch
                .. " through depth " .. depth)
  debug.flush_map_memory()
  for d = 1, depth do
    debug.goto_place(branch .. ":" .. d)
    dgn.grid(place2.x, place2.y, "floor")
    you.moveto(place2.x, place2.y)
    for i = 1, count do
      test_place_random_monster()
    end
  end
end

local function run_random_unique_tests()
  for depth = 1, 16 do
    test_random_unique("D", depth, 3)
  end

  for depth = 1, 6 do
    test_random_unique("Depths", depth, 3)
  end

  for depth = 1, 7 do
    test_random_unique("Dis", depth, 3)
  end

  for depth = 1, 5 do
    test_random_unique("Swamp", depth, 5)
  end
end

run_random_unique_tests()