From f17b6f2bb5dfaa63f25fa3a3bf8779208cbc0aa0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 28 Oct 2016 20:26:34 +0200 Subject: [PATCH] WIP: additional testing for GUARD. BUG: ents cannot guard, do not protect trees. FIX: issue #589 (bad test for stardust) --- scripts/tests/e2/init.lua | 3 +- scripts/tests/economy.lua | 71 +++++++++++++++++++++++++++++++++++++++ scripts/tests/xmas.lua | 1 + 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 9e9163256..afaac7209 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,3 +1,5 @@ +require 'tests.economy' + require 'tests.e2.undead' require 'tests.e2.shiplanding' require 'tests.e2.e2features' @@ -13,4 +15,3 @@ require 'tests.storage' require 'tests.magicbag' require 'tests.process' require 'tests.xmas' -require 'tests.economy' diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index f528f16d2..ebacc32e1 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -79,6 +79,38 @@ function test_ent_guards_trees() assert_equal(1, u:get_item("log")) end +function test_guard_stops_recruit() + local r = region.create(0, 0, "plain") + r:set_resource("peasant", 100) + local u = unit.create(faction.create("human"), r) + local guard = unit.create(get_monsters(), r, 1) + guard:add_order("BEWACHEN") + + u:add_item("money", 1000) + assert_equal(1, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(2, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(2, u.number) +end + +function test_guard_protects_iron() + local r = region.create(0, 0, "plain") + r:set_resource("iron", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("mining", 1) + local guard = unit.create(get_monsters(), r, 1) + guard:add_order("BEWACHEN") + + u:add_order("MACHE EISEN") + process_orders() + assert_equal(1, u:get_item("iron")) + process_orders() + assert_equal(1, u:get_item("iron")) +end + function test_ironkeeper_guards_iron() local r = region.create(0, 0, "plain") r:set_resource("iron", 100) @@ -92,3 +124,42 @@ function test_ironkeeper_guards_iron() process_orders() assert_equal(1, u:get_item("iron")) end + +function test_ent_guards_trees() + local r = region.create(0, 0, "plain") + r:set_resource("tree", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("mining", 1) + local guard = unit.create(get_monsters(), r, 1, "ent") + u:set_skill("forestry", 1) + guard:add_order("BEWACHEN") + guard:clear_orders() + u:clear_orders() + + u:add_order("MACHE HOLZ") + process_orders() + assert_equal(1, u:get_item("log")) + process_orders() + -- print("report: " .. tostring(u.faction)) + -- init_reports() + -- write_report(u.faction) + assert_equal(1, u:get_item("log")) +end + +function test_ironkeeper_allows_recruit() + local r = region.create(0, 0, "plain") + r:set_resource("iron", 100) + local u = unit.create(faction.create("human"), r) + u:set_skill("mining", 1) + local guard = unit.create(faction.create("mountainguard"), r, 1, "mountainguard") + guard:add_order("BEWACHEN") + + u:add_item("money", 1000) + assert_equal(1, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(2, u.number) + u:add_order("REKRUTIERE 1") + process_orders() + assert_equal(3, u.number) +end diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index e1cd4753b..bbd4941f2 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -6,6 +6,7 @@ function setup() eressea.free_game() eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.grow.formula", "0") + eressea.settings.set("rules.peasants.growth.factor", "0") end function test_snowglobe_fail()