From 12a2a1f41265c10d5f0cdf77036bbf51da06e21d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 7 Aug 2015 09:03:19 +0200 Subject: [PATCH] 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. --- src/kernel/ship.h | 2 -- src/kernel/ship.test.c | 15 ++------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/kernel/ship.h b/src/kernel/ship.h index be873ab99..6ba2de75d 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -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 diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c index a32666a5a..380274a45 100644 --- a/src/kernel/ship.test.c +++ b/src/kernel/ship.test.c @@ -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(); }