forked from github/server
spells can only be cast on single ships.
This commit is contained in:
parent
43094e8bf9
commit
1e0afdc961
7 changed files with 105 additions and 5 deletions
|
@ -2768,12 +2768,18 @@ msgstr "\"$unit($unit) verspeiste $int($amount) Bauern.\""
|
|||
msgid "error320"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit kann nicht bewachen, da sie versucht zu fliehen.\""
|
||||
|
||||
msgid "error321"
|
||||
msgid "error325"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Der Zauber kann nur auf ein einzelnes Schiff gewirkt werden.\""
|
||||
|
||||
msgid "error324"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit gehört nicht zu unserer Partei.\""
|
||||
|
||||
msgid "error322"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist bereits auf einem Schiff.\""
|
||||
|
||||
msgid "error323"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist verzaubert.\""
|
||||
|
||||
msgid "dissolve_units_2"
|
||||
msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) $if($eq($number,1),\"wurde zum Baum\", \"wurden zu Bäumen\").\""
|
||||
|
||||
|
|
|
@ -2768,6 +2768,18 @@ msgstr "\"$unit($unit) ate $int($amount) peasants.\""
|
|||
msgid "error320"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit cannot guard the region because it is trying to flee.\""
|
||||
|
||||
msgid "error325"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Spells can only be cast on a single ship.\""
|
||||
|
||||
msgid "error324"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\""
|
||||
|
||||
msgid "error322"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is already on a ship.\""
|
||||
|
||||
msgid "error323"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The ship is under a spell.\""
|
||||
|
||||
msgid "dissolve_units_2"
|
||||
msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) turned into $if($eq($number,1),\"a tree\", \"trees\").\""
|
||||
|
||||
|
|
|
@ -177,6 +177,22 @@ function test_give_ship()
|
|||
assert_equal(1, u2.ship.number)
|
||||
end
|
||||
|
||||
function test_give_ship_only_to_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')
|
||||
u3.ship = u2.ship
|
||||
u1.ship = ship.create(r, 'boat')
|
||||
u1.ship.number = 2
|
||||
u1:add_order("GIB " .. itoa36(u3.id) .. " 1 SCHIFF")
|
||||
process_orders()
|
||||
assert_equal(2, u1.ship.number)
|
||||
assert_equal(1, u2.ship.number)
|
||||
end
|
||||
|
||||
function test_give_ship_merge()
|
||||
local r = region.create(1, 0, 'ocean')
|
||||
local f = faction.create("human")
|
||||
|
@ -227,15 +243,17 @@ end
|
|||
|
||||
function test_give_ship_all_ships()
|
||||
local r = region.create(1, 0, 'plain')
|
||||
local f = faction.create("human")
|
||||
local f = faction.create("human", 'noreply@vg.no')
|
||||
local u1 = unit.create(f, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
u1.ship = ship.create(r, 'boat')
|
||||
u1.ship.damage = 2
|
||||
u1.ship.number = 2
|
||||
u2.ship = ship.create(r, 'boat')
|
||||
u2.ship.number = 1
|
||||
u1:add_order("GIB " .. itoa36(u2.id) .. " 2 SCHIFF")
|
||||
process_orders()
|
||||
write_reports()
|
||||
assert_equal(3, u2.ship.number)
|
||||
assert_equal(u2.ship, u1.ship)
|
||||
end
|
||||
|
@ -254,3 +272,46 @@ function test_give_ship_self_only()
|
|||
assert_equal(2, u1.ship.number)
|
||||
assert_equal(nil, u2.ship)
|
||||
end
|
||||
|
||||
function test_give_ship_not_cursed()
|
||||
local r = region.create(1, 0, 'plain')
|
||||
local f = faction.create("human")
|
||||
local u = unit.create(f, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
local sh = ship.create(r, 'boat')
|
||||
u.ship = sh
|
||||
u:add_item("speedsail", 1)
|
||||
u:add_order("BENUTZE 1 Sonnensegel")
|
||||
process_orders()
|
||||
u:clear_orders()
|
||||
assert_equal(1, sh:get_curse('shipspeedup'))
|
||||
|
||||
u:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF")
|
||||
process_orders()
|
||||
assert_equal(nil, u2.ship)
|
||||
end
|
||||
|
||||
function test_speedsail_on_ship()
|
||||
local r = region.create(1, 0, 'plain')
|
||||
local f = faction.create("human")
|
||||
local u = unit.create(f, r, 1)
|
||||
local sh = ship.create(r, 'boat')
|
||||
u.ship = sh
|
||||
u:add_item("speedsail", 1)
|
||||
u:add_order("BENUTZE 1 Sonnensegel")
|
||||
process_orders()
|
||||
assert_equal(1, sh:get_curse('shipspeedup'))
|
||||
end
|
||||
|
||||
function test_no_speedsail_on_convoy()
|
||||
local r = region.create(1, 0, 'plain')
|
||||
local f = faction.create("human")
|
||||
local u = unit.create(f, r, 1)
|
||||
local sh = ship.create(r, 'boat')
|
||||
u.ship = sh
|
||||
sh.number = 2
|
||||
u:add_item("speedsail", 2)
|
||||
u:add_order("BENUTZE 2 Sonnensegel")
|
||||
process_orders()
|
||||
assert_equal(nil, sh:get_curse('shipspeedup'))
|
||||
end
|
||||
|
|
14
src/give.c
14
src/give.c
|
@ -314,15 +314,24 @@ static void transfer_units(ship *s1, ship *s2)
|
|||
}
|
||||
}
|
||||
|
||||
static bool ship_cursed(const ship *sh) {
|
||||
return a_find(sh->attribs, &at_curse) != NULL;
|
||||
}
|
||||
|
||||
message * give_ship(unit *u1, unit *u2, int n, order *ord)
|
||||
{
|
||||
assert(u1->ship);
|
||||
assert(n > 0 && n <= u1->ship->number);
|
||||
if (u1->faction != u2->faction) {
|
||||
return msg_error(u1, ord, 321);
|
||||
return msg_error(u1, ord, 324);
|
||||
}
|
||||
if (ship_cursed(u1->ship)) {
|
||||
return msg_error(u1, ord, 323);
|
||||
}
|
||||
/* TODO: when transferring all ships, unit must hop on the target ship */
|
||||
if (u2->ship) {
|
||||
if (ship_cursed(u2->ship)) {
|
||||
return msg_error(u1, ord, 323);
|
||||
}
|
||||
if (n < u1->ship->number) {
|
||||
if (u2->ship->type != u1->ship->type) {
|
||||
return msg_error(u1, ord, 322);
|
||||
|
@ -892,6 +901,7 @@ void give_cmd(unit * u, order * ord)
|
|||
else {
|
||||
cmistake(u, ord, 144, MSG_COMMERCE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (p == P_PERSON) {
|
||||
if (!(u_race(u)->ec_flags & ECF_GIVEPERSON)) {
|
||||
|
|
|
@ -101,6 +101,10 @@ struct order *ord)
|
|||
cmistake(u, ord, 20, MSG_MOVE);
|
||||
return -1;
|
||||
}
|
||||
if (sh->number > 1) {
|
||||
cmistake(u, ord, 325, MSG_MAGIC);
|
||||
return -1;
|
||||
}
|
||||
|
||||
effect = SPEEDSAIL_EFFECT;
|
||||
create_curse(u, &sh->attribs, &ct_shipspeedup, 20, INT_MAX, effect, 0);
|
||||
|
|
|
@ -314,7 +314,6 @@ int shipspeed(const ship * sh, const unit * u)
|
|||
if (!ship_finished(sh)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sh->attribs) {
|
||||
if (curse_active(get_curse(sh->attribs, &ct_stormwind))) {
|
||||
k *= 2;
|
||||
|
|
|
@ -808,6 +808,10 @@ static int sp_goodwinds(castorder * co)
|
|||
return 0;
|
||||
|
||||
sh = pa->param[0]->data.sh;
|
||||
if (sh->number > 1) {
|
||||
cmistake(caster, co->order, 325, MSG_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* keine Probleme mit C_SHIP_SPEEDUP und C_SHIP_FLYING */
|
||||
/* NODRIFT bewirkt auch +1 Geschwindigkeit */
|
||||
|
@ -2231,6 +2235,10 @@ static int sp_stormwinds(castorder * co)
|
|||
|
||||
sh = pa->param[n]->data.sh;
|
||||
|
||||
if (sh->number > 1) {
|
||||
cmistake(caster, co->order, 325, MSG_MAGIC);
|
||||
continue;
|
||||
}
|
||||
if (is_cursed(sh->attribs, &ct_flyingship)) {
|
||||
ADDMSG(&caster->faction->msgs, msg_feedback(caster, co->order,
|
||||
"error_spell_on_flying_ship", "ship", sh))
|
||||
|
|
Loading…
Reference in a new issue