forked from github/server
test familiar skill bonus
This commit is contained in:
parent
4dee1744a2
commit
b27f0787a8
1 changed files with 32 additions and 0 deletions
|
@ -259,6 +259,10 @@ static void test_skillmod(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 10, effskill(u, SK_ARMORER));
|
||||
a_remove(&u->attribs, a);
|
||||
|
||||
a_add(&u->attribs, a = make_skillmod(NOSKILL, SMF_ALWAYS, 0, 2.0, 0)); // NOSKILL means any skill
|
||||
CuAssertIntEquals(tc, 10, effskill(u, SK_ARMORER));
|
||||
a_remove(&u->attribs, a);
|
||||
|
||||
a_add(&u->attribs, a = make_skillmod(SK_ARMORER, SMF_ALWAYS, 0, 0, 2));
|
||||
CuAssertIntEquals(tc, 7, effskill(u, SK_ARMORER));
|
||||
a_remove(&u->attribs, a);
|
||||
|
@ -294,6 +298,33 @@ static void test_skill_hunger(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, effskill(u, SK_SAILING));
|
||||
}
|
||||
|
||||
static void test_skill_familiar(CuTest *tc) {
|
||||
unit *mag, *fam;
|
||||
region *r;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
// setup two units
|
||||
mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
fam = test_create_unit(mag->faction, test_create_region(0, 0, 0));
|
||||
set_level(fam, SK_PERCEPTION, 6);
|
||||
CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION));
|
||||
set_level(mag, SK_PERCEPTION, 6);
|
||||
CuAssertIntEquals(tc, 6, effskill(mag, SK_PERCEPTION));
|
||||
|
||||
// make them mage and familiar to each other
|
||||
CuAssertIntEquals(tc, true, create_newfamiliar(mag, fam));
|
||||
|
||||
// when they are in the same region, the mage gets half their skill as a bonus
|
||||
CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION));
|
||||
CuAssertIntEquals(tc, 9, effskill(mag, SK_PERCEPTION));
|
||||
|
||||
// when they are further apart, divide bonus by distance
|
||||
r = test_create_region(3, 0, 0);
|
||||
move_unit(fam, r, &r->units);
|
||||
CuAssertIntEquals(tc, 7, effskill(mag, SK_PERCEPTION));
|
||||
}
|
||||
|
||||
CuSuite *get_unit_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
@ -310,5 +341,6 @@ CuSuite *get_unit_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_default_name);
|
||||
SUITE_ADD_TEST(suite, test_skillmod);
|
||||
SUITE_ADD_TEST(suite, test_skill_hunger);
|
||||
SUITE_ADD_TEST(suite, test_skill_familiar);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue