17,101
edits
(getRuneNavbox: Order results by level & improve resilience against future rune additions; getSkillcapeNavbox: Include missing max cape & consistency with shop table; getFishingNavbox: Implement to replace manually maintained table) |
(getPrayerNavbox/getSpellNavbox: Order prayers/spells by level, in line with in-game appearance) |
||
Line 188: | Line 188: | ||
function p.getPrayerNavbox(frame) | function p.getPrayerNavbox(frame) | ||
local | local prayerList = {} | ||
for i, prayer in Shared.skpairs(SkillData.Prayer) do | for i, prayer in Shared.skpairs(SkillData.Prayer) do | ||
table.insert(prayerList, { ["name"] = prayer.name, ["order"] = prayer.prayerLevel }) | |||
end | end | ||
local | table.sort(prayerList, function(a, b) | ||
if a.order == b.order then | |||
return a.name < b.name | |||
else | |||
return | return a.order < b.order | ||
end | |||
end) | |||
local prayerListText = {} | |||
for i, prayer in ipairs(prayerList) do | |||
table.insert(prayerListText, Icons.Icon({ prayer.name, type='prayer' })) | |||
end | |||
local resultPart = {} | |||
table.insert(resultPart, '{| class="wikitable" style="margin:auto; clear:both; width: 100%"') | |||
table.insert(resultPart, '\r\n!'..Icons.Icon({'Prayer', 'Prayers', type='skill'})) | |||
table.insert(resultPart, '\r\n|-\r\n|style="text-align:center;"| ' .. table.concat(prayerListText, ' • ')) | |||
table.insert(resultPart, '\r\n|}') | |||
return table.concat(resultPart) | |||
end | end | ||
Line 257: | Line 271: | ||
function p.getSpellNavbox(frame) | function p.getSpellNavbox(frame) | ||
local | local spellTable = { ["standard"] = {}, ["curse"] = {}, ["aurora"] = {}, ["ancient"] = {}, ["alt"] = {} } | ||
local | local catData = { | ||
{ ["name"] = 'standard', ["header"] = '[[Magic#Standard_Magic|Standard Spells]]', ["imgType"] = 'spell' }, | |||
{ ["name"] = 'curse', ["header"] = '[[Magic#Curses|Curses]]', ["imgType"] = 'curse' }, | |||
{ ["name"] = 'aurora', ["header"] = '[[Magic#Auroras|Auroras]]', ["imgType"] = 'aurora' }, | |||
{ ["name"] = 'ancient', ["header"] = '[[Magic#Ancient_Magicks|Ancient Magicks]]', ["imgType"] = 'spell' }, | |||
{ ["name"] = 'alt', ["header"] = '[[Alternative_Magic|Alt Magic]]', ["imgType"] = 'spell' }, | |||
} | |||
for i, spell in | for i, spell in ipairs(MagicData.Spells) do | ||
table.insert(spellTable['standard'], { ["name"] = spell.name, ["order"] = spell.level }) | |||
end | |||
for i, spell in ipairs(MagicData.Curses) do | |||
table.insert(spellTable['curse'], { ["name"] = spell.name, ["order"] = spell.level }) | |||
end | end | ||
for i, spell in | for i, spell in ipairs(MagicData.Auroras) do | ||
table.insert(spellTable['aurora'], { ["name"] = spell.name, ["order"] = spell.level }) | |||
end | end | ||
for i, spell in | for i, spell in ipairs(MagicData.Ancient) do | ||
table.insert(spellTable['ancient'], { ["name"] = spell.name, ["order"] = spell.level }) | |||
end | end | ||
for i, spell in | for i, spell in ipairs(MagicData.AltMagic) do | ||
table.insert(spellTable['alt'], { ["name"] = spell.name, ["order"] = spell.level }) | |||
end | end | ||
for i, | |||
local getSpellList = function(spellTable, imgType) | |||
local listPart = {} | |||
for i, obj in ipairs(spellTable) do | |||
table.insert(listPart, Icons.Icon({obj.name, type=imgType})) | |||
end | |||
return table.concat(listPart, ' • ') | |||
end | |||
local resultPart = {} | |||
table.insert(resultPart, '{| class="wikitable" style="margin:auto; clear:both; width: 100%"') | |||
table.insert(resultPart, '\r\n!colspan=2|[[File:Magic_(skill).svg|25px|link=Spells]] [[Spells]]') | |||
for i, catDefn in ipairs(catData) do | |||
table.sort(spellTable[catDefn.name], function(a, b) | |||
if a.order == b.order then | |||
return a.name < b.name | |||
else | |||
return a.order < b.order | |||
end | |||
end) | |||
table.insert(resultPart, '\r\n|-\r\n!scope="row"| ' .. catDefn.header) | |||
table.insert(resultPart, '\r\n|style="text-align:center;| ' .. getSpellList(spellTable[catDefn.name], catDefn.imgType)) | |||
end | end | ||
table.insert(resultPart, '\r\n|}') | |||
return table.concat(resultPart) | |||
end | end | ||