2017-02-27 18:50:48 +01:00
|
|
|
require "lunit"
|
|
|
|
|
2017-02-27 19:35:14 +01:00
|
|
|
module("tests.e2.items", package.seeall, lunit.testcase )
|
2017-02-27 18:50:48 +01:00
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.free_game()
|
|
|
|
eressea.settings.set("nmr.timeout", "0")
|
|
|
|
eressea.settings.set("rules.food.flags", "4")
|
|
|
|
eressea.settings.set("rules.ship.storms", "0")
|
|
|
|
eressea.settings.set("magic.regeneration.enable", "0")
|
2018-05-06 15:49:34 +02:00
|
|
|
eressea.settings.set("rules.grow.formula", "0")
|
2018-02-24 18:58:50 +01:00
|
|
|
eressea.settings.set("study.random_progress", "0")
|
2017-02-27 18:50:48 +01:00
|
|
|
end
|
|
|
|
|
2017-12-26 13:23:14 +01:00
|
|
|
function test_water_of_life()
|
2018-05-01 19:05:04 +02:00
|
|
|
eressea.settings.set("rules.grow.formula", 0) -- no tree growth
|
2017-12-26 13:23:14 +01:00
|
|
|
local r = region.create(0, 0, "plain")
|
2017-12-26 15:57:59 +01:00
|
|
|
r:set_flag(1, false) -- no mallorn
|
2017-12-26 13:23:14 +01:00
|
|
|
local f = faction.create("human")
|
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
local trees = r:get_resource('sapling')
|
|
|
|
u:add_item('p2', 1)
|
|
|
|
u:add_item('log', 10)
|
|
|
|
u:add_order("BENUTZE 1 'Wasser des Lebens'")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(0, u:get_item('p2'))
|
|
|
|
assert_equal(0, u:get_item('log'))
|
|
|
|
assert_equal(trees+10, r:get_resource('sapling'))
|
|
|
|
end
|
|
|
|
|
2017-02-27 20:26:48 +01:00
|
|
|
function test_nestwarmth_insect()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("insect")
|
2017-02-27 20:26:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
local flags = u.flags
|
|
|
|
u:add_item("nestwarmth", 2)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Nestwaerme")
|
|
|
|
turn_begin()
|
|
|
|
turn_process()
|
|
|
|
assert_equal(flags+64, u.flags) -- UFL_WARMTH
|
|
|
|
assert_equal(1, u:get_item("nestwarmth"))
|
2018-02-17 15:30:38 +01:00
|
|
|
assert_equal(1, f:count_msg_type('use_item'))
|
2017-02-27 20:26:48 +01:00
|
|
|
turn_end()
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_nestwarmth_other()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("human")
|
2017-02-27 20:26:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
local flags = u.flags
|
|
|
|
u:add_item("nestwarmth", 2)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Nestwaerme")
|
|
|
|
turn_begin()
|
|
|
|
turn_process()
|
|
|
|
assert_equal(flags, u.flags) -- nothing happens
|
|
|
|
assert_equal(2, u:get_item("nestwarmth"))
|
|
|
|
assert_equal(1, f:count_msg_type('error163'))
|
|
|
|
turn_end()
|
|
|
|
end
|
|
|
|
|
2017-02-27 18:50:48 +01:00
|
|
|
function test_meow()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("human")
|
2017-02-27 18:50:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:add_item("aoc", 1)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Katzenamulett")
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_begin()
|
|
|
|
turn_process()
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(1, u:get_item("aoc"))
|
|
|
|
assert_equal(1, r:count_msg_type('meow'))
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_end()
|
2017-02-27 18:50:48 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_aurapotion50()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("human")
|
2017-02-27 18:50:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:add_item("aurapotion50", 1)
|
|
|
|
u:set_skill('magic', 10);
|
|
|
|
u.magic = 'gwyrrd'
|
|
|
|
u.aura = 0
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Auratrank")
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_begin()
|
|
|
|
turn_process()
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(0, u:get_item("aurapotion50"))
|
2018-05-17 19:03:49 +02:00
|
|
|
assert_equal(1, f:count_msg_type('aurapotion50_effect'))
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(50, u.aura)
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_end()
|
2017-02-27 18:50:48 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_bagpipe()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("human")
|
2017-02-27 18:50:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
2017-02-27 20:16:50 +01:00
|
|
|
turn_begin()
|
2017-02-27 18:50:48 +01:00
|
|
|
u:add_item("bagpipeoffear", 1)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Dudelsack")
|
2017-02-27 20:16:50 +01:00
|
|
|
assert_equal(nil, r:get_curse('depression'))
|
|
|
|
turn_process()
|
|
|
|
assert_equal(0, r:get_curse('depression'))
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(1, u:get_item("bagpipeoffear"))
|
|
|
|
assert_equal(1, f:count_msg_type('bagpipeoffear_faction'))
|
|
|
|
assert_equal(1, r:count_msg_type('bagpipeoffear_region'))
|
2017-02-27 20:16:50 +01:00
|
|
|
turn_end()
|
|
|
|
-- duration is variable, but at least 4
|
|
|
|
assert_equal(0, r:get_curse('depression'))
|
2017-02-27 18:50:48 +01:00
|
|
|
end
|
|
|
|
|
2018-02-15 20:25:58 +01:00
|
|
|
function test_monthly_healing()
|
|
|
|
local r = region.create(0, 0, "plain")
|
|
|
|
local f = faction.create("human")
|
|
|
|
local u = unit.create(f, r, 30)
|
|
|
|
assert_equal(600, u.hp)
|
|
|
|
u.hp = 100
|
|
|
|
process_orders()
|
|
|
|
assert_equal(130, u.hp)
|
|
|
|
end
|
|
|
|
|
2017-02-27 18:50:48 +01:00
|
|
|
function test_speedsail()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("human")
|
2017-02-27 18:50:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
2017-02-27 20:16:50 +01:00
|
|
|
|
|
|
|
turn_begin()
|
2017-02-27 18:50:48 +01:00
|
|
|
u.ship = ship.create(r, "boat")
|
|
|
|
u:add_item("speedsail", 2)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Sonnensegel")
|
2017-02-27 20:16:50 +01:00
|
|
|
assert_equal(nil, u.ship:get_curse('shipspeed'))
|
|
|
|
turn_process()
|
|
|
|
assert_equal(1, u.ship:get_curse('shipspeed'))
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(1, u:get_item("speedsail"))
|
|
|
|
assert_equal(1, f:count_msg_type('use_speedsail'))
|
2017-02-27 20:16:50 +01:00
|
|
|
turn_end()
|
|
|
|
assert_equal(1, u.ship:get_curse('shipspeed')) -- effect stays forever
|
2017-02-27 18:50:48 +01:00
|
|
|
end
|
|
|
|
|
2018-02-17 15:22:44 +01:00
|
|
|
function test_use_foolpotion()
|
2017-02-27 18:50:48 +01:00
|
|
|
local r = region.create(0, 0, "plain")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("human")
|
2017-02-27 18:50:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_begin()
|
2018-01-17 17:37:37 +01:00
|
|
|
u:add_item('p7', 2)
|
2017-02-27 18:50:48 +01:00
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242")
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_process()
|
2018-01-17 17:37:37 +01:00
|
|
|
assert_equal(2, u:get_item('p7'))
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(1, f:count_msg_type('feedback_unit_not_found'))
|
|
|
|
local u2 = unit.create(f, r, 1)
|
|
|
|
|
|
|
|
u:clear_orders()
|
2018-01-17 17:37:37 +01:00
|
|
|
u:add_order("BENUTZEN 2 Dumpfbackenbrot " .. itoa36(u2.id))
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_process()
|
2018-01-17 17:37:37 +01:00
|
|
|
assert_equal(2, u:get_item('p7'))
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(1, f:count_msg_type('error64'))
|
|
|
|
|
2018-01-17 17:37:37 +01:00
|
|
|
u:set_skill("stealth", 1)
|
|
|
|
u2:set_skill('crossbow', 1)
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_process()
|
2018-01-17 17:37:37 +01:00
|
|
|
assert_equal(0, u:get_item('p7'))
|
|
|
|
assert_equal(0, u2:effect('p7'))
|
2018-02-24 18:58:50 +01:00
|
|
|
assert_equal(0, u2:get_skill('crossbow'))
|
2017-02-27 18:50:48 +01:00
|
|
|
assert_equal(1, f:count_msg_type('givedumb'))
|
2017-02-27 19:35:14 +01:00
|
|
|
turn_end()
|
2017-02-27 18:50:48 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_snowman()
|
|
|
|
local r = region.create(0, 0, "glacier")
|
2018-02-15 20:25:58 +01:00
|
|
|
local f = faction.create("human")
|
2017-02-27 18:50:48 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:add_item("snowman", 1)
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("BENUTZEN 1 Schneemann")
|
|
|
|
process_orders()
|
|
|
|
for u2 in r.units do
|
|
|
|
if u2.id~=u.id then
|
|
|
|
assert_equal("snowman", u2.race)
|
|
|
|
assert_equal(1000, u2.hp)
|
|
|
|
u = nil
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
assert_equal(nil, u)
|
|
|
|
end
|