2020-04-22 03:03:44 +02:00
|
|
|
local tcname = 'tests.e3.parser'
|
2020-05-03 16:52:40 +02:00
|
|
|
local lunit = require('lunit')
|
2020-04-22 03:03:44 +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-22 03:03:44 +02:00
|
|
|
end
|
2015-01-04 13:20:11 +01:00
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.game.reset()
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_set_status_en()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("human", "bug_1882@eressea.de", "en")
|
2015-01-04 13:20:11 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u.status = 1
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("COMBAT AGGRESSIVE")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(u.status, 0)
|
|
|
|
u.status = 1
|
|
|
|
u:add_order("FIGHT AGGRESSIVE")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(u.status, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_set_status_de()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("human", "bug_1882@eressea.de", "de")
|
2015-01-04 13:20:11 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u.status = 1
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("KAEMPFE AGGRESSIV")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(u.status, 0)
|
|
|
|
end
|
|
|
|
|
2015-01-04 15:42:36 +01:00
|
|
|
function test_breed_horses()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("human", "bug_1886@eressea.de", "en")
|
2015-01-04 15:42:36 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
local b = building.create(r, "stables")
|
|
|
|
b.size = 10
|
|
|
|
u.building = b
|
|
|
|
u:add_item("horse", 2)
|
|
|
|
u:add_item("money", 2000)
|
|
|
|
u:set_skill("training", 100) -- 100% chance to duplicate each horse
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("GROW horses")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(4, u:get_item("horse"))
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BREED horses")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(8, u:get_item("horse"))
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("PLANT horses")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(16, u:get_item("horse"))
|
|
|
|
end
|