2017-02-28 10:48:27 +01:00
|
|
|
require "lunit"
|
|
|
|
|
|
|
|
module("tests.e3.items", package.seeall, lunit.testcase )
|
|
|
|
|
|
|
|
function setup()
|
|
|
|
eressea.game.reset()
|
|
|
|
eressea.settings.set("rules.food.flags", "4") -- food is free
|
|
|
|
eressea.settings.set("NewbieImmunity", "0")
|
2017-03-03 16:50:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_give_horses()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("human", "noreply@eressea.de", "de")
|
2017-03-03 16:50:43 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
|
|
|
|
r:set_resource("horse", 0)
|
|
|
|
u:add_item("charger", 20)
|
|
|
|
u:add_order("GIB 0 10 Streitross")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(10, r:get_resource("horse"))
|
|
|
|
assert_equal(10, u:get_item("charger"))
|
2017-02-28 10:48:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_goblins()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f1 = faction.create("goblin", "goblin@eressea.de", "de")
|
|
|
|
local f2 = faction.create("dwarf", "dwarf@eressea.de", "de")
|
|
|
|
local f3 = faction.create("elf", "elf@eressea.de", "de")
|
2017-02-28 11:07:32 +01:00
|
|
|
local ud = unit.create(f1, r, 1)
|
|
|
|
local uh = unit.create(f1, r, 1)
|
|
|
|
uh.race = "halfling"
|
2017-02-28 10:48:27 +01:00
|
|
|
local u2 = unit.create(f2, r, 1)
|
|
|
|
local u3 = unit.create(f3, r, 1)
|
|
|
|
|
|
|
|
local restricted = {
|
|
|
|
"towershield", "rep_crossbow", "plate", "lance",
|
2017-03-03 09:56:27 +01:00
|
|
|
"mallornlance", "greatbow", "greataxe", "axe", "scale",
|
|
|
|
"plate", "halberd", "greatsword", "rustyhalberd"
|
2017-02-28 10:48:27 +01:00
|
|
|
}
|
|
|
|
for k, v in ipairs(restricted) do
|
2017-02-28 11:07:32 +01:00
|
|
|
ud:add_item(v, 1)
|
|
|
|
uh:add_item(v, 1)
|
2017-02-28 10:48:27 +01:00
|
|
|
u2:add_item(v, 1)
|
2017-02-28 10:58:09 +01:00
|
|
|
u3:add_item(v, 1)
|
2017-02-28 10:48:27 +01:00
|
|
|
end
|
|
|
|
|
2017-02-28 11:07:32 +01:00
|
|
|
uh:add_order("ATTACKIERE " .. itoa36(u2.id))
|
|
|
|
uh:add_order("ATTACKIERE " .. itoa36(u3.id))
|
|
|
|
ud:add_order("ATTACKIERE " .. itoa36(u2.id))
|
|
|
|
ud:add_order("ATTACKIERE " .. itoa36(u3.id))
|
2017-02-28 10:48:27 +01:00
|
|
|
process_orders()
|
|
|
|
end
|
2017-03-03 18:02:43 +01:00
|
|
|
|
|
|
|
function test_make_horse()
|
|
|
|
eressea.settings.set("rules.horses.growth", "0")
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("human", "horses@eressea.de", "de")
|
2017-03-03 18:02:43 +01:00
|
|
|
local u = unit.create(f, r, 1)
|
|
|
|
u:set_skill("training", 4)
|
|
|
|
r:set_resource("horse", 100)
|
|
|
|
u:add_order("MACHE 1 PFERD")
|
|
|
|
process_orders()
|
|
|
|
assert_equal(1, u:get_item("horse"))
|
|
|
|
assert_equal(99, r:get_resource("horse"))
|
|
|
|
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("MACHE 1 STREITROSS")
|
|
|
|
u:add_item("money", 200)
|
|
|
|
u:add_item("iron", 1)
|
|
|
|
process_orders()
|
|
|
|
assert_equal(1, u:get_item("charger"))
|
|
|
|
assert_equal(0, u:get_item("horse"))
|
|
|
|
assert_equal(0, u:get_item("iron"))
|
|
|
|
assert_equal(0, u:get_item("money"))
|
|
|
|
assert_equal(99, r:get_resource("horse"))
|
|
|
|
end
|