2,875
edits
No edit summary |
No edit summary |
||
Line 1,123: | Line 1,123: | ||
function p._buildAstrologyConstellationTable(realmID) | function p._buildAstrologyConstellationTable(realmID) | ||
local modTypes = { | |||
{ | |||
name = 'Standard', | |||
modKey = 'standardModifiers', | |||
levels = SkillData.Astrology.standardModifierLevels, | |||
inUse = false | |||
}, | |||
{ | |||
name = 'Unique', | |||
modKey = 'uniqueModifiers', | |||
levels = SkillData.Astrology.uniqueModifierLevels, | |||
inUse = false | |||
}, | |||
{ | |||
name = 'Abyssal', | |||
modKey = 'abyssalModifiers', | |||
levels = SkillData.Astrology.abyssalModifierLevels, | |||
inUse = false | |||
}, | |||
} | |||
local recipes = GameData.getEntities(SkillData.Astrology.recipes, | |||
function(cons) | |||
return Skills.getRecipeRealm(cons) == realmID | |||
end | |||
) | |||
table.sort(recipes, | |||
function(a, b) | |||
return Skills.getRecipeLevel('Astrology', a) < Skills.getRecipeLevel('Astrology', b) | |||
end | |||
) | |||
-- Determine which mod types are to be displayed | |||
for _, recipe in ipairs(recipes) do | |||
for _, modType in ipairs(modTypes) do | |||
if not modType.inUse then | |||
local recipeMods = recipe[modType.modKey] | |||
if recipeMods and not Shared.tableIsEmpty(recipeMods) then | |||
modType.inUse = true | |||
end | |||
end | |||
end | |||
end | |||
local root = mw.html.create('table') | |||
:addClass('wikitable sortable stickyHeader') | |||
-- Header row | |||
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') | |||
-- Mod types header | |||
local headerRow1 = root:tag('tr') | |||
for _, modType in ipairs(modTypes) do | |||
if modType.inUse then | |||
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 | |||
-- Data rows | |||
for i, cons in ipairs(recipes) do | |||
local modData = Skills._getConstellationModifiers(cons) | |||
local name = cons.name | |||
local skillIconArray = {} | |||
for j, skillID in ipairs(cons.skillIDs) do | |||
table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'})) | |||
end | |||
local maxRows = 1 | |||
for _, modTypeData in pairs(modData) do | |||
maxRows = math.max(maxRows, Shared.tableCount(modTypeData)) | |||
end | |||
local row = root:tag('tr') | |||
row:tag('td'):attr('rowspan', maxRows) | |||
:attr('data-sort-value', name):attr('id', name):wikitext(' ') | |||
row:tag('td'):attr('rowspan', maxRows) | |||
:wikitext(Icons.Icon({name, type='constellation', notext='true'})) | |||
row:tag('td'):attr('rowspan', maxRows) | |||
:wikitext(name) | |||
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 rowIdx = 1, maxRows do | |||
local subrow = root:tag('tr') | |||
for _, modType in ipairs(modTypes) do | |||
if modType.inUse then | |||
local masteryLevel = modType.levels[rowIdx] | |||
local rowModData = modData[modType.modKey][rowIdx] | |||
if masteryLevel and rowModData then | |||
subrow:tag('td'):css('text-align', 'right'):wikitext(masteryLevel) | |||
subrow:tag('td'):wikitext(Modifiers.getModifiersText(rowModData, false, false, 10)) | |||
else | |||
subrow:tag('td'):attr('colspan', '2'):addClass('table-na'):wikitext(' ') | |||
end | |||
end | |||
end | |||
end | |||
end | |||
root:wikitext('\n|}') | |||
return tostring(root) | |||
end | end | ||
function p.buildAstrologyConstellationTable(frame) | function p.buildAstrologyConstellationTable(frame) |
edits