Skip to content

Commit

Permalink
bugfix and test for shadowdemons
Browse files Browse the repository at this point in the history
  • Loading branch information
ennorehling committed Mar 10, 2024
1 parent 81f1292 commit 598aa5d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/spells.c
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,7 @@ static int sp_plague(castorder * co)
* Flag:
* (SPELLLEVEL)
*/
static int sp_summonshadow(castorder * co)
int sp_summonshadow(castorder * co)
{
region *r = co_get_region(co);
unit *caster = co_get_caster(co);
Expand All @@ -2960,7 +2960,7 @@ static int sp_summonshadow(castorder * co)
u = create_unit(r, caster->faction, number, get_race(RC_SHADOW), 0, NULL, caster);

/* Bekommen Tarnung = (Magie+Tarnung)/2 und Wahrnehmung 1. */
val = get_level(caster, SK_MAGIC) + get_level(caster, SK_STEALTH);
val = (get_level(caster, SK_MAGIC) + get_level(caster, SK_STEALTH)) / 2;

set_level(u, SK_STEALTH, val);
set_level(u, SK_PERCEPTION, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/spells.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ int sp_destroy_magic(struct castorder *co);
int sp_rosthauch(struct castorder *co);
int sp_sparkle(struct castorder *co);
int sp_summon_familiar(struct castorder *co);

int sp_summonshadow(struct castorder *co);
31 changes: 31 additions & 0 deletions src/spells.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ static void test_view_reality(CuTest *tc) {
"unit:unit", "region:region", "command:order", MT_NEW_END);
mt_create_va(mt_new("viewreality_effect", NULL),
"unit:unit", MT_NEW_END);
mt_create_va(mt_new("summonshadow_effect", NULL),
"mage:unit", "number:int", MT_NEW_END);
rx = test_create_region(0, TP_RADIUS + 1, NULL);
f = test_create_faction();
u = test_create_unit(f, rx);
Expand Down Expand Up @@ -1425,6 +1427,34 @@ static void test_summon_familiar(CuTest *tc) {
CuAssertPtrEquals(tc, rc_special, (race *)u_race(u2));
}

static void test_summonshadow(CuTest *tc) {
struct region *r;
struct faction *f;
unit *u, *u2;
race *rc;
castorder co;

test_setup();
r = test_create_plain(0, 0);
f = test_create_faction();
f->magiegebiet = M_DRAIG;
u = test_create_unit(f, r);
rc = test_create_race("shadowdemon");
CuAssertPtrEquals(tc, (void *)get_race(RC_SHADOW), rc);
test_set_skill(u, SK_MAGIC, 10, 1);
test_set_skill(u, SK_STEALTH, 6, 1);
test_create_castorder(&co, u, 3, 10., 0, NULL);

CuAssertIntEquals(tc, co.level, sp_summonshadow(&co));
CuAssertPtrNotNull(tc, u2 = u->next);
CuAssertPtrEquals(tc, u->faction, u2->faction);
CuAssertPtrEquals(tc, rc, (race *)u_race(u2));
CuAssertIntEquals(tc, 100, u2->number);
CuAssertIntEquals(tc, 8, effskill(u2, SK_STEALTH, u2->region));
CuAssertIntEquals(tc, 1, effskill(u2, SK_PERCEPTION, u2->region));
CuAssertPtrNotNull(tc, test_find_faction_message(f, "summonshadow_effect"));
}

CuSuite *get_spells_suite(void)
{
CuSuite *suite = CuSuiteNew();
Expand Down Expand Up @@ -1464,6 +1494,7 @@ CuSuite *get_spells_suite(void)
SUITE_ADD_TEST(suite, test_rosthauch);
SUITE_ADD_TEST(suite, test_sparkle);
SUITE_ADD_TEST(suite, test_summon_familiar);
SUITE_ADD_TEST(suite, test_summonshadow);

return suite;
}

0 comments on commit 598aa5d

Please sign in to comment.