forked from github/server
BUG 2387 some tweaks to the first draft.
This commit is contained in:
parent
c7a65116be
commit
4eb4c61d37
3 changed files with 15 additions and 7 deletions
|
@ -957,7 +957,7 @@
|
|||
<skill name="unarmed" modifier="-99"/>
|
||||
<attack type="1" damage="0d0"/>
|
||||
</race>
|
||||
<race name="template" magres="100" maxaura="0.000000" regaura="0.000000" weight="0" capacity="1000" speed="10.000000" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" shapeshiftany="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
|
||||
<race name="template" maintenance="0" magres="100" maxaura="0.000000" regaura="0.000000" weight="0" capacity="1000" speed="10.000000" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" shapeshiftany="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
|
||||
<ai splitsize="10000" moverandom="yes" learn="yes"/>
|
||||
<attack type="1" damage="1d4"/>
|
||||
</race>
|
||||
|
|
|
@ -406,10 +406,9 @@ void save_special_items(unit *usrc)
|
|||
faction *fm = get_monsters();
|
||||
static const race *rc_ghost;
|
||||
static int cache;
|
||||
static const char *name = NULL;
|
||||
|
||||
if (rc_changed(&cache)) {
|
||||
rc_ghost = get_race(RC_TEMPLATE);
|
||||
name = "ghost";
|
||||
}
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->faction == fm) {
|
||||
|
@ -418,9 +417,12 @@ void save_special_items(unit *usrc)
|
|||
}
|
||||
}
|
||||
u = create_unit(r, fm, 1, rc_ghost, 0, NULL, NULL);
|
||||
if (name) {
|
||||
set_racename(&u->attribs, name);
|
||||
unit_setname(u, unit_getname(usrc));
|
||||
if (usrc->number > 1) {
|
||||
/* some units have plural names, it would be neat if they aren't single: */
|
||||
scale_number(u, 2);
|
||||
}
|
||||
set_racename(&u->attribs, "ghost");
|
||||
give_special_items(u, &usrc->items);
|
||||
}
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ static void test_set_email(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_items_notlost(CuTest *tc) {
|
||||
static void test_save_special_items(CuTest *tc) {
|
||||
unit *u, *ug;
|
||||
race * rc;
|
||||
struct item_type *itype, *it_silver, *it_horse;
|
||||
|
@ -266,16 +266,21 @@ static void test_items_notlost(CuTest *tc) {
|
|||
rc = test_create_race("template");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
i_change(&u->items, itype, 1);
|
||||
|
||||
/* when there is no monster in the region, a ghost of the dead unit is created: */
|
||||
save_special_items(u);
|
||||
CuAssertPtrNotNull(tc, u->next);
|
||||
ug = u->next;
|
||||
CuAssertPtrEquals(tc, NULL, ug->next);
|
||||
CuAssertPtrEquals(tc, rc, (void *)ug->_race);
|
||||
CuAssertIntEquals(tc, 1, u->number);
|
||||
CuAssertIntEquals(tc, 0, i_get(u->items, itype));
|
||||
CuAssertIntEquals(tc, 1, i_get(ug->items, itype));
|
||||
CuAssertStrEquals(tc, "ghost", get_racename(ug->attribs));
|
||||
CuAssertStrEquals(tc, u->_name, ug->_name);
|
||||
|
||||
i_change(&u->items, itype, 1);
|
||||
/* when there is a monster, it takes all special items: */
|
||||
save_special_items(u);
|
||||
CuAssertPtrEquals(tc, NULL, ug->next);
|
||||
CuAssertIntEquals(tc, 2, i_get(ug->items, itype));
|
||||
|
@ -284,6 +289,7 @@ static void test_items_notlost(CuTest *tc) {
|
|||
i_change(&u->items, itype, 1);
|
||||
i_change(&u->items, it_horse, 5);
|
||||
i_change(&u->items, it_silver, 10);
|
||||
/* horses and money need to go to the region and are not taken: */
|
||||
save_special_items(u);
|
||||
CuAssertIntEquals(tc, 3, i_get(ug->items, itype));
|
||||
CuAssertIntEquals(tc, 5, i_get(u->items, it_horse));
|
||||
|
@ -306,6 +312,6 @@ CuSuite *get_faction_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_check_passwd);
|
||||
SUITE_ADD_TEST(suite, test_valid_race);
|
||||
SUITE_ADD_TEST(suite, test_set_email);
|
||||
SUITE_ADD_TEST(suite, test_items_notlost);
|
||||
SUITE_ADD_TEST(suite, test_save_special_items);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue