forked from github/server
Merge branch 'develop' of github.com:ennorehling/eressea into develop
This commit is contained in:
commit
9b2e33f044
|
@ -1,6 +1,6 @@
|
||||||
|
require 'tests.e2.movement'
|
||||||
require 'tests.e2.carts'
|
require 'tests.e2.carts'
|
||||||
require 'tests.e2.quit'
|
require 'tests.e2.quit'
|
||||||
require 'tests.e2.movement'
|
|
||||||
require 'tests.e2.astral'
|
require 'tests.e2.astral'
|
||||||
require 'tests.e2.spells'
|
require 'tests.e2.spells'
|
||||||
require 'tests.e2.e2features'
|
require 'tests.e2.e2features'
|
||||||
|
|
|
@ -5,11 +5,40 @@ module("tests.e2.movement", package.seeall, lunit.testcase)
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
eressea.settings.set("rules.food.flags", "4")
|
eressea.settings.set("rules.food.flags", "4")
|
||||||
|
eressea.settings.set("rules.ship.damage.nocrewocean", "0")
|
||||||
|
eressea.settings.set("rules.ship.damage.nocrew", "0")
|
||||||
|
eressea.settings.set("rules.ship.drifting", "0")
|
||||||
|
eressea.settings.set("rules.ship.storms", "0")
|
||||||
eressea.settings.set("nmr.timeout", "0")
|
eressea.settings.set("nmr.timeout", "0")
|
||||||
eressea.settings.set("NewbieImmunity", "0")
|
eressea.settings.set("NewbieImmunity", "0")
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_piracy()
|
function test_piracy()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local r2 = region.create(1, 0, "ocean")
|
||||||
|
local r3 = region.create(-1, 0, "ocean")
|
||||||
|
local f = faction.create("human", "pirate@eressea.de", "de")
|
||||||
|
local f2 = faction.create("human", "elf@eressea.de", "de")
|
||||||
|
local u1 = unit.create(f, r2, 1)
|
||||||
|
local u2 = unit.create(f2, r3, 1)
|
||||||
|
|
||||||
|
u1.ship = ship.create(r2, "longboat")
|
||||||
|
u2.ship = ship.create(r3, "longboat")
|
||||||
|
u1:set_skill("sailing", 10)
|
||||||
|
u2:set_skill("sailing", 10)
|
||||||
|
|
||||||
|
u1:clear_orders()
|
||||||
|
u1:add_order("PIRATERIE")
|
||||||
|
u2:clear_orders()
|
||||||
|
u2:add_order("NACH o")
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
|
||||||
|
assert_equal(r, u2.region) -- Nach Osten
|
||||||
|
assert_equal(r, u1.region) -- Entern!
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_piracy_to_land()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local r2 = region.create(1, 0, "plain")
|
local r2 = region.create(1, 0, "plain")
|
||||||
local r3 = region.create(-1, 0, "ocean")
|
local r3 = region.create(-1, 0, "ocean")
|
||||||
|
@ -30,10 +59,8 @@ function test_piracy()
|
||||||
|
|
||||||
process_orders()
|
process_orders()
|
||||||
|
|
||||||
if r2~=u1.region then
|
assert_equal(r, u2.region) -- Nach Osten
|
||||||
write_reports()
|
assert_equal(r2, u1.region) -- bewegt sich nicht
|
||||||
end
|
|
||||||
assert_equal(r2, u1.region) -- should pass, but fails!!!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_dolphin_on_land()
|
function test_dolphin_on_land()
|
||||||
|
|
|
@ -407,24 +407,21 @@ int crew_skill(const ship *sh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ship_crewed(const ship *sh) {
|
bool ship_crewed(const ship *sh) {
|
||||||
unit *u;
|
unit *u, *cap = ship_owner(sh);
|
||||||
int capskill = -1, sumskill = 0;
|
int capskill = -1, sumskill = 0;
|
||||||
for (u = sh->region->units; u; u = u->next) {
|
for (u = sh->region->units; u; u = u->next) {
|
||||||
if (u->ship == sh) {
|
if (u->ship == sh) {
|
||||||
int es = effskill(u, SK_SAILING, NULL);
|
int es = effskill(u, SK_SAILING, NULL);
|
||||||
if (capskill < 0) {
|
if (es > 0) {
|
||||||
if (u->number >= sh->number) {
|
if (u == cap && u->number >= sh->number) {
|
||||||
capskill = es;
|
capskill = es;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
capskill = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (es >= sh->type->minskill) {
|
if (es >= sh->type->minskill) {
|
||||||
sumskill += es * u->number;
|
sumskill += es * u->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return (capskill >= ship_captain_minskill(sh)) && (sumskill >= sh->type->sumskill * sh->number);
|
return (capskill >= ship_captain_minskill(sh)) && (sumskill >= sh->type->sumskill * sh->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,58 @@ static void test_register_ship(CuTest * tc)
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_ship_crewed(CuTest * tc)
|
||||||
|
{
|
||||||
|
struct region *r;
|
||||||
|
struct faction *f;
|
||||||
|
struct ship *sh;
|
||||||
|
struct unit *u1, *u2;
|
||||||
|
struct ship_type *stype;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
r = test_create_ocean(0, 0);
|
||||||
|
stype = test_create_shiptype("longboat");
|
||||||
|
stype->cptskill = 2;
|
||||||
|
stype->sumskill = 4;
|
||||||
|
sh = test_create_ship(r, stype);
|
||||||
|
CuAssertTrue(tc, !ship_crewed(sh));
|
||||||
|
u1 = test_create_unit(f, r);
|
||||||
|
set_level(u1, SK_SAILING, 4);
|
||||||
|
u_set_ship(u1, sh);
|
||||||
|
CuAssertTrue(tc, ship_crewed(sh));
|
||||||
|
u2 = test_create_unit(f, r);
|
||||||
|
set_level(u1, SK_SAILING, 2);
|
||||||
|
set_level(u2, SK_SAILING, 2);
|
||||||
|
u_set_ship(u2, sh);
|
||||||
|
CuAssertTrue(tc, ship_crewed(sh));
|
||||||
|
set_level(u1, SK_SAILING, 1);
|
||||||
|
set_level(u2, SK_SAILING, 2);
|
||||||
|
CuAssertTrue(tc, !ship_crewed(sh));
|
||||||
|
set_level(u1, SK_SAILING, 2);
|
||||||
|
set_level(u2, SK_SAILING, 1);
|
||||||
|
CuAssertTrue(tc, !ship_crewed(sh));
|
||||||
|
set_level(u1, SK_SAILING, 3);
|
||||||
|
set_level(u2, SK_SAILING, 1);
|
||||||
|
CuAssertTrue(tc, ship_crewed(sh));
|
||||||
|
stype->minskill = 2;
|
||||||
|
CuAssertTrue(tc, !ship_crewed(sh));
|
||||||
|
set_level(u1, SK_SAILING, 2);
|
||||||
|
set_level(u2, SK_SAILING, 2);
|
||||||
|
CuAssertTrue(tc, ship_crewed(sh));
|
||||||
|
sh->number = 2;
|
||||||
|
CuAssertTrue(tc, !ship_crewed(sh));
|
||||||
|
set_level(u1, SK_SAILING, 4);
|
||||||
|
set_level(u2, SK_SAILING, 4);
|
||||||
|
CuAssertTrue(tc, !ship_crewed(sh));
|
||||||
|
u1->number = 2;
|
||||||
|
set_level(u1, SK_SAILING, 2);
|
||||||
|
set_level(u2, SK_SAILING, 4);
|
||||||
|
CuAssertTrue(tc, ship_crewed(sh));
|
||||||
|
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_ship_set_owner(CuTest * tc)
|
static void test_ship_set_owner(CuTest * tc)
|
||||||
{
|
{
|
||||||
struct region *r;
|
struct region *r;
|
||||||
|
@ -665,6 +717,7 @@ CuSuite *get_ship_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_register_ship);
|
SUITE_ADD_TEST(suite, test_register_ship);
|
||||||
SUITE_ADD_TEST(suite, test_stype_defaults);
|
SUITE_ADD_TEST(suite, test_stype_defaults);
|
||||||
SUITE_ADD_TEST(suite, test_ship_set_owner);
|
SUITE_ADD_TEST(suite, test_ship_set_owner);
|
||||||
|
SUITE_ADD_TEST(suite, test_ship_crewed);
|
||||||
SUITE_ADD_TEST(suite, test_shipowner_resets_when_empty);
|
SUITE_ADD_TEST(suite, test_shipowner_resets_when_empty);
|
||||||
SUITE_ADD_TEST(suite, test_shipowner_goes_to_next_when_empty);
|
SUITE_ADD_TEST(suite, test_shipowner_goes_to_next_when_empty);
|
||||||
SUITE_ADD_TEST(suite, test_shipowner_goes_to_other_when_empty);
|
SUITE_ADD_TEST(suite, test_shipowner_goes_to_other_when_empty);
|
||||||
|
|
12
src/move.c
12
src/move.c
|
@ -696,18 +696,17 @@ int check_ship_allowed(struct ship *sh, const region * r)
|
||||||
return SA_NO_COAST;
|
return SA_NO_COAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_coast(ship * sh, region * r, region * rnext)
|
static enum direction_t set_coast(ship * sh, region * r, region * rnext)
|
||||||
{
|
{
|
||||||
if (sh->type->flags & SFL_NOCOAST) {
|
if (sh->type->flags & SFL_NOCOAST) {
|
||||||
sh->coast = NODIRECTION;
|
return sh->coast = NODIRECTION;
|
||||||
}
|
}
|
||||||
else if (!fval(rnext->terrain, SEA_REGION) && !flying_ship(sh)) {
|
else if (!fval(rnext->terrain, SEA_REGION) && !flying_ship(sh)) {
|
||||||
sh->coast = reldirection(rnext, r);
|
if (fval(r->terrain, SEA_REGION)) {
|
||||||
assert(fval(r->terrain, SEA_REGION));
|
return sh->coast = reldirection(rnext, r);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
sh->coast = NODIRECTION;
|
|
||||||
}
|
}
|
||||||
|
return sh->coast = NODIRECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double overload_start(void) {
|
static double overload_start(void) {
|
||||||
|
@ -1923,7 +1922,6 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
||||||
replace_order(&u->orders, ord, norder);
|
replace_order(&u->orders, ord, norder);
|
||||||
free_order(norder);
|
free_order(norder);
|
||||||
}
|
}
|
||||||
set_order(&u->thisorder, NULL);
|
|
||||||
set_coast(sh, last_point, current_point);
|
set_coast(sh, last_point, current_point);
|
||||||
|
|
||||||
if (is_cursed(sh->attribs, &ct_flyingship)) {
|
if (is_cursed(sh->attribs, &ct_flyingship)) {
|
||||||
|
|
Loading…
Reference in New Issue