author | unc0rr |
Mon, 02 Feb 2015 23:12:56 +0300 | |
branch | qmlfrontend |
changeset 10757 | f71275973737 |
parent 10611 | 58cad46782ff |
permissions | -rw-r--r-- |
10548
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
1 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
2 |
local ta_pointsize = 63 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
3 |
local ta_radius = (ta_pointsize * 10 + 6) / 2 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
4 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
5 |
local sqrttwo = math.sqrt(2) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
6 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
7 |
-- creates round test area |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
8 |
function AddTestArea(testarea) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
9 |
step = 100 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
10 |
xstep = step * testarea["xdir"] |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
11 |
ystep = step * testarea["ydir"] |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
12 |
x = testarea["x"] |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
13 |
y = testarea["y"] |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
14 |
if xstep * ystep ~= 0 then |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
15 |
xstep = math.floor(xstep / sqrttwo) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
16 |
ystep = math.floor(ystep / sqrttwo) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
17 |
end |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
18 |
AddPoint(x, y, ta_pointsize); |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
19 |
AddPoint(x + xstep, y + ystep, ta_pointsize, true); |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
20 |
end |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
21 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
22 |
-- vertical test area |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
23 |
local taa_v2 = {x= 350, y=1500, xdir= 0, ydir=-1} |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
24 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
25 |
-- fail counter |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
26 |
local nfailed = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
27 |
local nspawned = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
28 |
local ndied = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
29 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
30 |
function onGameInit() |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
31 |
-- At first we have to overwrite/set some global variables |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
32 |
-- that define the map, the game has to load, as well as |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
33 |
-- other things such as the game rules to use, etc. |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
34 |
-- Things we don't modify here will use their default values. |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
35 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
36 |
-- The base number for the random number generator |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
37 |
Seed = 1 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
38 |
-- The map to be played |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
39 |
MapGen = mgDrawn |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
40 |
-- The theme to be used |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
41 |
Theme = "Bamboo" |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
42 |
-- Game settings and rules |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
43 |
EnableGameFlags(gfOneClanMode, gfDisableWind, gfDisableLandObjects, gfDisableGirders, gfSolidLand) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
44 |
CaseFreq = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
45 |
MinesNum = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
46 |
Explosives = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
47 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
48 |
-- No damage please |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
49 |
DamagePercent = 1 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
50 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
51 |
-- Draw Map |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
52 |
AddPoint(10,30,0) -- hog spawn platform |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
53 |
-- test areas |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
54 |
AddTestArea(taa_v2) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
55 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
56 |
FlushPoints() |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
57 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
58 |
-- Create the player team |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
59 |
AddTeam("'Zooka Team", 14483456, "Simple", "Island", "Default") |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
60 |
-- And add a hog to it |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
61 |
player = AddHog("Hunter", 0, 1, "NoHat") |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
62 |
-- place it on how spawn platform |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
63 |
SetGearPosition(player, 10, 10) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
64 |
end |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
65 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
66 |
local pass = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
67 |
local nMines = 0 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
68 |
local maxMines = 2000 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
69 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
70 |
function onGameStart() |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
71 |
local maxPass = maxMines / 25 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
72 |
for pass = 1, maxPass, 1 do |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
73 |
pass = pass + 1 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
74 |
-- spawn 25 mines |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
75 |
for i = 0, 480, 20 do |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
76 |
AddGear(110 + i, 1000 - i - (pass * 30), gtMine, 0, 0, 0, 0) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
77 |
nMines = nMines + 1 |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
78 |
end |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
79 |
end |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
80 |
end |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
81 |
|
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
82 |
function onNewTurn() |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
83 |
WriteLnToConsole('Engine succeessfully dealt with ' .. nMines .. ' mines!') |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
84 |
EndLuaTest(TEST_SUCCESSFUL) |
28584bcb73a2
test case that spawns 2000 mines in a pit. run with ctest -R mines # only works if cmake was ran after pulling this commit
sheepluva
parents:
diff
changeset
|
85 |
end |