Anonymous

Module:Skills: Difference between revisions

From Melvor Idle
Adjusted the appearance of the Lesser Relics table
(mw.log(p.getAncientRelicsTable({args={}})))
(Adjusted the appearance of the Lesser Relics table)
 
(3 intermediate revisions by 2 users not shown)
Line 494: Line 494:
local skillName = frame.args ~= nil and frame.args[1] or frame
local skillName = frame.args ~= nil and frame.args[1] or frame
local skillID = nil
local skillID = nil
if skillName ~= nil then
if skillName ~= nil and skillName ~= '' then
skillID = Constants.getSkillID(skillName)
skillID = Constants.getSkillID(skillName)
if skillID == nil then
if skillID == nil then
Line 502: Line 502:


local resultPart = {}
local resultPart = {}
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
table.insert(resultPart, '{| class="wikitable sortable stickyHeader lighttable"')
table.insert(resultPart, '\n|-class="headerRow-0"')
table.insert(resultPart, '\n|-class="headerRow-0"')
table.insert(resultPart, '\n|-\n!colspan="2"|Skill\n!Relic\n!Modifiers')
table.insert(resultPart, '\n|-\n!colspan="2"|Skill\n!Relic\n!Modifiers')


local relics = GameData.getEntites('ancientRelics',
local relics = GameData.getEntities('ancientRelics',
function(relic)
function(relic)
return skillID == nil or relic.skillID == skillID
return skillID == nil or relic.skillID == skillID
Line 514: Line 514:
local skillNameA, skillNameB = Constants.getSkillName(a.skillID), Constants.getSkillName(b.skillID)
local skillNameA, skillNameB = Constants.getSkillName(a.skillID), Constants.getSkillName(b.skillID)
if skillNameA == skillNameB then
if skillNameA == skillNameB then
return a.number < b.number
-- Order by numbers at the end of relic IDs
-- Relics have a 'number' property, but this appears to contain duplicates
return string.sub(a.id, string.len(a.id)) < string.sub(b.id, string.len(b.id))
else
else
return skillNameA < skillNameB
return skillNameA < skillNameB
Line 522: Line 524:
local function appendSkillRows(resultTable, rowTable, relicCount, skillID)
local function appendSkillRows(resultTable, rowTable, relicCount, skillID)
local skillName = Constants.getSkillName(skillID)
local skillName = Constants.getSkillName(skillID)
table.insert(resultTable, '\n|-\n|rowpsan="' .. relicCount .. '"| ' .. Icons.Icon({skillName, type='skill', notext=true, size=50}))
table.insert(resultTable, '\n|-\n|rowspan="' .. relicCount .. '"| ' .. Icons.Icon({skillName, type='skill', notext=true, size=50}))
table.insert(resultTable, '\n|rowpsan="' .. relicCount .. '"| ' .. Icons.Icon({skillName, type='skill', noicon=true}))
table.insert(resultTable, '\n|rowspan="' .. relicCount .. '"| ' .. Icons.Icon({skillName, type='skill', noicon=true}))
table.insert(resultTable, table.concat(rowTable))
table.insert(resultTable, table.concat(rowTable))
end
end
Line 538: Line 540:
end
end


skillRelicCount = relic.number
skillRelicCount = skillRelicCount + 1
table.insert(tablePart, '\n|-\n| ' .. skillRelicCount .. '\n| ' .. Constants.getModifiersText(relic.modifiers))
if skillRelicCount > 1 then
table.insert(tablePart, '\n|-')
end
table.insert(tablePart, '\n| ' .. skillRelicCount .. '\n| ' .. Constants.getModifiersText(relic.modifiers))
end
end
appendSkillRows(resultPart, tablePart, skillRelicCount, currentSkillID)
appendSkillRows(resultPart, tablePart, skillRelicCount, currentSkillID)
Line 545: Line 550:


return table.concat(resultPart)
return table.concat(resultPart)
end
function p.getLesserRelicsTable(frame)
local lesserRelics = {}
-- Iterate over each skill with a global rare drop then check
-- if the skill has a Lesser Relic drop
for skillLocalID, skill in pairs(SkillData) do
if skill.rareDrops ~= nil then
for i, drops in pairs(skill.rareDrops) do
if string.match(drops.itemID, '_Lesser_Relic') then
table.insert(lesserRelics, Items.getItemByID(drops.itemID))
end
end
end
end
table.sort(lesserRelics, function(a, b) return a.name < b.name end)
-- Create the Table
local resultTable = mw.html.create('table')
resultTable:addClass('wikitable sortable')
resultTable:tag('tr'):addClass('headerRow-0')
:tag('th'):wikitext('Icon')
:tag('th'):wikitext('Lesser Relic')
:tag('th'):wikitext('Modifiers')
for _, relic in ipairs(lesserRelics) do
local tr = mw.html.create('tr')
tr:tag('td'):wikitext(Icons.Icon({relic.name, type='item', size='50', notext=true}))
tr:tag('td'):wikitext(Icons.Icon({relic.name, type='item', noicon=true}))
tr:tag('td'):wikitext(Constants.getModifiersText(relic.modifiers))
resultTable:node(tr)
end
return resultTable
end
end


return p
return p
463

edits