2015-07-02 08:55:05 +02:00
|
|
|
require "lunit"
|
|
|
|
|
|
|
|
module("tests.e2.undead", package.seeall, lunit.testcase)
|
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.free_game()
|
|
|
|
end
|
|
|
|
|
2018-11-03 18:25:22 +01:00
|
|
|
function test_undead_reserve_self()
|
|
|
|
local r1 = region.create(0, 0, "plain")
|
|
|
|
local f1 = faction.create("human")
|
|
|
|
local u1 = unit.create(f1, r1, 1)
|
|
|
|
u1.race = "undead"
|
|
|
|
u1:clear_orders()
|
|
|
|
u1:add_item("log", 2)
|
|
|
|
u1:add_order("RESERVIERE 1 Holz")
|
|
|
|
u1:add_order("GIB 0 ALLES Holz")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(1, u1:get_item("log"))
|
|
|
|
end
|
|
|
|
|
2018-12-09 14:41:14 +01:00
|
|
|
function test_undead_reserve_other()
|
2018-11-03 18:25:22 +01:00
|
|
|
local r1 = region.create(0, 0, "plain")
|
|
|
|
local f1 = faction.create("human")
|
|
|
|
local u1 = unit.create(f1, r1, 1)
|
|
|
|
local u2 = unit.create(f1, r1, 1)
|
|
|
|
u2:add_item("log", 2)
|
|
|
|
u1.race = "undead"
|
|
|
|
u1:clear_orders()
|
|
|
|
u1:add_order("RESERVIERE 1 Holz")
|
2018-12-09 14:41:14 +01:00
|
|
|
u1.name = 'Xolgrim'
|
2018-11-03 18:25:22 +01:00
|
|
|
process_orders()
|
2019-03-02 21:12:15 +01:00
|
|
|
|
2019-03-24 18:05:40 +01:00
|
|
|
if 0 ~= u1:get_item("log") then
|
|
|
|
-- try to catch that intermittent bug:
|
|
|
|
print(u1:show())
|
|
|
|
end
|
|
|
|
assert_equal(0, u1:get_item("log"))
|
|
|
|
if 2 ~= u2:get_item("log") then
|
|
|
|
-- try to catch that intermittent bug:
|
|
|
|
print(u2:show())
|
|
|
|
end
|
2018-11-03 18:25:22 +01:00
|
|
|
assert_equal(2, u2:get_item("log"))
|
|
|
|
end
|
|
|
|
|
2015-07-02 08:55:05 +02:00
|
|
|
function test_undead_give_item()
|
|
|
|
local r1 = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f1 = faction.create("human", "hodor@eressea.de", "de")
|
2015-07-02 08:55:05 +02:00
|
|
|
local u1 = unit.create(f1, r1, 1)
|
|
|
|
u1.race = "undead"
|
|
|
|
u1:clear_orders()
|
|
|
|
u1:add_item("log", 1)
|
|
|
|
u1:add_order("GIB 0 1 Holz")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(0, u1:get_item("log"))
|
|
|
|
end
|
|
|
|
|
2017-07-22 12:36:01 +02:00
|
|
|
function test_clones_dont_give_person()
|
2015-07-02 08:55:05 +02:00
|
|
|
local r1 = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f1 = faction.create("human", "hodor@eressea.de", "de")
|
2015-07-02 08:55:05 +02:00
|
|
|
local u1 = unit.create(f1, r1, 2)
|
2017-07-22 12:36:01 +02:00
|
|
|
u1.race = "clone"
|
2015-07-02 08:55:05 +02:00
|
|
|
u1:clear_orders()
|
|
|
|
u1:add_item("log", 1)
|
|
|
|
u1:add_order("GIB 0 1 Person")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(2, u1.number)
|
|
|
|
end
|
2019-02-16 20:14:34 +01:00
|
|
|
|
|
|
|
-- bug 2504
|
|
|
|
function test_skeleton_cannot_learn()
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local f = faction.create("elf")
|
|
|
|
local u = unit.create(f, r, 2)
|
|
|
|
u.race = "skeleton"
|
|
|
|
u:add_order("LERNE Wahrnehmung")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(0, u:get_skill('perception'))
|
|
|
|
end
|