2,875
edits
Tag: Undo |
Tag: Undo |
||
Line 1,122: | Line 1,122: | ||
function p._buildAstrologyConstellationTable(realmID) | |||
local modTypes = { | local modTypes = { | ||
{ | { | ||
Line 1,149: | Line 1,149: | ||
end | end | ||
) | ) | ||
table.sort(recipes, | table.sort(recipes, | ||
function(a, b) | function(a, b) | ||
Line 1,156: | Line 1,155: | ||
) | ) | ||
-- Determine which mod types are | -- Determine which mod types are to be displayed | ||
for _, recipe in ipairs(recipes) do | for _, recipe in ipairs(recipes) do | ||
for _, modType in ipairs(modTypes) do | for _, modType in ipairs(modTypes) do | ||
if not modType.inUse then | if not modType.inUse then | ||
local recipeMods = recipe[modType.modKey] | local recipeMods = recipe[modType.modKey] | ||
if recipeMods | if recipeMods and not Shared.tableIsEmpty(recipeMods) then | ||
modType.inUse = true | modType.inUse = true | ||
end | end | ||
Line 1,168: | Line 1,167: | ||
end | end | ||
local | local root = mw.html.create('table') | ||
:addClass('wikitable sortable stickyHeader') | |||
-- Header | -- Header row | ||
local | local headerRow = root:tag('tr') | ||
headerRow:tag('th'):attr('rowspan', '2'):attr('colspan', '2'):wikitext('Constellation') | |||
headerRow:tag('th'):attr('rowspan', '2'):wikitext(Icons.Icon({"Astrology", type='skill', notext='true'}) .. '<br>Level') | |||
headerRow:tag('th'):attr('rowspan', '2'):wikitext('[[DLC]]') | |||
headerRow:tag('th'):attr('rowspan', '2'):wikitext('XP') | |||
headerRow:tag('th'):attr('rowspan', '2'):wikitext('Skills') | |||
local headerRow1 = | -- Mod types header | ||
local headerRow1 = root:tag('tr') | |||
for _, modType in ipairs(modTypes) do | for _, modType in ipairs(modTypes) do | ||
if modType.inUse then | if modType.inUse then | ||
headerRow1:tag('th'):attr('colspan', '2'):wikitext(modType.name .. ' Stars') | headerRow1:tag('th'):attr('colspan', '2'):wikitext(modType.name .. ' Stars') | ||
end | |||
end | |||
-- Subheaders for mod types | |||
local headerRow2 = root:tag('tr') | |||
for _, modType in ipairs(modTypes) do | |||
if modType.inUse then | |||
headerRow2:tag('th'):wikitext(Icons.Icon({'Mastery', notext='true'}) .. ' Level') | |||
headerRow2:tag('th'):wikitext('Modifiers') | |||
end | end | ||
end | end | ||
-- Data rows | -- Data rows | ||
for | for i, cons in ipairs(recipes) do | ||
local modData = Skills._getConstellationModifiers(cons) | local modData = Skills._getConstellationModifiers(cons) | ||
local name = cons.name | local name = cons.name | ||
local skillIconArray = {} | local skillIconArray = {} | ||
for | for j, skillID in ipairs(cons.skillIDs) do | ||
table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'})) | table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'})) | ||
end | end | ||
Line 1,198: | Line 1,208: | ||
end | end | ||
local row = root:tag('tr') | |||
row:tag('td'):attr('rowspan', maxRows) | |||
local row = | :attr('data-sort-value', name):attr('id', name):wikitext(' ') | ||
row:tag('td'):attr('rowspan', | row:tag('td'):attr('rowspan', maxRows) | ||
row:tag('td'):attr('rowspan', | :wikitext(Icons.Icon({name, type='constellation', notext='true'})) | ||
row:tag('td'):attr('rowspan', maxRows) | |||
row:tag('td'):attr('rowspan', | :wikitext(name) | ||
row:tag('td'):attr('rowspan', | row:tag('td'):attr('rowspan', maxRows) | ||
:css('text-align', 'center') | |||
:wikitext(cons.level) | |||
row:tag('td'):attr('rowspan', maxRows) | |||
:attr('data-sort-value', Icons.getExpansionID(cons.id)) | |||
:css('text-align', 'center') | |||
:wikitext(Icons.getDLCColumnIcon(cons.id)) | |||
row:tag('td'):attr('rowspan', maxRows) | |||
:css('text-align', 'right') | |||
:wikitext(cons.baseExperience) | |||
row:tag('td'):attr('rowspan', maxRows) | |||
:wikitext(table.concat(skillIconArray, '<br/>')) | |||
-- | -- Generate table rows for modifiers | ||
for | for rowIdx = 1, maxRows do | ||
local subrow = root:tag('tr') | |||
for _, modType in ipairs(modTypes) do | for _, modType in ipairs(modTypes) do | ||
if modType.inUse then | if modType.inUse then | ||
local masteryLevel = modType.levels[ | local masteryLevel = modType.levels[rowIdx] | ||
local rowModData = modData[modType.modKey][ | local rowModData = modData[modType.modKey][rowIdx] | ||
if masteryLevel and rowModData then | |||
if masteryLevel | subrow:tag('td'):css('text-align', 'right'):wikitext(masteryLevel) | ||
subrow:tag('td'):wikitext(Modifiers.getModifiersText(rowModData, false, false, 10)) | |||
else | else | ||
subrow:tag('td'):attr('colspan', '2'):addClass('table-na'):wikitext(' ') | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
return tostring( | root:wikitext('\n|}') | ||
return tostring(root) | |||
end | end | ||
edits