get_captain is wrong, the rules say the captain is the FIRST unit in the ship, which I believe means ship_owner, not best skill.

clean up shipspeed tests a little (WIP, missing edge cases).
ignore some temporary files.
This commit is contained in:
Enno Rehling 2015-08-07 09:03:19 +02:00
parent 5537f0ac68
commit 12a2a1f412
2 changed files with 2 additions and 15 deletions

View File

@ -126,8 +126,6 @@ extern "C" {
void ship_setname(struct ship *self, const char *name);
int shipspeed(const struct ship *sh, const struct unit *u);
int crew_skill(const struct ship *sh);
int crew_skill(const struct ship *sh);
#ifdef __cplusplus
}
#endif

View File

@ -398,7 +398,6 @@ static void test_crew_skill(CuTest *tc) {
static ship *setup_ship(void) {
region *r;
ship_type *stype;
ship *sh;
set_param(&global.parameters, "movement.shipspeed.skillbonus", "0");
r = test_create_region(0, 0, test_create_terrain("ocean", 0));
@ -408,8 +407,7 @@ static ship *setup_ship(void) {
stype->minskill = 1;
stype->range = 2;
stype->range_max = 4;
sh = test_create_ship(r, stype);
return sh;
return test_create_ship(r, stype);
}
static void setup_crew(ship *sh, struct faction *f, unit **cap, unit **crew) {
@ -524,26 +522,18 @@ static void test_shipspeed(CuTest *tc) {
ship *sh;
const ship_type *stype;
region *r;
struct faction *f;
unit *cap, *crew;
test_cleanup();
sh = setup_ship();
r = sh->region;
f = test_create_faction(0);
assert(r && f);
stype = sh->type;
CuAssertIntEquals_Msg(tc, "ship without a captain cannot move", 0, shipspeed(sh, NULL));
cap = test_create_unit(f, r);
crew = test_create_unit(f, r);
cap->ship = sh;
crew->ship = sh;
setup_crew(sh, 0, &cap, &crew);
CuAssertPtrEquals(tc, cap, ship_owner(sh));
set_level(cap, SK_SAILING, stype->cptskill);
set_level(crew, SK_SAILING, stype->sumskill - stype->cptskill);
CuAssertIntEquals_Msg(tc, "ship with fully skilled crew can sail at max speed", 2, shipspeed(sh, cap));
CuAssertIntEquals_Msg(tc, "shipspeed without a hint defaults to captain", 2, shipspeed(sh, NULL));
@ -587,7 +577,6 @@ static void test_shipspeed_max_range(CuTest *tc) {
set_level(cap, SK_SAILING, stype->cptskill + 15);
set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 15);
CuAssertIntEquals_Msg(tc, "skill-bonus cannot exceed max_range", 4, shipspeed(sh, cap));
test_cleanup();
}