2020-04-19 21:35:48 +02:00
|
|
|
local tcname = 'tests.e2.stealth'
|
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-08-02 23:17:55 +02:00
|
|
|
|
|
|
|
local f
|
|
|
|
local u
|
|
|
|
|
2015-07-01 21:24:44 +02:00
|
|
|
local settings = {}
|
2015-01-03 16:11:33 +01:00
|
|
|
|
|
|
|
local function set_rule(key, value)
|
|
|
|
if value==nil then
|
|
|
|
eressea.settings.set(key, settings[key])
|
|
|
|
else
|
|
|
|
settings[key] = settings[key] or eressea.settings.get(key)
|
|
|
|
eressea.settings.set(key, value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-02 23:17:55 +02:00
|
|
|
function setup()
|
|
|
|
eressea.game.reset()
|
2015-09-11 10:04:08 +02:00
|
|
|
set_rule('rules.food.flags', '4')
|
2014-08-02 23:17:55 +02:00
|
|
|
|
|
|
|
local r = region.create(0,0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
f = faction.create("human", "stealthy@eressea.de", "de")
|
2014-08-02 23:17:55 +02:00
|
|
|
u = unit.create(f, r, 1)
|
2017-03-17 22:31:59 +01:00
|
|
|
f = faction.create("human", "stealth@eressea.de", "de")
|
2015-11-09 14:17:12 +01:00
|
|
|
unit.create(f, r, 1) -- TARNE PARTEI NUMMER <no> must have a unit in the region
|
2014-08-02 23:17:55 +02:00
|
|
|
end
|
|
|
|
|
2015-01-03 16:11:33 +01:00
|
|
|
function teardown()
|
2015-09-11 10:04:08 +02:00
|
|
|
set_rule('rules.food.flags')
|
2015-01-03 16:11:33 +01:00
|
|
|
end
|
|
|
|
|
2014-08-02 23:17:55 +02:00
|
|
|
function test_stealth_faction_on()
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("TARNEN PARTEI")
|
|
|
|
|
|
|
|
process_orders()
|
|
|
|
assert_not_match("Partei", report.report_unit(u, f))
|
|
|
|
assert_match("anonym", report.report_unit(u, f))
|
|
|
|
end
|
|
|
|
|
2015-11-09 14:17:12 +01:00
|
|
|
function test_stealth_faction_other()
|
2014-08-02 23:17:55 +02:00
|
|
|
u:clear_orders()
|
2015-11-09 14:17:12 +01:00
|
|
|
u:add_order("TARNEN PARTEI NUMMER " .. itoa36(f.id))
|
2014-08-02 23:17:55 +02:00
|
|
|
|
|
|
|
process_orders()
|
2015-11-09 14:17:12 +01:00
|
|
|
assert_match(itoa36(f.id), report.report_unit(u, f))
|
2014-08-02 23:17:55 +02:00
|
|
|
assert_not_match("anonym", report.report_unit(u, f))
|
|
|
|
end
|