BUG 2361: familiars cannot forget magic.

https://bugs.eressea.de/view.php?id=2361
This commit is contained in:
Enno Rehling 2017-08-27 19:55:04 +02:00
parent aa27c91a6e
commit 8517857d55
2 changed files with 23 additions and 1 deletions

View File

@ -11,6 +11,23 @@ function setup()
eressea.settings.set("rules.encounters", "0")
end
function test_bug_2361_forget_magic()
-- https://bugs.eressea.de/view.php?id=2361
-- familiars cannot forget magic
local r = region.create(0, 0, "plain")
local f = faction.create("human")
local u = unit.create(f, r, 1)
u:clear_orders()
u:add_order("VERGESSE Magie")
u:set_skill('magic', 5)
u.race = 'unicorn'
process_orders()
assert_equal(5, u:get_skill('magic'))
u.race = 'human'
process_orders()
assert_equal(0, u:get_skill('magic'))
end
function test_mine_bonus()
local r = region.create(0, 0, "mountain")
r:set_resource("iron", 100)

View File

@ -661,7 +661,12 @@ static int forget_cmd(unit * u, order * ord)
init_order(ord);
s = gettoken(token, sizeof(token));
if ((sk = get_skill(s, u->faction->locale)) != NOSKILL) {
sk = get_skill(s, u->faction->locale);
if (sk != NOSKILL) {
if (sk == SK_MAGIC && (u_race(u)->flags & RCF_FAMILIAR)) {
/* some races cannot forget their innate magical abilities */
return 0;
}
ADDMSG(&u->faction->msgs, msg_message("forget", "unit skill", u, sk));
set_level(u, sk, 0);
}