2020-04-19 21:35:48 +02:00
|
|
|
local tcname = 'tests.shared.magicbag'
|
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-01 22:13:24 +02:00
|
|
|
|
|
|
|
local u
|
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.free_game()
|
2017-03-17 22:31:59 +01:00
|
|
|
u = unit.create(faction.create("human", "test@example.com", "de"), region.create(0, 0, "plain"), 1)
|
2015-07-01 22:13:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_magicbag_weight()
|
|
|
|
assert_equal(1000, u.weight)
|
|
|
|
u:add_item("log", 10)
|
|
|
|
assert_equal(6000, u.weight)
|
|
|
|
u:add_item("magicbag", 1)
|
|
|
|
assert_equal(1100, u.weight)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_magicbag_no_stone()
|
|
|
|
assert_equal(1000, u.weight)
|
|
|
|
u:add_item("stone", 1)
|
|
|
|
assert_equal(7000, u.weight)
|
|
|
|
u:add_item("magicbag", 1)
|
|
|
|
assert_equal(7100, u.weight)
|
|
|
|
end
|
|
|
|
|
2015-07-01 22:16:43 +02:00
|
|
|
function test_magicbag_limit_200ge()
|
|
|
|
assert_equal(1000, u.weight)
|
|
|
|
u:add_item("log", 100)
|
|
|
|
assert_equal(51000, u.weight)
|
|
|
|
u:add_item("magicbag", 1)
|
|
|
|
assert_equal(31100, u.weight)
|
|
|
|
end
|
|
|
|
|
2015-07-01 22:13:24 +02:00
|
|
|
function test_magicbag_no_carts()
|
|
|
|
assert_equal(1000, u.weight)
|
|
|
|
u:add_item("cart", 1)
|
|
|
|
assert_equal(5000, u.weight)
|
|
|
|
u:add_item("magicbag", 1)
|
|
|
|
assert_equal(5100, u.weight)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_magicbag_no_catapult()
|
|
|
|
assert_equal(1000, u.weight)
|
|
|
|
u:add_item("catapult", 1)
|
|
|
|
assert_equal(11000, u.weight)
|
|
|
|
u:add_item("magicbag", 1)
|
|
|
|
assert_equal(11100, u.weight)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_magicbag_no_horses()
|
|
|
|
assert_equal(1000, u.weight)
|
|
|
|
u:add_item("horse", 1)
|
|
|
|
assert_equal(6000, u.weight)
|
|
|
|
u:add_item("magicbag", 1)
|
|
|
|
assert_equal(6100, u.weight)
|
|
|
|
end
|