forked from github/server
test the birthday amulet
This commit is contained in:
parent
604b574d0f
commit
60c2f1e807
|
@ -62,9 +62,7 @@
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="aoc" appearance="amulet">
|
<resource name="aoc" appearance="amulet">
|
||||||
<item weight="100">
|
<item weight="100" use="yes" />
|
||||||
<function name="use" value="use_birthdayamulet"/>
|
|
||||||
</item>
|
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="dreameye">
|
<resource name="dreameye">
|
||||||
|
|
|
@ -230,12 +230,24 @@ function test_no_uruk()
|
||||||
assert_equal(f1.race, "orc")
|
assert_equal(f1.race, "orc")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_meow()
|
||||||
|
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("aoc", 1)
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order("BENUTZEN 1 Katzenamulett")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(1, u:get_item("aoc"))
|
||||||
|
assert_equal(1, r:count_msg_type('meow'))
|
||||||
|
end
|
||||||
|
|
||||||
function test_ointment()
|
function test_ointment()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||||
local u = unit.create(f, r, 1)
|
local u = unit.create(f, r, 1)
|
||||||
local hp = u.hp
|
local hp = u.hp
|
||||||
u.hp = 0
|
u.hp = 1
|
||||||
u:add_item("ointment", 1)
|
u:add_item("ointment", 1)
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
u:add_order("BENUTZEN 1 Wundsalbe")
|
u:add_order("BENUTZEN 1 Wundsalbe")
|
||||||
|
|
|
@ -29,6 +29,7 @@ without prior permission by the authors of Eressea.
|
||||||
#include <kernel/ship.h>
|
#include <kernel/ship.h>
|
||||||
#include <kernel/plane.h>
|
#include <kernel/plane.h>
|
||||||
#include <kernel/terrain.h>
|
#include <kernel/terrain.h>
|
||||||
|
#include <kernel/messages.h>
|
||||||
#include <modules/autoseed.h>
|
#include <modules/autoseed.h>
|
||||||
#include <attributes/key.h>
|
#include <attributes/key.h>
|
||||||
#include <attributes/racename.h>
|
#include <attributes/racename.h>
|
||||||
|
@ -46,6 +47,23 @@ without prior permission by the authors of Eressea.
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int tolua_region_count_msg_type(lua_State *L) {
|
||||||
|
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||||
|
const char *str = tolua_tostring(L, 2, 0);
|
||||||
|
int n = 0;
|
||||||
|
if (self->msgs) {
|
||||||
|
mlist * ml = self->msgs->begin;
|
||||||
|
while (ml) {
|
||||||
|
if (strcmp(str, ml->msg->type->name) == 0) {
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
ml = ml->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lua_pushinteger(L, n);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int tolua_regionlist_next(lua_State * L)
|
int tolua_regionlist_next(lua_State * L)
|
||||||
{
|
{
|
||||||
region **region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1));
|
region **region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1));
|
||||||
|
@ -671,6 +689,8 @@ void tolua_region_open(lua_State * L)
|
||||||
tolua_function(L, TOLUA_CAST "destroy", tolua_region_destroy);
|
tolua_function(L, TOLUA_CAST "destroy", tolua_region_destroy);
|
||||||
tolua_function(L, TOLUA_CAST "__tostring", tolua_region_tostring);
|
tolua_function(L, TOLUA_CAST "__tostring", tolua_region_tostring);
|
||||||
|
|
||||||
|
tolua_function(L, TOLUA_CAST "count_msg_type", tolua_region_count_msg_type);
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
tolua_variable(L, TOLUA_CAST "blocked", tolua_region_get_blocked, tolua_region_set_blocked);
|
tolua_variable(L, TOLUA_CAST "blocked", tolua_region_get_blocked, tolua_region_set_blocked);
|
||||||
|
|
||||||
|
|
|
@ -1289,7 +1289,7 @@ void register_resources(void)
|
||||||
|
|
||||||
register_item_use(use_potion_delayed, "use_p2");
|
register_item_use(use_potion_delayed, "use_p2");
|
||||||
register_item_use(use_tacticcrystal, "use_tacticcrystal");
|
register_item_use(use_tacticcrystal, "use_tacticcrystal");
|
||||||
register_item_use(use_birthdayamulet, "use_birthdayamulet");
|
register_item_use(use_birthdayamulet, "use_aoc");
|
||||||
register_item_use(use_warmthpotion, "use_nestwarmth");
|
register_item_use(use_warmthpotion, "use_nestwarmth");
|
||||||
register_item_use(use_bloodpotion, "use_peasantblood");
|
register_item_use(use_bloodpotion, "use_peasantblood");
|
||||||
register_item_use(use_healingpotion, "use_ointment");
|
register_item_use(use_healingpotion, "use_ointment");
|
||||||
|
|
|
@ -855,6 +855,7 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)
|
||||||
struct order *))fun;
|
struct order *))fun;
|
||||||
}
|
}
|
||||||
else if (strcmp((const char *)propValue, "use") == 0) {
|
else if (strcmp((const char *)propValue, "use") == 0) {
|
||||||
|
log_error("%s has a use function", rtype->_name);
|
||||||
itype->flags |= ITF_CANUSE;
|
itype->flags |= ITF_CANUSE;
|
||||||
itype->use =
|
itype->use =
|
||||||
(int(*)(struct unit *, const struct item_type *, int,
|
(int(*)(struct unit *, const struct item_type *, int,
|
||||||
|
|
Loading…
Reference in New Issue