2020-04-19 21:35:48 +02:00
|
|
|
local tcname = 'tests.shared.config'
|
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
|
2014-06-13 02:41:03 +02:00
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.free_game()
|
|
|
|
end
|
|
|
|
|
2014-06-13 17:04:06 +02:00
|
|
|
function test_read_race()
|
2014-06-13 02:41:03 +02:00
|
|
|
local f
|
|
|
|
assert_not_nil(eressea.config)
|
|
|
|
eressea.config.parse('{ "races": { "orc" : {}}}')
|
2017-03-17 22:31:59 +01:00
|
|
|
f = faction.create("orc", "orc@example.com", "en")
|
2014-06-13 02:41:03 +02:00
|
|
|
assert_not_nil(f)
|
|
|
|
end
|
|
|
|
|
2018-07-12 20:24:23 +02:00
|
|
|
function test_first_insect()
|
|
|
|
local f = faction.create('insect')
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:equip('first_unit')
|
|
|
|
assert_equal(9, u:get_item('nestwarmth'))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_first_troll()
|
|
|
|
local f = faction.create('troll')
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:equip('first_unit')
|
|
|
|
assert_equal(2, u:eff_skill('perception'))
|
|
|
|
end
|
|
|
|
|
2018-07-30 22:19:40 +02:00
|
|
|
function test_first_human()
|
|
|
|
local f = faction.create('human')
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:equip('first_unit')
|
|
|
|
assert_not_nil(u.building)
|
|
|
|
assert_equal('castle', u.building.type)
|
|
|
|
assert_equal(10, u.building.size)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_first_aquarian()
|
|
|
|
local f = faction.create('aquarian')
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:equip('first_unit')
|
|
|
|
assert_not_nil(u.ship)
|
|
|
|
assert_equal('boat', u.ship.type)
|
|
|
|
assert_equal(1, u:get_skill('sailing'))
|
|
|
|
end
|
|
|
|
|
2018-05-12 19:10:40 +02:00
|
|
|
function test_seed_unit()
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local f = faction.create('human')
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:equip('seed_unit')
|
|
|
|
assert_equal(20000, u:get_item('money'))
|
|
|
|
assert_equal(50, u:get_item('log'))
|
|
|
|
assert_equal(50, u:get_item('stone'))
|
|
|
|
assert_equal(1, u:get_skill('melee'))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_seed_elf()
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local f = faction.create('human')
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
-- quirk: independent of the race, seed_elf contains a fairyboot
|
|
|
|
u:equip('seed_elf')
|
|
|
|
assert_equal(1, u:get_item('fairyboot'))
|
|
|
|
-- all humans start in a building:
|
|
|
|
assert_not_nil(u.building)
|
|
|
|
assert_equal('castle', u.building.type)
|
|
|
|
assert_equal(10, u.building.size)
|
2014-06-13 17:04:06 +02:00
|
|
|
end
|
2018-07-30 22:19:40 +02:00
|
|
|
|