fix magic tests that created gray mages.

also fix mage_change_spellpoints.
This commit is contained in:
Enno Rehling 2018-11-18 21:53:45 +01:00
parent 4a66b558c5
commit 3638219e13
4 changed files with 6 additions and 6 deletions

View file

@ -25,7 +25,7 @@ static void test_manacrystal(CuTest *tc) {
CuAssertIntEquals(tc, -1, use_manacrystal(u, itype, 1, NULL)); CuAssertIntEquals(tc, -1, use_manacrystal(u, itype, 1, NULL));
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error295")); CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error295"));
test_clear_messages(u->faction); test_clear_messages(u->faction);
create_mage(u, M_GRAY); create_mage(u, M_GWYRRD);
set_level(u, SK_MAGIC, 5); set_level(u, SK_MAGIC, 5);
CuAssertIntEquals(tc, 0, get_spellpoints(u)); CuAssertIntEquals(tc, 0, get_spellpoints(u));
CuAssertIntEquals(tc, 1, use_manacrystal(u, itype, 1, NULL)); CuAssertIntEquals(tc, 1, use_manacrystal(u, itype, 1, NULL));

View file

@ -126,7 +126,7 @@ int mage_change_spellpoints(sc_mage *m, int delta)
{ {
if (m) { if (m) {
int val = m->spellpoints + delta; int val = m->spellpoints + delta;
return m->spellpoints = (val > 0) ? val : m->spellpoints; return m->spellpoints = (val >= 0) ? val : m->spellpoints;
} }
return 0; return 0;
} }

View file

@ -182,7 +182,7 @@ void test_getspell_unit(CuTest * tc)
r = test_create_region(0, 0, NULL); r = test_create_region(0, 0, NULL);
f = test_create_faction(NULL); f = test_create_faction(NULL);
u = test_create_unit(f, r); u = test_create_unit(f, r);
create_mage(u, M_GRAY); create_mage(u, M_GWYRRD);
enable_skill(SK_MAGIC, true); enable_skill(SK_MAGIC, true);
set_level(u, SK_MAGIC, 1); set_level(u, SK_MAGIC, 1);
@ -451,7 +451,7 @@ static void test_max_spellpoints(CuTest *tc) {
CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u)); CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u));
rc->maxaura = 200; rc->maxaura = 200;
CuAssertIntEquals(tc, 2, max_spellpoints(u->region, u)); CuAssertIntEquals(tc, 2, max_spellpoints(u->region, u));
create_mage(u, M_GRAY); create_mage(u, M_GWYRRD);
set_level(u, SK_MAGIC, 1); set_level(u, SK_MAGIC, 1);
CuAssertIntEquals(tc, 3, max_spellpoints(u->region, u)); CuAssertIntEquals(tc, 3, max_spellpoints(u->region, u));
set_level(u, SK_MAGIC, 2); set_level(u, SK_MAGIC, 2);

View file

@ -23,7 +23,7 @@ static void test_shock(CuTest *tc) {
test_setup(); test_setup();
shock_setup(); shock_setup();
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
create_mage(u, M_GRAY); create_mage(u, M_GWYRRD);
set_level(u, SK_MAGIC, 5); set_level(u, SK_MAGIC, 5);
set_spellpoints(u, 10); set_spellpoints(u, 10);
u->hp = 10; u->hp = 10;
@ -44,7 +44,7 @@ static void test_shock_low(CuTest *tc) {
test_setup(); test_setup();
shock_setup(); shock_setup();
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
create_mage(u, M_GRAY); create_mage(u, M_GWYRRD);
set_level(u, SK_MAGIC, 5); set_level(u, SK_MAGIC, 5);
set_spellpoints(u, 1); set_spellpoints(u, 1);
u->hp = 1; u->hp = 1;