2014-08-02 23:17:55 +02:00
|
|
|
require "lunit"
|
|
|
|
|
2015-07-01 21:24:44 +02:00
|
|
|
module('tests.e2.stealth', package.seeall, lunit.testcase)
|
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-01-03 16:11:33 +01:00
|
|
|
set_rule('rules.economy.food', '4')
|
|
|
|
set_rule('rules.magic.playerschools', '')
|
2014-08-02 23:17:55 +02:00
|
|
|
|
|
|
|
local r = region.create(0,0, "plain")
|
|
|
|
f = faction.create("stealthy@eressea.de", "human", "de")
|
|
|
|
u = unit.create(f, r, 1)
|
|
|
|
f = faction.create("stealth@eressea.de", "human", "de")
|
|
|
|
end
|
|
|
|
|
2015-01-03 16:11:33 +01:00
|
|
|
function teardown()
|
|
|
|
set_rule('rules.economy.food')
|
|
|
|
set_rule('rules.magic.playerschools')
|
|
|
|
set_rule('rules.stealth.faction')
|
|
|
|
end
|
|
|
|
|
2014-08-02 23:17:55 +02:00
|
|
|
function test_stealth_faction_on()
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("TARNEN PARTEI")
|
|
|
|
|
2015-01-03 16:11:33 +01:00
|
|
|
set_rule("rules.stealth.faction", 1)
|
2014-08-02 23:17:55 +02:00
|
|
|
process_orders()
|
|
|
|
assert_not_match("Partei", report.report_unit(u, f))
|
|
|
|
assert_match("anonym", report.report_unit(u, f))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_stealth_faction_off()
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("TARNEN PARTEI")
|
|
|
|
|
2015-01-03 16:11:33 +01:00
|
|
|
set_rule("rules.stealth.faction", 0)
|
2014-08-02 23:17:55 +02:00
|
|
|
process_orders()
|
|
|
|
assert_match("Partei", report.report_unit(u, f))
|
|
|
|
assert_not_match("anonym", report.report_unit(u, f))
|
|
|
|
end
|