forked from github/server
bug 1692: rewrite of magicresistance curse-info, especially for buildings (homestome spell).
This commit is contained in:
parent
d7f4fbe05d
commit
6abf8f7adb
|
@ -392,13 +392,20 @@
|
|||
</message>
|
||||
<message name="curseinfo::magicresistance" section="events">
|
||||
<type>
|
||||
<arg name="building" type="building"/>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="id" type="int"/>
|
||||
</type>
|
||||
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
|
||||
<text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
|
||||
</message>
|
||||
<message name="curseinfo::homestone" section="events">
|
||||
<type>
|
||||
<arg name="building" type="building"/>
|
||||
<arg name="id" type="int"/>
|
||||
</type>
|
||||
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
|
||||
<text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
|
||||
</message>
|
||||
<message name="curseinfo::goodmagicresistancezone" section="events">
|
||||
<type>
|
||||
<arg name="id" type="int"/>
|
||||
|
@ -415,6 +422,7 @@
|
|||
</message>
|
||||
<message name="curseinfo::magicwalls" section="events">
|
||||
<type>
|
||||
<arg name="building" type="building"/>
|
||||
<arg name="id" type="int"/>
|
||||
</type>
|
||||
<text locale="de">"Diese Mauern wirken, als wären sie direkt aus der Erde gewachsen und nicht erbaut. ($int36($id))"</text>
|
||||
|
@ -422,6 +430,7 @@
|
|||
</message>
|
||||
<message name="curseinfo::buildingunknown" section="events">
|
||||
<type>
|
||||
<arg name="building" type="building"/>
|
||||
<arg name="id" type="int"/>
|
||||
</type>
|
||||
<text locale="de">"Ein magischer Schimmer liegt auf diesen Mauern. ($int36($id))"</text>
|
||||
|
@ -542,6 +551,7 @@
|
|||
<message name="curseinfo::nocostbuilding" section="events">
|
||||
<type>
|
||||
<arg name="id" type="int"/>
|
||||
<arg name="building" type="building"/>
|
||||
</type>
|
||||
<text locale="de">"Der Zahn der Zeit kann diesen Mauern nichts anhaben. ($int36($id))"</text>
|
||||
<text locale="en">"Time cannot touch these walls. ($int36($id))"</text>
|
||||
|
|
|
@ -188,7 +188,6 @@ message *msg_message(const char *name, const char *sig, ...)
|
|||
}
|
||||
else {
|
||||
log_error("invalid parameter %s for message type %s\n", paramname, mtype->name);
|
||||
assert(!"program aborted.");
|
||||
}
|
||||
while (*ic && !isalnum(*ic))
|
||||
ic++;
|
||||
|
@ -196,7 +195,6 @@ message *msg_message(const char *name, const char *sig, ...)
|
|||
va_end(vargs);
|
||||
if (argnum != mtype->nparameters) {
|
||||
log_error("not enough parameters for message type %s\n", mtype->name);
|
||||
assert(!"program aborted.");
|
||||
}
|
||||
|
||||
return msg_create(mtype, args);
|
||||
|
|
|
@ -36,14 +36,13 @@
|
|||
message *cinfo_building(const void *obj, objtype_t typ, const curse * c,
|
||||
int self)
|
||||
{
|
||||
const building *b = (const building *)obj;
|
||||
unused_arg(typ);
|
||||
assert(typ == TYP_BUILDING);
|
||||
assert(obj);
|
||||
assert(c);
|
||||
|
||||
if (self != 0) { /* owner or inside */
|
||||
building *b = (building *)obj;
|
||||
return msg_message(mkname("curseinfo", c->type->cname), "id building", c->no, b);
|
||||
}
|
||||
return msg_message(mkname("curseinfo", "buildingunknown"), "id", c->no);
|
||||
return msg_message(mkname("curseinfo", self ? c->type->cname : "buildingunknown"), "id building", c->no, b);
|
||||
}
|
||||
|
||||
/* CurseInfo mit Spezialabfragen */
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
#include <platform.h>
|
||||
#include <kernel/config.h>
|
||||
#include "unitcurse.h"
|
||||
#include "buildingcurse.h"
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/messages.h>
|
||||
#include <util/language.h>
|
||||
|
||||
static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, const struct curse * c, int self)
|
||||
{
|
||||
if (typ == TYP_UNIT) {
|
||||
return cinfo_unit(obj, typ, c, self);
|
||||
if (self != 0) {
|
||||
const struct unit *u = (const struct unit *)obj;
|
||||
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u,
|
||||
c->no);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (typ == TYP_BUILDING) {
|
||||
return cinfo_building(obj, typ, c, self);
|
||||
const struct building *b = (const struct building *)obj;
|
||||
return msg_message(mkname("curseinfo", self ? "homestone" : "buildingunknown"), "id building", c->no, b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#include <platform.h>
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <util/message.h>
|
||||
#include <util/language.h>
|
||||
#include <util/attrib.h>
|
||||
#include <spells/regioncurse.h>
|
||||
|
@ -29,11 +31,11 @@ static struct castorder *test_create_castorder(castorder *order, unit *u, const
|
|||
return order = create_castorder(order, u, NULL, sp, u->region, level, force, range, create_order(K_CAST, lang, ""), NULL);
|
||||
}
|
||||
|
||||
static void test_magicresistance(CuTest *tc) {
|
||||
static void test_magicresistance_unit(CuTest *tc) {
|
||||
struct region *r;
|
||||
struct faction *f1, *f2;
|
||||
unit *u1, *u2;
|
||||
int level;
|
||||
message *msg;
|
||||
curse *c;
|
||||
|
||||
test_cleanup();
|
||||
|
@ -45,12 +47,47 @@ static void test_magicresistance(CuTest *tc) {
|
|||
f2 = test_create_faction(test_create_race("human"));
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
||||
c = create_curse(u1, &u2->attribs, ct_find("magicresistance"), 10, 20, 30, u2->number);
|
||||
CuAssertPtrNotNull(tc, u2->attribs);
|
||||
CuAssertPtrEquals(tc, (void *)&at_curse, (void *)u2->attribs->type);
|
||||
msg = c->type->curseinfo(u2, TYP_UNIT, c, 1);
|
||||
CuAssertPtrNotNull(tc, msg);
|
||||
CuAssertStrEquals(tc, "curseinfo::magicresistance", test_get_messagetype(msg));
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_magicresistance_building(CuTest *tc) {
|
||||
struct region *r;
|
||||
struct faction *f1, *f2;
|
||||
unit *u1;
|
||||
building *b1;
|
||||
message *msg;
|
||||
curse *c;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
||||
f2 = test_create_faction(test_create_race("human"));
|
||||
b1 = test_create_building(r, test_create_buildingtype("castle"));
|
||||
|
||||
c = create_curse(u1, &b1->attribs, ct_find("magicresistance"), 10, 20, 30, 0);
|
||||
CuAssertPtrNotNull(tc, b1->attribs);
|
||||
CuAssertPtrEquals(tc, (void *)&at_curse, (void *)b1->attribs->type);
|
||||
msg = c->type->curseinfo(b1, TYP_BUILDING, c, 1);
|
||||
CuAssertPtrNotNull(tc, msg);
|
||||
CuAssertStrEquals(tc, "curseinfo::homestone", test_get_messagetype(msg));
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_magicresistance_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_magicresistance);
|
||||
SUITE_ADD_TEST(suite, test_magicresistance_unit);
|
||||
SUITE_ADD_TEST(suite, test_magicresistance_building);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,7 @@ message *cinfo_unit(const void *obj, objtype_t typ, const curse * c, int self)
|
|||
{
|
||||
unused_arg(typ);
|
||||
assert(typ == TYP_UNIT);
|
||||
assert(obj);
|
||||
|
||||
if (self != 0) {
|
||||
unit *u = (unit *)obj;
|
||||
|
|
|
@ -74,6 +74,7 @@ int RunAllTests(void)
|
|||
RUN_TESTS(suite, building);
|
||||
RUN_TESTS(suite, spell);
|
||||
RUN_TESTS(suite, spells);
|
||||
RUN_TESTS(suite, magicresistance);
|
||||
RUN_TESTS(suite, ally);
|
||||
RUN_TESTS(suite, messages);
|
||||
/* gamecode */
|
||||
|
|
Loading…
Reference in New Issue