Module:Magic: Difference between revisions

Update for v1.0.2
m (Formatting tweaks)
(Update for v1.0.2)
Line 27: Line 27:
section = 'AltMagic'
section = 'AltMagic'
end
end
 
name = Shared.fixPagename(name)
name = Shared.fixPagename(name)
if section == nil then
if section == nil then
Line 59: Line 59:
section = 'AltMagic'
section = 'AltMagic'
end
end
 
if MagicData[section] ~= nil then
if MagicData[section] ~= nil then
return processSpell(section, id + 1)
return processSpell(section, id + 1)
Line 107: Line 107:


function p._getSpellRunes(spell)
function p._getSpellRunes(spell)
local result = ''
local formatRuneList = function(runes)
for i, req in Shared.skpairs(spell.runesRequired) do
local runeList = {}
local rune = Items.getItemByID(req.id)
for i, req in ipairs(runes) do
if i > 1 then result = result..', ' end
local rune = Items.getItemByID(req.id)
result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
if rune ~= nil then
end
table.insert(runeList, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty}))
if spell.runesRequiredAlt ~= nil and not Shared.tablesEqual(spell.runesRequired, spell.runesRequiredAlt) then
end
result = result.."<br/>'''OR'''<br/>"
end
for i, req in pairs(spell.runesRequiredAlt) do
return table.concat(runeList, ', ')
local rune = Items.getItemByID(req.id)
end
if i > 1 then result = result..', ' end
if type(spell.runesRequired) == 'table' then
result = result..Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})
local resultPart  = {}
table.insert(resultPart, formatRuneList(spell.runesRequired))
if spell.runesRequiredAlt ~= nil and not Shared.tablesEqual(spell.runesRequired, spell.runesRequiredAlt) then
table.insert(resultPart, "<br/>'''OR'''<br/>" .. formatRuneList(spell.runesRequiredAlt))
end
end
return table.concat(resultPart)
else
return ''
end
end
return result
end
end


Line 236: Line 241:
end
end
end
end
table.sort(spellList, function(a, b)  
table.sort(spellList, function(a, b)
if a.type ~= b.type then
if a.type ~= b.type then
return p.getSpellTypeIndex(a.type) < p.getSpellTypeIndex(b.type)
return p.getSpellTypeIndex(a.type) < p.getSpellTypeIndex(b.type)
Line 318: Line 323:
end
end
if p.getSpellTypeIndex(spell.type) == 4 then
if p.getSpellTypeIndex(spell.type) == 4 then
rowTxt = rowTxt..'||'..spell.magicXP
rowTxt = rowTxt..'||'..spell.baseExperience
end
end
rowTxt = rowTxt..'||style="text-align:center"|'
rowTxt = rowTxt..'||style="text-align:center"|'