4,951
edits
Falterfire (talk | contribs) (Fixed some mistakes with new getting spells) |
Falterfire (talk | contribs) (Added ability to get all spells for a given rune.) |
||
Line 55: | Line 55: | ||
return nil | return nil | ||
end | end | ||
end | |||
function p.getSpellsForRune(runeID) | |||
local spellList = {} | |||
for secName, secArray in Shared.skpairs(MagicData) do | |||
for i, spell in pairs(secArray) do | |||
local foundSpell = false | |||
for j, req in pairs(spell.runesRequired) do | |||
if req.id == runeID then | |||
table.insert(spellList, processSpell(secName, i)) | |||
foundSpell = true | |||
break | |||
end | |||
end | |||
if spell.runesRequiredAlt ~= nil and not foundSpell then | |||
for j, req in pairs(spell.runesRequiredAlt) do | |||
if req.id == runeID then | |||
table.insert(spellList, processSpell(secName, i)) | |||
break | |||
end | |||
end | |||
end | |||
end | |||
end | |||
table.sort(spellList, function(a, b) | |||
if a.type ~= b.type then | |||
return p.getSpellTypeIndex(a.type) < p.getSpellTypeIndex(b.type) | |||
else | |||
return a.magicLevelRequired < b.magicLevelRequired | |||
end | |||
end) | |||
return spellList | |||
end | |||
function p.getSpellTypeIndex(type) | |||
if type == 'Spells' then | |||
return 0 | |||
elseif type == 'Curses' then | |||
return 1 | |||
elseif type == 'Auroras' then | |||
return 2 | |||
elseif type == 'Ancient' then | |||
return 3 | |||
elseif type == 'AltMagic' then | |||
return 4 | |||
end | |||
return -1 | |||
end | |||
function p.getSpellTypeLink(type) | |||
if type == 'Spells' then | |||
return Icons.Icon({'Magic#Standard Magic', 'Standard', img='Standard', type='spellType'}) | |||
elseif type == 'Curses' then | |||
return Icons.Icon({'Magic#Curses', 'Curse', img='Curse', type='spellType'}) | |||
elseif type == 'Auroras' then | |||
return Icons.Icon({'Magic#Auroras', 'Aurora', img='Aurora', type='spellType'}) | |||
elseif type == 'Ancient' then | |||
return Icons.Icon({'Magic#Ancient Magicks', 'Ancient', img='Ancient', type='spellType'}) | |||
elseif type == 'AltMagic' then | |||
return Icons.Icon({'Alt. Magic', type='skill'}) | |||
end | |||
return '' | |||
end | end | ||
return p | return p |