tests for more items

This commit is contained in:
Enno Rehling 2017-02-27 15:14:52 +01:00
parent 3d4860c033
commit 108501e398
3 changed files with 57 additions and 6 deletions

View File

@ -128,9 +128,7 @@
<!-- items -->
<resource name="antimagic" appearance="amulet">
<item weight="0" score="2000">
<function name="use" value="use_antimagiccrystal"/>
</item>
<item weight="0" score="2000" use="yes" />
</resource>
<resource name="catapultammo">

View File

@ -259,6 +259,58 @@ function test_aurapotion50()
assert_equal(50, u.aura)
end
function test_bagpipe()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("bagpipeoffear", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Dudelsack")
process_orders()
assert_equal(1, u:get_item("bagpipeoffear"))
assert_equal(1, f:count_msg_type('bagpipeoffear_faction'))
assert_equal(1, r:count_msg_type('bagpipeoffear_region'))
end
function test_speedsail()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.ship = ship.create(r, "boat")
u:add_item("speedsail", 2)
u:clear_orders()
u:add_order("BENUTZEN 1 Sonnensegel")
process_orders()
assert_equal(1, u:get_item("speedsail"))
assert_equal(1, f:count_msg_type('use_speedsail'))
end
--[[
function test_studypotion()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("studypotion", 2)
u:clear_orders()
u:add_order("LERNE Unterhaltung")
u:add_order("BENUTZEN 1 Lerntrank")
process_orders()
assert_equal(1, u:get_item("studypotion"))
end
]]--
function test_antimagic()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("antimagic", 2)
u:clear_orders()
u:add_order("BENUTZEN 1 Antimagiekristall")
process_orders()
assert_equal(1, r:count_msg_type('use_antimagiccrystal'))
assert_equal(1, u:get_item("antimagic"))
end
function test_ointment()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")

View File

@ -29,6 +29,7 @@
#include <util/attrib.h>
#include <util/event.h>
#include <util/log.h>
#include <util/parser.h>
#include <util/rand.h>
#include <util/rng.h>
@ -343,12 +344,12 @@ struct order *ord)
void register_itemfunctions(void)
{
register_demonseye();
register_item_use(use_antimagiccrystal, "use_antimagiccrystal");
register_item_use(use_studypotion, "use_studypotion");
register_item_use(use_speedsail, "use_speedsail");
register_item_use(use_bagpipeoffear, "use_bagpipeoffear");
/* have tests: */
register_item_use(use_antimagiccrystal, "use_antimagic");
register_item_use(use_speedsail, "use_speedsail");
register_item_use(use_bagpipeoffear, "use_bagpipeoffear");
register_item_use(use_aurapotion50, "use_aurapotion50");
register_item_use(use_birthdayamulet, "use_aoc");
register_item_use(use_foolpotion, "use_p7");