Schiffstransfer nur zwischen Kapitänen.

This commit is contained in:
Enno Rehling 2019-10-08 21:14:01 +02:00
parent 1e0afdc961
commit 24978a5b80
2 changed files with 24 additions and 2 deletions

View File

@ -183,16 +183,32 @@ function test_give_ship_only_to_captain()
local u1 = unit.create(f, r, 1) local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, r, 1) local u3 = unit.create(f, r, 1)
u2.ship = ship.create(r, 'boat')
u3.ship = u2.ship
u1.ship = ship.create(r, 'boat') u1.ship = ship.create(r, 'boat')
u1.ship.number = 2 u1.ship.number = 2
u2.ship = ship.create(r, 'boat')
u3.ship = u2.ship
u1:add_order("GIB " .. itoa36(u3.id) .. " 1 SCHIFF") u1:add_order("GIB " .. itoa36(u3.id) .. " 1 SCHIFF")
process_orders() process_orders()
assert_equal(2, u1.ship.number) assert_equal(2, u1.ship.number)
assert_equal(1, u2.ship.number) assert_equal(1, u2.ship.number)
end end
function test_give_ship_only_from_captain()
local r = region.create(1, 0, 'ocean')
local f = faction.create("human")
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, r, 1)
u2.ship = ship.create(r, 'boat')
u1.ship = ship.create(r, 'boat')
u1.ship.number = 2
u3.ship = u1.ship
u3:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF")
process_orders()
assert_equal(2, u1.ship.number)
assert_equal(1, u2.ship.number)
end
function test_give_ship_merge() function test_give_ship_merge()
local r = region.create(1, 0, 'ocean') local r = region.create(1, 0, 'ocean')
local f = faction.create("human") local f = faction.create("human")

View File

@ -328,7 +328,13 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord)
if (ship_cursed(u1->ship)) { if (ship_cursed(u1->ship)) {
return msg_error(u1, ord, 323); return msg_error(u1, ord, 323);
} }
if (u1 != ship_owner(u1->ship)) {
return msg_error(u1, ord, 146);
}
if (u2->ship) { if (u2->ship) {
if (u2 != ship_owner(u2->ship)) {
return msg_error(u1, ord, 146);
}
if (ship_cursed(u2->ship)) { if (ship_cursed(u2->ship)) {
return msg_error(u1, ord, 323); return msg_error(u1, ord, 323);
} }