2012-05-26 04:55:03 +02:00
|
|
|
require "lunit"
|
|
|
|
|
2012-06-05 16:36:33 +02:00
|
|
|
module("tests.e3.spells", package.seeall, lunit.testcase)
|
2012-05-26 04:55:03 +02:00
|
|
|
|
|
|
|
function setup()
|
2014-12-31 21:07:42 +01:00
|
|
|
eressea.game.reset()
|
2012-06-10 22:33:05 +02:00
|
|
|
eressea.settings.set("magic.fumble.enable", "0")
|
2014-03-17 08:21:35 +01:00
|
|
|
eressea.settings.set("nmr.timeout", "0")
|
|
|
|
eressea.settings.set("rules.peasants.growth", "0")
|
2012-05-26 04:55:03 +02:00
|
|
|
end
|
|
|
|
|
2017-04-30 21:38:30 +02:00
|
|
|
function test_raindance()
|
2012-05-26 04:55:03 +02:00
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("halfling", "noreply@eressea.de", "de")
|
2012-05-26 04:55:03 +02:00
|
|
|
local u = unit.create(f, r)
|
|
|
|
r:set_resource("peasant", 100)
|
|
|
|
r:set_resource("money", 0)
|
|
|
|
u.magic = "gwyrrd"
|
|
|
|
u.race = "dwarf"
|
|
|
|
u:set_skill("magic", 20)
|
|
|
|
u.aura = 200
|
2017-04-30 21:38:30 +02:00
|
|
|
local err = u:add_spell("raindance")
|
2012-05-26 04:55:03 +02:00
|
|
|
assert_equal(0, err)
|
|
|
|
|
|
|
|
u:clear_orders()
|
2014-03-17 08:21:35 +01:00
|
|
|
u:add_order("ZAUBERE STUFE 3 Regentanz")
|
2012-05-26 04:55:03 +02:00
|
|
|
assert_equal(0, r:get_resource("money"), 0)
|
|
|
|
|
2014-03-17 08:21:35 +01:00
|
|
|
process_orders()
|
|
|
|
assert_equal(200, r:get_resource("money"))
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("ARBEITEN")
|
|
|
|
process_orders()
|
|
|
|
process_orders()
|
2017-04-30 20:54:53 +02:00
|
|
|
assert_equal(500, r:get_resource("money"))
|
2014-03-17 08:21:35 +01:00
|
|
|
process_orders()
|
2017-04-30 20:54:53 +02:00
|
|
|
assert_equal(600, r:get_resource("money"))
|
2012-05-26 04:55:03 +02:00
|
|
|
end
|
2015-05-07 00:31:44 +02:00
|
|
|
|
|
|
|
function test_magic()
|
|
|
|
local r = region.create(0, 0, "plain")
|
2017-03-17 22:31:59 +01:00
|
|
|
local f = faction.create("halfling", "noreply@eressea.de", "de")
|
2015-05-07 00:31:44 +02:00
|
|
|
local u = unit.create(f, r)
|
|
|
|
local b = building.create(r, "castle")
|
|
|
|
|
|
|
|
u.race = "dwarf"
|
|
|
|
u.magic = "gwyrrd"
|
|
|
|
u:set_skill("magic", 30)
|
|
|
|
u.aura = 300
|
|
|
|
|
|
|
|
u:add_spell("protective_runes")
|
|
|
|
u:add_spell("analyze_magic")
|
|
|
|
u:clear_orders()
|
|
|
|
u.building = b
|
|
|
|
u:add_order("ZAUBERE \"Magie analysieren\" BURG " .. itoa36(b.id));
|
|
|
|
process_orders()
|
2015-05-07 18:28:44 +02:00
|
|
|
-- there used to be a SEGFAULT when writing reports here:
|
|
|
|
-- write_reports()
|
2015-05-07 00:31:44 +02:00
|
|
|
end
|
2017-04-30 17:25:24 +02:00
|
|
|
|
|
|
|
-- E3: earn 50 per every TWO levels of spell
|
2017-04-30 17:42:16 +02:00
|
|
|
function test_earn_silver()
|
|
|
|
local r = region.create(0, 0, "mountain")
|
2017-04-30 17:25:24 +02:00
|
|
|
local f = faction.create("human")
|
|
|
|
local u = unit.create(f, r)
|
|
|
|
|
|
|
|
eressea.settings.set("rules.food.flags", "4")
|
|
|
|
eressea.settings.set("magic.fumble.enable", "0")
|
|
|
|
eressea.settings.set("rules.peasants.growth", "0")
|
|
|
|
eressea.settings.set("rules.economy.repopulate_maximum", "0")
|
|
|
|
|
|
|
|
u.magic = "gwyrrd"
|
|
|
|
u.race = "elf"
|
|
|
|
u:set_skill("magic", 10)
|
|
|
|
u.aura = 100
|
|
|
|
local err = u:add_spell("earn_silver#gwyrrd")
|
|
|
|
assert_equal(0, err)
|
|
|
|
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("ZAUBERE STUFE 1 Viehheilung")
|
2017-04-30 17:48:08 +02:00
|
|
|
r:set_resource("money", 200)
|
2017-04-30 17:25:24 +02:00
|
|
|
r:set_resource("peasant", 0)
|
|
|
|
process_orders() -- get 50 silver
|
|
|
|
assert_equal(50, u:get_item("money"))
|
2017-04-30 17:48:08 +02:00
|
|
|
assert_equal(150, r:get_resource("money"))
|
2017-04-30 17:25:24 +02:00
|
|
|
|
2017-04-30 17:48:08 +02:00
|
|
|
u:clear_orders() -- get 50 silver
|
2017-04-30 17:25:24 +02:00
|
|
|
u:add_order("ZAUBERE STUFE 2 Viehheilung")
|
|
|
|
process_orders()
|
2017-04-30 17:48:08 +02:00
|
|
|
assert_equal(100, u:get_item("money"))
|
|
|
|
assert_equal(100, r:get_resource("money"))
|
2017-04-30 17:25:24 +02:00
|
|
|
|
2017-04-30 17:48:08 +02:00
|
|
|
u:clear_orders() -- get 75 silver
|
2017-04-30 17:25:24 +02:00
|
|
|
u:add_order("ZAUBERE STUFE 3 Viehheilung")
|
|
|
|
process_orders()
|
2017-04-30 17:48:08 +02:00
|
|
|
assert_equal(175, u:get_item("money"))
|
2017-04-30 17:25:24 +02:00
|
|
|
assert_equal(25, r:get_resource("money"))
|
|
|
|
|
|
|
|
process_orders() -- not enough
|
2017-04-30 17:48:08 +02:00
|
|
|
assert_equal(200, u:get_item("money"))
|
2017-04-30 17:25:24 +02:00
|
|
|
assert_equal(0, r:get_resource("money"))
|
|
|
|
end
|