From 182cecf31b159f7801d2cbdc6acc7d6e983b3c60 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 30 Oct 2016 19:27:00 +0100 Subject: [PATCH] fix tests that use leveled resources. --- scripts/tests/economy.lua | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index 5678cfc6c..b628dd47b 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -99,30 +99,32 @@ end function test_guard_protects_iron() local r = region.create(0, 0, "plain") r:set_resource("iron", 100) + local level = r:get_resourcelevel("iron") local u = unit.create(faction.create("human"), r) - u:set_skill("mining", 1) + u:set_skill("mining", level) 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")) + assert_equal(level, u:get_item("iron")) process_orders() - assert_equal(1, u:get_item("iron")) + assert_equal(level, u:get_item("iron")) end function test_ironkeeper_guards_iron() local r = region.create(0, 0, "plain") r:set_resource("iron", 100) + local level = r:get_resourcelevel("iron") local u = unit.create(faction.create("human"), r) - u:set_skill("mining", 1) + u:set_skill("mining", level) local guard = unit.create(faction.create("mountainguard"), r, 1, "mountainguard") guard:add_order("BEWACHEN") u:add_order("MACHE EISEN") process_orders() - assert_equal(1, u:get_item("iron")) + assert_equal(level, u:get_item("iron")) process_orders() - assert_equal(1, u:get_item("iron")) + assert_equal(level, u:get_item("iron")) end function test_ent_guards_trees() @@ -140,26 +142,5 @@ function test_ent_guards_trees() 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