Merge pull request #106 from badgerman/master

fix magicstreets (Bug 2066) and dreams (Bug 1511)
This commit is contained in:
Enno Rehling 2015-01-12 18:39:08 +01:00
commit 9404afa4ea
3 changed files with 31 additions and 5 deletions

View File

@ -43,7 +43,7 @@ static void test_magicstreet(CuTest *tc) {
curse_fixture fix; curse_fixture fix;
message *msg; message *msg;
setup_curse(&fix, "magicstreet"); setup_curse(&fix, "magicstreet");
fix.c->duration = 3; fix.c->duration = 2;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0); msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::magicstreet", test_get_messagetype(msg)); CuAssertStrEquals(tc, "curseinfo::magicstreet", test_get_messagetype(msg));
msg_release(msg); msg_release(msg);
@ -54,18 +54,42 @@ static void test_magicstreet_warning(CuTest *tc) {
curse_fixture fix; curse_fixture fix;
message *msg; message *msg;
setup_curse(&fix, "magicstreet"); setup_curse(&fix, "magicstreet");
fix.c->duration = 2; fix.c->duration = 1;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0); msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::magicstreetwarn", test_get_messagetype(msg)); CuAssertStrEquals(tc, "curseinfo::magicstreetwarn", test_get_messagetype(msg));
msg_release(msg); msg_release(msg);
test_cleanup(); test_cleanup();
} }
static void test_good_dreams(CuTest *tc) {
curse_fixture fix;
message *msg;
setup_curse(&fix, "gbdream");
fix.c->effect = 1;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::gooddream", test_get_messagetype(msg));
msg_release(msg);
test_cleanup();
}
static void test_bad_dreams(CuTest *tc) {
curse_fixture fix;
message *msg;
setup_curse(&fix, "gbdream");
fix.c->effect = -1;
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
CuAssertStrEquals(tc, "curseinfo::baddream", test_get_messagetype(msg));
msg_release(msg);
test_cleanup();
}
CuSuite *get_curse_suite(void) CuSuite *get_curse_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_curse); SUITE_ADD_TEST(suite, test_curse);
SUITE_ADD_TEST(suite, test_magicstreet); SUITE_ADD_TEST(suite, test_magicstreet);
SUITE_ADD_TEST(suite, test_magicstreet_warning); SUITE_ADD_TEST(suite, test_magicstreet_warning);
SUITE_ADD_TEST(suite, test_good_dreams);
SUITE_ADD_TEST(suite, test_bad_dreams);
return suite; return suite;
} }

View File

@ -74,11 +74,12 @@ static message *cinfo_dreamcurse(const void *obj, objtype_t typ, const curse * c
unused_arg(obj); unused_arg(obj);
assert(typ == TYP_REGION); assert(typ == TYP_REGION);
if (curse_geteffect(c) > 0) { if (c->effect > 0) {
return msg_message("curseinfo::gooddream", "id", c->no); return msg_message("curseinfo::gooddream", "id", c->no);
} } else {
return msg_message("curseinfo::baddream", "id", c->no); return msg_message("curseinfo::baddream", "id", c->no);
} }
}
static struct curse_type ct_gbdream = { static struct curse_type ct_gbdream = {
"gbdream", "gbdream",
@ -99,7 +100,7 @@ static message *cinfo_magicstreet(const void *obj, objtype_t typ, const curse *
assert(typ == TYP_REGION); assert(typ == TYP_REGION);
/* Warnung vor Auflösung */ /* Warnung vor Auflösung */
if (c->duration <= 2) { if (c->duration >= 2) {
return msg_message("curseinfo::magicstreet", "id", c->no); return msg_message("curseinfo::magicstreet", "id", c->no);
} }
return msg_message("curseinfo::magicstreetwarn", "id", c->no); return msg_message("curseinfo::magicstreetwarn", "id", c->no);

View File

@ -13,6 +13,7 @@ extern "C" {
struct faction; struct faction;
struct building; struct building;
struct ship; struct ship;
struct message;
struct item_type; struct item_type;
struct building_type; struct building_type;
struct ship_type; struct ship_type;