WIP: additional testing for GUARD.

BUG: ents cannot guard, do not protect trees.
FIX: issue #589 (bad test for stardust)
This commit is contained in:
Enno Rehling 2016-10-28 20:26:34 +02:00
parent e0a6618199
commit f17b6f2bb5
3 changed files with 74 additions and 1 deletions

View File

@ -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'

View File

@ -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

View File

@ -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()