2014-07-06 03:21:20 +02:00
|
|
|
require "lunit"
|
|
|
|
|
|
|
|
module("tests.eressea.pool", package.seeall, lunit.testcase )
|
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.free_game()
|
|
|
|
eressea.config.reset();
|
|
|
|
eressea.settings.set("rules.economy.food", "0")
|
|
|
|
eressea.settings.set("nmr.removenewbie", "0")
|
|
|
|
eressea.settings.set("nmr.timeout", "0")
|
|
|
|
conf = [[{
|
|
|
|
"races": {
|
2014-07-06 10:13:09 +02:00
|
|
|
"human" : { "flags" : [ "giveitem", "getitem" ] }
|
2014-07-06 03:21:20 +02:00
|
|
|
},
|
|
|
|
"terrains" : {
|
|
|
|
"plain": { "flags" : [ "land" ] }
|
|
|
|
},
|
|
|
|
"keywords" : {
|
|
|
|
"de" : {
|
|
|
|
"give" : "GIB"
|
|
|
|
}
|
2014-07-06 10:13:09 +02:00
|
|
|
},
|
|
|
|
"strings" : {
|
|
|
|
"de" : {
|
|
|
|
"money" : "Silber"
|
|
|
|
}
|
2014-07-06 03:21:20 +02:00
|
|
|
}
|
|
|
|
}]]
|
|
|
|
|
|
|
|
assert(eressea.config.parse(conf)==0)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_give_nopool()
|
|
|
|
local r = region.create(1, 1, "plain")
|
|
|
|
local f = faction.create("test@example.com", "human", "de")
|
|
|
|
local u1 = unit.create(f, r, 1)
|
|
|
|
local u2 = unit.create(f, r, 1)
|
|
|
|
u1:add_item("money", 100)
|
2014-07-06 10:13:09 +02:00
|
|
|
u1:add_order("GIB " .. itoa36(u2.id) .. " 50 SILBER")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(50, u1:get_item("money"))
|
|
|
|
assert_equal(50, u2:get_item("money"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_give_from_faction()
|
|
|
|
local r = region.create(1, 1, "plain")
|
|
|
|
local f = faction.create("test@example.com", "human", "de")
|
|
|
|
local u1 = unit.create(f, r, 1)
|
|
|
|
local u2 = unit.create(f, r, 1)
|
|
|
|
local u3 = unit.create(f, r, 1)
|
|
|
|
u1:add_item("money", 50)
|
|
|
|
u2:add_item("money", 50)
|
|
|
|
u1:add_order("GIB " .. itoa36(u3.id) .. " 100 SILBER")
|
2014-07-06 03:21:20 +02:00
|
|
|
process_orders()
|
|
|
|
assert_equal(0, u1:get_item("money"))
|
2014-07-06 10:13:09 +02:00
|
|
|
assert_equal(0, u2:get_item("money"))
|
|
|
|
assert_equal(100, u3:get_item("money"))
|
2014-07-06 03:21:20 +02:00
|
|
|
end
|