2020-04-19 21:35:48 +02:00
|
|
|
local tcname = 'tests.e2.destroy'
|
2020-05-03 16:52:40 +02:00
|
|
|
local lunit = require('lunit')
|
2020-04-19 21:35:48 +02:00
|
|
|
if _VERSION >= 'Lua 5.2' then
|
|
|
|
_ENV = module(tcname, 'seeall')
|
|
|
|
else
|
2020-05-03 16:52:40 +02:00
|
|
|
module(tcname, lunit.testcase, package.seeall)
|
2020-04-19 21:35:48 +02:00
|
|
|
end
|
2015-07-03 13:04:11 +02:00
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.free_game()
|
|
|
|
eressea.settings.set("NewbieImmunity", "0")
|
|
|
|
end
|
|
|
|
|
2015-08-20 16:17:19 +02:00
|
|
|
function disabled_test_dont_move_after_destroy()
|
2015-07-03 13:04:11 +02:00
|
|
|
local r1 = region.create(0, 0, "plain")
|
|
|
|
local r2 = region.create(1, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("human", "test@example.com", "de")
|
2015-07-03 13:04:11 +02:00
|
|
|
local u = unit.create(f, r1, 1)
|
|
|
|
u.building = building.create(u.region, "castle")
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("NACH O")
|
|
|
|
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
|
|
|
|
process_orders()
|
2015-07-07 20:23:24 +02:00
|
|
|
if not u.region then
|
|
|
|
print("shit happened ", u.number)
|
|
|
|
end
|
2015-07-03 13:04:11 +02:00
|
|
|
assert_equal(r1, u.region)
|
|
|
|
assert_equal(nil, u.building)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_dont_destroy_after_attack()
|
|
|
|
local r1 = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local u = unit.create(faction.create("human", "one@example.com", "de"), r1, 10)
|
|
|
|
local u2 = unit.create(faction.create("human", "two@example.com", "de"), r1, 1)
|
2015-07-03 13:04:11 +02:00
|
|
|
u.building = building.create(u.region, "castle")
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("ATTACKIERE " .. itoa36(u2.id))
|
|
|
|
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
|
|
|
|
process_orders()
|
|
|
|
assert_not_nil(u.building)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_destroy_is_long()
|
|
|
|
local r1 = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local u = unit.create(faction.create("human", "one@example.com", "de"), r1, 10)
|
2015-07-03 13:04:11 +02:00
|
|
|
u.building = building.create(u.region, "castle")
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
|
2020-04-18 22:34:12 +02:00
|
|
|
u:add_order("LERNE Unterhaltung")
|
2015-07-03 13:04:11 +02:00
|
|
|
process_orders()
|
|
|
|
assert_equal(0, u:get_skill("entertainment"))
|
|
|
|
assert_equal(nil, u.building)
|
|
|
|
end
|