From 77cf7f68761d3665e86796a7aecd0d4129a55449 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 22 Dec 2017 20:07:30 +0100 Subject: [PATCH 1/2] new factions cannot guard --- scripts/tests/e3/rules.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 4f44bc3a4..0888aa0b9 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -1011,6 +1011,7 @@ end function test_demons_using_mallornlance() -- bug 2392 set_rule("skillchange.demon.up", "0") + set_rule("NewbieImmunity", "0") local r = region.create(0, 0, "plain") local f = faction.create('goblin') local u = unit.create(f, r, 1, 'demon') @@ -1019,5 +1020,9 @@ function test_demons_using_mallornlance() u:add_item('mallornlance', 1) u:add_order('BEWACHE') process_orders() + if not u.guard then + init_reports() + write_report(f) + end assert_true(u.guard) end From abd2a398d1f89df202dfbdf219c01355edf194a7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 22 Dec 2017 20:12:05 +0100 Subject: [PATCH 2/2] check that newbie immunity prevents guarding --- scripts/tests/common.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index d76c2cfdf..b77606266 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1160,3 +1160,19 @@ function test_bug_2393_cart() process_orders() assert_equal(r1, u.region) end + +function test_immunity_stops_guard() + eressea.settings.set("NewbieImmunity", 2) + local f = faction.create('human') + local r = region.create(0, 0, 'plain') + local u = unit.create(f, r) + u:set_skill('polearm', 2) + u:add_item('lance', 1) + u:add_order('BEWACHE') + process_orders() + assert_equal(f.age, 1) + assert_true(not u.guard) + process_orders() + assert_equal(f.age, 2) + assert_true(u.guard) +end