remove even more equipment xml to Lua

only familiars still TBD, I think.
This commit is contained in:
Enno Rehling 2018-05-14 22:01:32 +02:00
parent 2a026da1fd
commit e46cfa5e77
7 changed files with 91 additions and 80 deletions

View File

@ -13,7 +13,6 @@
"config://res/eressea/races.xml",
"config://res/eressea/artrewards.xml",
"config://res/eressea/familiars.xml",
"config://res/eressea/equipment.xml",
"config://res/eressea/spells.xml",
"config://res/eressea/spellbooks/gray.xml",
"config://res/eressea/spellbooks/gwyrrd.xml",

View File

@ -1,27 +0,0 @@
<?xml version="1.0"?>
<eressea>
<equipment>
<set name="first_unit">
<item name="money" amount="2500"/>
<item name="log" amount="10"/>
<item name="stone" amount="4"/>
</set>
<set name="seed_unit">
<item name="log" amount="50"/>
<item name="stone" amount="50"/>
<item name="iron" amount="50"/>
<item name="laen" amount="10"/>
<item name="sword" amount="1"/>
<item name="mallorn" amount="10"/>
<item name="skillpotion" amount="5"/>
<item name="lifepotion" amount="5"/>
<item name="money" amount="20000"/>
<skill name="perception" level="30"/>
<skill name="melee" level="1"/>
</set>
<set name="seed_faction">
<item name="adamantium" amount="1"/>
</set>
</equipment>
</eressea>

View File

@ -1,49 +0,0 @@
<?xml version="1.0"?>
<eressea><equipment>
<!-- sets that are used by the monster-spawning code -->
<set name="seed_dragon">
<skill name="magic" level="4"/>
<skill name="stealth" level="1"/>
<skill name="stamina" level="1"/>
<skill name="perception" level="d3"/>
<item name="money" amount="d500+99"/>
</set>
<set name="seed_braineater">
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="seed_seaserpent">
<skill name="magic" level="4"/>
<skill name="stealth" level="2"/>
<skill name="stamina" level="1"/>
<skill name="perception" level="3"/>
</set>
<set name="new_dracoid">
<!-- dracoiden, von drachen rekrutiert -->
<skill name="polearm" level="d4+2"/>
<skill name="melee" level="d4+2"/>
<skill name="bow" level="d3+1"/>
<subset>
<!-- dracoiden haben immer eine von drei waffen -->
<set name="i_sword" chance="0.33"/>
<set name="i_spear" chance="0.33"/>
<set name="i_bow" chance="0.34"/>
</subset>
</set>
<set name="rising_undead">
<!-- untote, von den graebern auferstanden -->
<item name="rustysword" amount="1"/>
<item name="rustychainmail" amount="d2-1"/>
<subset chance="0.3">
<set name="i_rustyshield"/>
</subset>
</set>
</equipment>
</eressea>

View File

@ -1,8 +1,15 @@
require 'eressea.spells'
eressea.log.debug('rules for game E2')
math.randomseed(rng.random())
local equipment = require('eressea.equipment')
local sets = {
['seed_faction'] = {
['items'] = {
['adamantium'] = 1
}
},
['new_orc'] = {
['skills'] = {
['polearm'] = 1,
@ -37,8 +44,62 @@ local sets = {
['dragonblood'] = 10,
['dragonhead'] = 1
}
},
['seed_dragon'] = {
['skills'] = {
['magic'] = 4,
['stealth'] = 1,
['stamina'] = 1,
},
['callback'] = function(u)
u:add_item('money', u.number * (math.random(500)+99))
u:set_skill('perception', math.random(3))
end
},
['seed_braineater'] = {
['skills'] = {
['stealth'] = 1,
['perception'] = 1,
}
},
['seed_seaserpent'] = {
['skills'] = {
['magic'] = 4,
['stealth'] = 2,
['stamina'] = 1,
['perception'] = 3,
}
},
['rising_undead'] = {
['items'] = {
['rustysword'] = 1
},
['callback'] = function(u)
if (math.random(2)==1) then
u:add_item('rustychainmail', u.number)
end
if (math.random(3)==1) then
u:add_item('rustyshield', u.number)
end
end
},
['new_dracoid'] = {
['callback'] = function(u)
local pick = math.random(3)
if pick==1 then
u:set_skill('melee', math.random(4)+2)
u:add_item('sword', u.number)
elseif pick==2 then
u:set_skill('polearm', math.random(4)+2)
u:add_item('spear', u.number)
else
u:set_skill('bow', math.random(3)+1)
u:add_item('bow', u.number)
end
end
}
}
equipment.add_multiple(sets)
return {

View File

@ -115,7 +115,7 @@ function equip_unit(u, name, flags)
local items = set['items']
if items then
for k,v in pairs(items) do
u:add_item(k, v)
u:add_item(k, v * u.number)
end
end
local skills = set['skills']

View File

@ -3,8 +3,6 @@ local rules = 'conf'
if config.rules then
rules = rules .. '/' .. config.rules
assert(0 == eressea.config.read(rules .. '/config.json', config.install), "could not read JSON data")
-- assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
-- assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
end
eressea.game.reset()

View File

@ -457,3 +457,32 @@ function test_new_orc_has_skills()
assert_equal(1, u:get_skill('polearm'))
assert_equal(1, u:get_skill('melee'))
end
function test_new_dracoid()
local f = faction.create('human')
local r = region.create(0, 0, 'plain')
local u = unit.create(f, r, 'dracoid')
u.number = 2
u:equip("new_dracoid")
assert_equal(2, u.number)
item = nil
if u:get_skill('bow') > 1 then
item = 'bow'
elseif u:get_skill('polearm') > 1 then
item = 'spear'
elseif u:get_skill('melee') > 1 then
item = 'sword'
end
assert_not_nil(item)
assert_equal(u.number, u:get_item(item))
end
function test_rising_undead()
local f = faction.create('human')
local r = region.create(0, 0, 'plain')
local u = unit.create(f, r, 'undead')
u.number = 2
u:equip("rising_undead")
assert_equal(2, u.number)
assert_equal(u.number, u:get_item('rustysword'))
end