forked from github/server
WIP bug 2737
fix cost of spells with ring of power. test and fix cost and limits of familiars casting spells.
This commit is contained in:
parent
5564543bfd
commit
c8e975333b
6 changed files with 32 additions and 11 deletions
|
@ -7,6 +7,7 @@ require 'tests.e2.carts'
|
||||||
require 'tests.e2.astral'
|
require 'tests.e2.astral'
|
||||||
require 'tests.e2.spells'
|
require 'tests.e2.spells'
|
||||||
require 'tests.e2.migration'
|
require 'tests.e2.migration'
|
||||||
|
require 'tests.e2.familiars'
|
||||||
require 'tests.e2.e2features'
|
require 'tests.e2.e2features'
|
||||||
require 'tests.e2.insects'
|
require 'tests.e2.insects'
|
||||||
require 'tests.e2.production'
|
require 'tests.e2.production'
|
||||||
|
|
|
@ -181,7 +181,7 @@ function test_familiar()
|
||||||
local f = faction.create("human")
|
local f = faction.create("human")
|
||||||
local u = unit.create(f, r)
|
local u = unit.create(f, r)
|
||||||
local uid = u.id
|
local uid = u.id
|
||||||
u.name = 'Hodor'
|
u.name = 'Bonzi'
|
||||||
u.magic = "gwyrrd"
|
u.magic = "gwyrrd"
|
||||||
u.race = "elf"
|
u.race = "elf"
|
||||||
u:set_skill("magic", 10)
|
u:set_skill("magic", 10)
|
||||||
|
@ -192,7 +192,7 @@ function test_familiar()
|
||||||
process_orders()
|
process_orders()
|
||||||
for u in r.units do
|
for u in r.units do
|
||||||
if u.id ~= uid then
|
if u.id ~= uid then
|
||||||
assert_equal('Vertrauter von Hodor (' .. itoa36(uid) ..')', u.name)
|
assert_equal('Vertrauter von Bonzi (' .. itoa36(uid) ..')', u.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -222,6 +222,8 @@ function test_bug_2480()
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_bug_2517()
|
function test_bug_2517()
|
||||||
|
-- Magier macht lange Befehle, wenn sein Vertrauter
|
||||||
|
-- zaubert (auch wenn es nicht eigene Zauber sind).
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("elf")
|
local f = faction.create("elf")
|
||||||
local um = unit.create(f, r, 1)
|
local um = unit.create(f, r, 1)
|
||||||
|
@ -242,12 +244,25 @@ function test_bug_2517()
|
||||||
assert_equal('gray', uf.magic)
|
assert_equal('gray', uf.magic)
|
||||||
uf:add_order('LERNE Magie')
|
uf:add_order('LERNE Magie')
|
||||||
um:clear_orders()
|
um:clear_orders()
|
||||||
|
assert_equal(1, uf:get_skill('magic'))
|
||||||
um:add_order('ARBEITEN')
|
um:add_order('ARBEITEN')
|
||||||
|
assert_equal(0, um:get_item('money'))
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal('gray', uf.magic)
|
assert_equal('gray', uf.magic)
|
||||||
uf:add_order('ZAUBERE STUFE 1 Viehheilung')
|
uf:add_order('ZAUBERE STUFE 1 Viehheilung')
|
||||||
|
um.aura = 10
|
||||||
|
uf.aura = 10
|
||||||
|
assert_equal(10, um:get_item('money')) -- langer Befehl wurde ausgefuehrt
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(50, uf:get_item('money'))
|
assert_equal(50, uf:get_item('money'))
|
||||||
|
assert_equal(20, um:get_item('money')) -- langer Befehl wurde ausgefuehrt
|
||||||
|
assert_equal(8, um.aura) -- kein eigener Zauber, Aura des Magiers
|
||||||
|
assert_equal(10, uf.aura)
|
||||||
|
uf:add_spell('earn_silver#gwyrrd') -- ins private spellbook aufnehmen
|
||||||
|
process_orders()
|
||||||
|
assert_equal(9, uf.aura) -- einfache Kosten, aus eigener Aura
|
||||||
|
assert_equal(8, um.aura) -- keine Kosten für den Magier
|
||||||
|
assert_equal(30, um:get_item('money')) -- langer Befehl wurde ausgefuehrt
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_familiar_school()
|
function test_familiar_school()
|
||||||
|
|
|
@ -94,7 +94,6 @@ function test_appeasement_can_move()
|
||||||
r2 = region.create(1, 0, 'plain')
|
r2 = region.create(1, 0, 'plain')
|
||||||
u2 = unit.create(faction.create('human'), r1, 1)
|
u2 = unit.create(faction.create('human'), r1, 1)
|
||||||
u2.race = 'elf'
|
u2.race = 'elf'
|
||||||
u2.name = 'Angsthase'
|
|
||||||
u2.magic = 'gwyrrd'
|
u2.magic = 'gwyrrd'
|
||||||
u2:set_skill('magic', 5)
|
u2:set_skill('magic', 5)
|
||||||
u2.aura = 10
|
u2.aura = 10
|
||||||
|
@ -118,7 +117,6 @@ function test_appeasement_break_guard()
|
||||||
r2 = region.create(1, 0, 'plain')
|
r2 = region.create(1, 0, 'plain')
|
||||||
u2 = unit.create(faction.create('human'), r1, 1)
|
u2 = unit.create(faction.create('human'), r1, 1)
|
||||||
u2.race = 'elf'
|
u2.race = 'elf'
|
||||||
u2.name = 'Angsthase'
|
|
||||||
u2.magic = 'gwyrrd'
|
u2.magic = 'gwyrrd'
|
||||||
u2.guard = true
|
u2.guard = true
|
||||||
u2.status = 1
|
u2.status = 1
|
||||||
|
|
|
@ -599,13 +599,13 @@ static int tolua_unit_get_familiar(lua_State * L)
|
||||||
|
|
||||||
static int tolua_unit_set_familiar(lua_State * L)
|
static int tolua_unit_set_familiar(lua_State * L)
|
||||||
{
|
{
|
||||||
unit *mag = (unit *)tolua_tousertype(L, 1, NULL);
|
unit *u = (unit *)tolua_tousertype(L, 1, NULL);
|
||||||
unit *fam = (unit *)tolua_tousertype(L, 2, NULL);
|
unit *fam = (unit *)tolua_tousertype(L, 2, NULL);
|
||||||
if (fam) {
|
if (fam) {
|
||||||
set_familiar(mag, fam);
|
set_familiar(u, fam);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
remove_familiar(mag);
|
remove_familiar(u);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1165,9 +1165,9 @@ faction *read_faction(gamedata * data)
|
||||||
}
|
}
|
||||||
read_allies(data, &f->allies);
|
read_allies(data, &f->allies);
|
||||||
read_groups(data, f);
|
read_groups(data, f);
|
||||||
f->spellbook = 0;
|
f->spellbook = NULL;
|
||||||
if (data->version >= REGIONOWNER_VERSION) {
|
if (data->version >= REGIONOWNER_VERSION) {
|
||||||
read_spellbook(FactionSpells() ? &f->spellbook : 0, data, get_spell_level_faction, (void *)f);
|
read_spellbook(FactionSpells() ? &f->spellbook : NULL, data, get_spell_level_faction, (void *)f);
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
11
src/magic.c
11
src/magic.c
|
@ -364,11 +364,18 @@ write_mage(const variant *var, const void *owner, struct storage *store)
|
||||||
write_spellbook(mage->spellbook, store);
|
write_spellbook(mage->spellbook, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int reset_mage(attrib *a, void *owner) {
|
||||||
|
sc_mage *mage = (sc_mage *)a->data.v;
|
||||||
|
UNUSED_ARG(owner);
|
||||||
|
mage->spellcount = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
attrib_type at_mage = {
|
attrib_type at_mage = {
|
||||||
"mage",
|
"mage",
|
||||||
init_mage,
|
init_mage,
|
||||||
free_mage,
|
free_mage,
|
||||||
NULL,
|
reset_mage,
|
||||||
write_mage,
|
write_mage,
|
||||||
read_mage,
|
read_mage,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -498,7 +505,7 @@ sc_mage *create_mage(unit * u, magic_t mtyp)
|
||||||
bool u_hasspell(const unit *u, const struct spell *sp)
|
bool u_hasspell(const unit *u, const struct spell *sp)
|
||||||
{
|
{
|
||||||
spellbook * book = unit_get_spellbook(u);
|
spellbook * book = unit_get_spellbook(u);
|
||||||
spellbook_entry * sbe = book ? spellbook_get(book, sp) : 0;
|
spellbook_entry * sbe = book ? spellbook_get(book, sp) : NULL;
|
||||||
if (sbe) {
|
if (sbe) {
|
||||||
return sbe->level <= effskill(u, SK_MAGIC, NULL);
|
return sbe->level <= effskill(u, SK_MAGIC, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue