forked from github/server
enhanced ship speed for selected ships (currently none).
This commit is contained in:
parent
c322fbffd5
commit
b72f48c044
7 changed files with 18 additions and 9 deletions
|
@ -323,6 +323,9 @@ static void json_ship(cJSON *json, ship_type *st) {
|
||||||
if (strcmp(child->string, "range") == 0) {
|
if (strcmp(child->string, "range") == 0) {
|
||||||
st->range = child->valueint;
|
st->range = child->valueint;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(child->string, "maxrange") == 0) {
|
||||||
|
st->range_max = child->valueint;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
log_error("ship %s contains unknown attribute %s", json->string, child->string);
|
log_error("ship %s contains unknown attribute %s", json->string, child->string);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,9 @@ static void test_ships(CuTest * tc)
|
||||||
{
|
{
|
||||||
const char * data = "{\"ships\": { \"boat\" : { "
|
const char * data = "{\"ships\": { \"boat\" : { "
|
||||||
"\"construction\" : { \"maxsize\" : 20, \"reqsize\" : 10, \"minskill\" : 1 },"
|
"\"construction\" : { \"maxsize\" : 20, \"reqsize\" : 10, \"minskill\" : 1 },"
|
||||||
"\"coasts\" : [ \"plain\" ]"
|
"\"coasts\" : [ \"plain\" ],"
|
||||||
|
"\"range\" : 8,"
|
||||||
|
"\"maxrange\" : 16"
|
||||||
"}}}";
|
"}}}";
|
||||||
|
|
||||||
cJSON *json = cJSON_Parse(data);
|
cJSON *json = cJSON_Parse(data);
|
||||||
|
@ -175,6 +177,8 @@ static void test_ships(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, 10, st->construction->reqsize);
|
CuAssertIntEquals(tc, 10, st->construction->reqsize);
|
||||||
CuAssertIntEquals(tc, 20, st->construction->maxsize);
|
CuAssertIntEquals(tc, 20, st->construction->maxsize);
|
||||||
CuAssertIntEquals(tc, 1, st->construction->minskill);
|
CuAssertIntEquals(tc, 1, st->construction->minskill);
|
||||||
|
CuAssertIntEquals(tc, 8, st->range);
|
||||||
|
CuAssertIntEquals(tc, 16, st->range_max);
|
||||||
|
|
||||||
ter = get_terrain("plain");
|
ter = get_terrain("plain");
|
||||||
CuAssertPtrNotNull(tc, ter);
|
CuAssertPtrNotNull(tc, ter);
|
||||||
|
|
|
@ -336,8 +336,11 @@ int shipspeed(const ship * sh, const unit * u)
|
||||||
}
|
}
|
||||||
|
|
||||||
bonus = ShipSpeedBonus(u);
|
bonus = ShipSpeedBonus(u);
|
||||||
if (bonus > 0) {
|
if (bonus > 0 && sh->type->range_max>sh->type->range) {
|
||||||
//
|
int crew = crew_skill(sh);
|
||||||
|
int crew_bonus = (crew / sh->type->sumskill / 2) - 1;
|
||||||
|
bonus = _min(bonus, crew_bonus);
|
||||||
|
bonus = _min(bonus, sh->type->range_max - sh->type->range);
|
||||||
}
|
}
|
||||||
k += bonus;
|
k += bonus;
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ extern "C" {
|
||||||
int shipspeed(const struct ship *sh, const struct unit *u);
|
int shipspeed(const struct ship *sh, const struct unit *u);
|
||||||
int crew_skill(const struct ship *sh);
|
int crew_skill(const struct ship *sh);
|
||||||
|
|
||||||
|
int crew_skill(const struct ship *sh);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -400,8 +400,6 @@ static ship *setup_ship(void) {
|
||||||
ship_type *stype;
|
ship_type *stype;
|
||||||
ship *sh;
|
ship *sh;
|
||||||
|
|
||||||
test_cleanup();
|
|
||||||
test_create_world();
|
|
||||||
r = test_create_region(0, 0, test_create_terrain("ocean", 0));
|
r = test_create_region(0, 0, test_create_terrain("ocean", 0));
|
||||||
stype = test_create_shiptype("longboat");
|
stype = test_create_shiptype("longboat");
|
||||||
stype->cptskill = 1;
|
stype->cptskill = 1;
|
||||||
|
@ -557,7 +555,6 @@ static void test_shipspeed(CuTest *tc) {
|
||||||
set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 11);
|
set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 11);
|
||||||
set_level(cap, SK_SAILING, stype->cptskill + 10);
|
set_level(cap, SK_SAILING, stype->cptskill + 10);
|
||||||
CuAssertIntEquals_Msg(tc, "regular skills should not exceed sh.range", 2, shipspeed(sh, cap));
|
CuAssertIntEquals_Msg(tc, "regular skills should not exceed sh.range", 2, shipspeed(sh, cap));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CuSuite *get_ship_suite(void)
|
CuSuite *get_ship_suite(void)
|
||||||
|
@ -574,6 +571,7 @@ CuSuite *get_ship_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_shipowner_goes_to_other_after_leave);
|
SUITE_ADD_TEST(suite, test_shipowner_goes_to_other_after_leave);
|
||||||
SUITE_ADD_TEST(suite, test_shipowner_goes_to_same_faction_after_leave);
|
SUITE_ADD_TEST(suite, test_shipowner_goes_to_same_faction_after_leave);
|
||||||
SUITE_ADD_TEST(suite, test_shipowner_goes_to_empty_unit_after_leave);
|
SUITE_ADD_TEST(suite, test_shipowner_goes_to_empty_unit_after_leave);
|
||||||
|
SUITE_ADD_TEST(suite, test_crew_skill);
|
||||||
SUITE_ADD_TEST(suite, test_shipspeed);
|
SUITE_ADD_TEST(suite, test_shipspeed);
|
||||||
SUITE_ADD_TEST(suite, test_shipspeed_stormwind);
|
SUITE_ADD_TEST(suite, test_shipspeed_stormwind);
|
||||||
SUITE_ADD_TEST(suite, test_shipspeed_nodrift);
|
SUITE_ADD_TEST(suite, test_shipspeed_nodrift);
|
||||||
|
|
|
@ -509,7 +509,7 @@ static int parse_ships(xmlDocPtr doc)
|
||||||
st->minskill = xml_ivalue(node, "minskill", st->minskill);
|
st->minskill = xml_ivalue(node, "minskill", st->minskill);
|
||||||
st->sumskill = xml_ivalue(node, "sumskill", st->sumskill);
|
st->sumskill = xml_ivalue(node, "sumskill", st->sumskill);
|
||||||
st->range = xml_ivalue(node, "range", st->range);
|
st->range = xml_ivalue(node, "range", st->range);
|
||||||
st->range_max = xml_ivalue(node, "range_max", st->range_max);
|
st->range_max = xml_ivalue(node, "maxrange", st->range_max);
|
||||||
st->storm = xml_fvalue(node, "storm", st->storm);
|
st->storm = xml_fvalue(node, "storm", st->storm);
|
||||||
|
|
||||||
/* reading eressea/ships/ship/construction */
|
/* reading eressea/ships/ship/construction */
|
||||||
|
|
|
@ -469,9 +469,9 @@ static bool cansail(const region * r, ship * sh)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int enoughsailors(const ship * sh, int sumskill)
|
int enoughsailors(const ship * sh, int crew_skill)
|
||||||
{
|
{
|
||||||
return sumskill >= sh->type->sumskill;
|
return crew_skill >= sh->type->sumskill;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in a new issue