2010-08-08 10:06:34 +02:00
|
|
|
require "lunit"
|
|
|
|
|
2012-06-05 16:36:05 +02:00
|
|
|
module("tests.eressea.spells", package.seeall, lunit.testcase)
|
|
|
|
|
|
|
|
local r, f, u
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
function setup()
|
2012-06-07 04:29:36 +02:00
|
|
|
eressea.free_game()
|
|
|
|
eressea.settings.set("magic.regeneration.enable", "0")
|
|
|
|
eressea.settings.set("magic.fumble.enable", "0")
|
|
|
|
eressea.settings.set("rules.economy.food", "4")
|
2012-06-05 16:36:05 +02:00
|
|
|
|
|
|
|
r = region.create(0, 0, "plain")
|
|
|
|
f = faction.create("spell_payment@eressea.de", "elf", "de")
|
|
|
|
u = unit.create(f, r, 1)
|
|
|
|
u.magic = "gray"
|
|
|
|
u:set_skill("magic", 12)
|
2012-05-30 05:44:25 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_spell_payment()
|
|
|
|
u:add_spell("create_roi")
|
|
|
|
|
|
|
|
local permaura = u:get_pooled("permaura")
|
|
|
|
u:add_item("money", 3000)
|
|
|
|
u.aura = 50
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ")
|
|
|
|
process_orders()
|
2012-06-05 16:36:05 +02:00
|
|
|
write_reports()
|
2012-05-30 05:44:25 +02:00
|
|
|
assert_equal(1, u:get_item("roi"))
|
|
|
|
assert_equal(0, u:get_item("money"))
|
|
|
|
assert_equal(0, u.aura)
|
|
|
|
assert_equal(permaura-1, u:get_pooled("permaura"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_spell_not_found_no_payment()
|
|
|
|
local permaura = u:get_pooled("permaura")
|
|
|
|
u:add_item("money", 3000)
|
|
|
|
u.aura = 50
|
|
|
|
|
|
|
|
u:clear_orders()
|
|
|
|
u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ")
|
|
|
|
process_orders()
|
|
|
|
|
|
|
|
assert_equal(0, u:get_item("roi"))
|
|
|
|
assert_equal(3000, u:get_item("money"))
|
|
|
|
assert_equal(50, u.aura)
|
|
|
|
assert_equal(permaura, u:get_pooled("permaura"))
|
2010-08-08 10:06:34 +02:00
|
|
|
end
|
|
|
|
|
2012-05-30 03:08:56 +02:00
|
|
|
function test_create_roi()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_roi')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_roi')
|
2012-05-26 04:55:47 +02:00
|
|
|
assert_equal(1, u:get_item("roi"))
|
2010-08-08 10:06:34 +02:00
|
|
|
end
|
2012-05-30 03:08:56 +02:00
|
|
|
|
|
|
|
function test_create_roqf()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_roqf')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_roqf')
|
|
|
|
assert_equal(1, u:get_item("roqf"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_create_aots()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_aots')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_aots')
|
|
|
|
assert_equal(1, u:get_item("aots"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_create_ror()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_ror')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_ror')
|
|
|
|
assert_equal(1, u:get_item("ror"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_create_trollbelt()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_trollbelt')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_trollbelt')
|
|
|
|
assert_equal(1, u:get_item("trollbelt"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_create_dreameye()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_dreameye')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_dreameye')
|
|
|
|
assert_equal(1, u:get_item("dreameye"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_create_antimagic()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_antimagic')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_antimagic')
|
|
|
|
assert_equal(1, u:get_item("antimagic"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function test_create_rop()
|
2012-05-30 05:50:20 +02:00
|
|
|
u:add_spell('create_rop')
|
2012-05-30 03:08:56 +02:00
|
|
|
u:cast_spell('create_rop')
|
|
|
|
assert_equal(1, u:get_item("rop"))
|
|
|
|
end
|