17,030
edits
(obstacleUnlockLevels now includes level 1) |
(mw.log(p.getAncientRelicsTable({args={}}))) |
||
Line 488: | Line 488: | ||
table.insert(resultPart, '\r\n|}') | table.insert(resultPart, '\r\n|}') | ||
return table.concat(resultPart) | |||
end | |||
function p.getAncientRelicsTable(frame) | |||
local skillName = frame.args ~= nil and frame.args[1] or frame | |||
local skillID = nil | |||
if skillName ~= nil then | |||
skillID = Constants.getSkillID(skillName) | |||
if skillID == nil then | |||
return Shared.printError('Failed to find a skill ID for ' .. skillName) | |||
end | |||
end | |||
local resultPart = {} | |||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | |||
table.insert(resultPart, '\n|-class="headerRow-0"') | |||
table.insert(resultPart, '\n|-\n!colspan="2"|Skill\n!Relic\n!Modifiers') | |||
local relics = GameData.getEntites('ancientRelics', | |||
function(relic) | |||
return skillID == nil or relic.skillID == skillID | |||
end) | |||
table.sort(relics, | |||
function (a, b) | |||
local skillNameA, skillNameB = Constants.getSkillName(a.skillID), Constants.getSkillName(b.skillID) | |||
if skillNameA == skillNameB then | |||
return a.number < b.number | |||
else | |||
return skillNameA < skillNameB | |||
end | |||
end) | |||
local function appendSkillRows(resultTable, rowTable, relicCount, 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|rowpsan="' .. relicCount .. '"| ' .. Icons.Icon({skillName, type='skill', noicon=true})) | |||
table.insert(resultTable, table.concat(rowTable)) | |||
end | |||
local skillRelicCount, currentSkillID, tablePart = 0, nil, {} | |||
for i, relic in ipairs(relics) do | |||
if currentSkillID == nil then | |||
currentSkillID = relic.skillID | |||
elseif relic.skillID ~= currentSkillID then | |||
appendSkillRows(resultPart, tablePart, skillRelicCount, currentSkillID) | |||
tablePart = {} | |||
currentSkillID = relic.skillID | |||
skillRelicCount = 0 | |||
end | |||
skillRelicCount = relic.number | |||
table.insert(tablePart, '\n|-\n| ' .. skillRelicCount .. '\n| ' .. Constants.getModifiersText(relic.modifiers)) | |||
end | |||
appendSkillRows(resultPart, tablePart, skillRelicCount, currentSkillID) | |||
table.insert(resultPart, '\n|}') | |||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | end | ||
return p | return p |