2020-04-19 21:35:48 +02:00
|
|
|
local tcname = 'tests.e2.insects'
|
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
|
2017-12-15 17:16:00 +01:00
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.free_game()
|
|
|
|
eressea.settings.set("rules.food.flags", "4")
|
|
|
|
eressea.settings.set("nmr.timeout", "0")
|
|
|
|
eressea.settings.set("NewbieImmunity", "0")
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_move_to_glacier()
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local r2 = region.create(1, 0, "glacier")
|
2017-12-17 14:50:11 +01:00
|
|
|
local f = faction.create("insect")
|
2017-12-15 17:16:00 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("NACH OST")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(r, u.region)
|
2017-12-17 14:50:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_sail_to_glacier()
|
|
|
|
local r = region.create(0, 0, "ocean")
|
|
|
|
local r2 = region.create(1, 0, "glacier")
|
|
|
|
local f = faction.create("insect")
|
|
|
|
local u1 = unit.create(f, r, 1, 'insect')
|
|
|
|
|
|
|
|
u1.ship = ship.create(r, 'boat')
|
|
|
|
u1:set_skill("sailing", 10)
|
|
|
|
u1:clear_orders()
|
|
|
|
u1:add_order("NACH OST")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(r, u1.region)
|
2017-12-15 17:16:00 +01:00
|
|
|
end
|
|
|
|
|
2017-12-17 14:50:11 +01:00
|
|
|
function test_passenger_into_glacier()
|
2017-12-15 17:16:00 +01:00
|
|
|
local r = region.create(0, 0, "ocean")
|
|
|
|
local r2 = region.create(1, 0, "glacier")
|
2017-12-17 14:50:11 +01:00
|
|
|
local f = faction.create("insect")
|
2017-12-15 17:16:00 +01:00
|
|
|
local u1 = unit.create(f, r, 1, 'human')
|
|
|
|
local u2 = unit.create(f, r, 1, 'insect')
|
|
|
|
|
|
|
|
u1.ship = ship.create(r, 'boat')
|
|
|
|
u1:set_skill("sailing", 10)
|
|
|
|
u1:clear_orders()
|
|
|
|
u1:add_order("NACH OST")
|
|
|
|
u2.ship = u1.ship
|
|
|
|
process_orders()
|
2017-12-17 14:28:15 +01:00
|
|
|
assert_equal(r2, u2.region)
|
2017-12-15 17:16:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_recruit_in_winter()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-12-17 14:50:11 +01:00
|
|
|
local f = faction.create("insect")
|
2017-12-15 17:16:00 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
|
|
|
|
u:add_item('money', 1000)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("REKRUTIERE 1")
|
|
|
|
set_turn(1010)
|
|
|
|
process_orders()
|
|
|
|
assert_equal('winter', get_season(get_turn()))
|
|
|
|
assert_equal(1, u.number)
|
|
|
|
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("REKRUTIERE 1")
|
|
|
|
set_turn(1011)
|
|
|
|
process_orders()
|
|
|
|
assert_equal('spring', get_season(get_turn()))
|
|
|
|
assert_equal(2, u.number)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_recruit_in_desert()
|
|
|
|
local r = region.create(0, 0, "desert")
|
2017-12-17 14:50:11 +01:00
|
|
|
local f = faction.create("insect")
|
2017-12-15 17:16:00 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
|
|
|
|
u:add_item('money', 1000)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("REKRUTIERE 1")
|
|
|
|
set_turn(1010)
|
|
|
|
process_orders()
|
|
|
|
assert_equal('winter', get_season(get_turn()))
|
|
|
|
assert_equal(2, u.number)
|
|
|
|
end
|
2019-09-22 14:06:04 +02:00
|
|
|
|
|
|
|
function test_ride_through_mountain()
|
|
|
|
local r1 = region.create(1, 0, "plain")
|
|
|
|
local r2 = region.create(2, 0, "mountain")
|
|
|
|
local r3 = region.create(3, 0, "plain")
|
|
|
|
local f = faction.create("insect")
|
|
|
|
local u = unit.create(f, r1, 1)
|
|
|
|
u.name="Hercules"
|
|
|
|
u:add_order('NACH O O')
|
|
|
|
u:add_item('horse', 1)
|
|
|
|
u:set_skill('riding', 1, true)
|
|
|
|
process_orders()
|
|
|
|
assert_equal(r3, u.region)
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_ride_from_mountain()
|
|
|
|
local r1 = region.create(1, 0, "mountain")
|
|
|
|
local r2 = region.create(2, 0, "plain")
|
|
|
|
local r3 = region.create(3, 0, "plain")
|
|
|
|
local f = faction.create("insect")
|
|
|
|
local u = unit.create(f, r1, 1)
|
|
|
|
u:add_order('NACH O O')
|
|
|
|
u:add_item('horse', 1)
|
|
|
|
u:set_skill('riding', 1, true)
|
|
|
|
process_orders()
|
|
|
|
assert_equal(r2, u.region)
|
|
|
|
end
|