forked from github/server
2582 WIP: failing test for regenerate_aura
This commit is contained in:
parent
ba457e2df5
commit
a35a0ca516
3 changed files with 31 additions and 6 deletions
|
@ -651,12 +651,13 @@ int max_spellpoints(const struct unit *u, const region * r)
|
||||||
const sc_mage *m;
|
const sc_mage *m;
|
||||||
|
|
||||||
assert(u);
|
assert(u);
|
||||||
|
m = get_mage(u);
|
||||||
|
if (!m) return 0;
|
||||||
if (!r) r = u->region;
|
if (!r) r = u->region;
|
||||||
|
|
||||||
sk = effskill(u, SK_MAGIC, r);
|
sk = effskill(u, SK_MAGIC, r);
|
||||||
msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1);
|
msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1);
|
||||||
m = get_mage(u);
|
msp += m->spchange;
|
||||||
if (m) msp += m->spchange;
|
|
||||||
|
|
||||||
rtype = rt_find("aurafocus");
|
rtype = rt_find("aurafocus");
|
||||||
if (rtype && i_get(u->items, rtype->itype) > 0) {
|
if (rtype && i_get(u->items, rtype->itype) > 0) {
|
||||||
|
|
|
@ -446,14 +446,14 @@ static void test_max_spellpoints(CuTest *tc) {
|
||||||
test_setup();
|
test_setup();
|
||||||
rc = test_create_race("human");
|
rc = test_create_race("human");
|
||||||
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
||||||
CuAssertIntEquals(tc, 1, max_spellpoints_depr(u->region, u));
|
CuAssertIntEquals(tc, 0, max_spellpoints_depr(u->region, u));
|
||||||
CuAssertIntEquals(tc, 1, max_spellpoints(u, u->region));
|
CuAssertIntEquals(tc, 0, max_spellpoints(u, u->region));
|
||||||
CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL));
|
CuAssertIntEquals(tc, 0, max_spellpoints(u, NULL));
|
||||||
|
create_mage(u, M_GWYRRD);
|
||||||
rc->maxaura = 100;
|
rc->maxaura = 100;
|
||||||
CuAssertIntEquals(tc, 1, max_spellpoints(u, u->region));
|
CuAssertIntEquals(tc, 1, max_spellpoints(u, u->region));
|
||||||
rc->maxaura = 200;
|
rc->maxaura = 200;
|
||||||
CuAssertIntEquals(tc, 2, max_spellpoints(u, u->region));
|
CuAssertIntEquals(tc, 2, max_spellpoints(u, u->region));
|
||||||
create_mage(u, M_GWYRRD);
|
|
||||||
set_level(u, SK_MAGIC, 1);
|
set_level(u, SK_MAGIC, 1);
|
||||||
CuAssertIntEquals(tc, 3, max_spellpoints(u, u->region));
|
CuAssertIntEquals(tc, 3, max_spellpoints(u, u->region));
|
||||||
set_level(u, SK_MAGIC, 2);
|
set_level(u, SK_MAGIC, 2);
|
||||||
|
@ -484,6 +484,27 @@ static void test_regenerate_aura(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 1, get_spellpoints(u));
|
CuAssertIntEquals(tc, 1, get_spellpoints(u));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for Bug 2582.
|
||||||
|
*
|
||||||
|
* Migrant units that are not familiars, but whose race has a maxaura
|
||||||
|
* must not regenerate aura.
|
||||||
|
*/
|
||||||
|
static void test_regenerate_aura_migrants(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
race *rc;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
test_teardown();
|
||||||
|
rc = test_create_race("demon");
|
||||||
|
rc->maxaura = 100;
|
||||||
|
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||||
|
u_setrace(u, rc);
|
||||||
|
CuAssertIntEquals(tc, 0, get_spellpoints(u));
|
||||||
|
regenerate_aura();
|
||||||
|
CuAssertIntEquals(tc, 0, get_spellpoints(u));
|
||||||
|
}
|
||||||
|
|
||||||
static void test_illusioncastle(CuTest *tc)
|
static void test_illusioncastle(CuTest *tc)
|
||||||
{
|
{
|
||||||
building *b;
|
building *b;
|
||||||
|
@ -635,5 +656,6 @@ CuSuite *get_magic_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_max_spellpoints);
|
SUITE_ADD_TEST(suite, test_max_spellpoints);
|
||||||
SUITE_ADD_TEST(suite, test_illusioncastle);
|
SUITE_ADD_TEST(suite, test_illusioncastle);
|
||||||
SUITE_ADD_TEST(suite, test_regenerate_aura);
|
SUITE_ADD_TEST(suite, test_regenerate_aura);
|
||||||
|
SUITE_ADD_TEST(suite, test_regenerate_aura_migrants);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,6 +239,7 @@ static void move_iceberg(region * r)
|
||||||
"region dir", r, dir));
|
"region dir", r, dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats_count("iceberg.drift", 1);
|
||||||
x = r->x;
|
x = r->x;
|
||||||
y = r->y;
|
y = r->y;
|
||||||
|
|
||||||
|
@ -379,6 +380,7 @@ static void create_icebergs(void)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
r->terrain = t_iceberg;
|
r->terrain = t_iceberg;
|
||||||
|
stats_count("iceberg.terraform", 1);
|
||||||
|
|
||||||
fset(r, RF_SELECT);
|
fset(r, RF_SELECT);
|
||||||
move_iceberg(r);
|
move_iceberg(r);
|
||||||
|
|
Loading…
Reference in a new issue