2014-06-21 18:17:10 +02:00
|
|
|
require "lunit"
|
|
|
|
|
|
|
|
module("tests.eressea.study", package.seeall, lunit.testcase)
|
|
|
|
|
|
|
|
function setup()
|
|
|
|
conf = [[{
|
|
|
|
"races" : { "human" : {} },
|
|
|
|
"terrains" : { "plain" : { "flags" : [ "land" ] } },
|
|
|
|
"keywords" : { "de" : { "study": "LERNEN" } },
|
|
|
|
"skills" : { "de": { "alchemy" : "Alchemie", "crossbow" : "Armbrust" } }
|
|
|
|
}]]
|
|
|
|
eressea.game.reset()
|
|
|
|
eressea.config.reset();
|
|
|
|
eressea.config.parse(conf)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_study()
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local f = faction.create("test@example.com", "human", "de")
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:add_order("LERNEN Armbrust")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(1, u:get_skill("crossbow"))
|
|
|
|
end
|
|
|
|
|
2014-06-22 16:55:14 +02:00
|
|
|
function test_study_expensive()
|
2014-06-21 18:17:10 +02:00
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local f = faction.create("test@example.com", "human", "de")
|
|
|
|
local u = unit.create(f, r, 1)
|
2014-06-22 16:55:14 +02:00
|
|
|
eressea.settings.set("skills.cost.alchemy", "50")
|
|
|
|
eressea.settings.set("rules.encounters", "0")
|
2014-06-21 18:17:10 +02:00
|
|
|
u:add_order("LERNEN Alchemie")
|
2014-06-22 16:55:14 +02:00
|
|
|
u:add_item("money", 50)
|
2014-06-21 18:17:10 +02:00
|
|
|
process_orders()
|
|
|
|
assert_equal(1, u:get_skill("alchemy"))
|
2014-06-22 16:55:14 +02:00
|
|
|
assert_equal(0, u:get_item("money"))
|
2014-06-21 18:17:10 +02:00
|
|
|
end
|