2,875
edits
Tag: Undo |
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 in use | |||
for _, recipe in ipairs(recipes) do | |||
for _, modType in ipairs(modTypes) do | |||
if not modType.inUse then | |||
local recipeMods = recipe[modType.modKey] | |||
if recipeMods ~= nil and not Shared.tableIsEmpty(recipeMods) then | |||
modType.inUse = true | |||
end | |||
end | |||
end | |||
end | |||
local root = mw.html.create() | |||
local tableRoot = root:tag('table') | |||
tableRoot:addClass('wikitable sortable stickyHeader') | |||
-- Header row | |||
local headerRow = tableRoot:tag('tr'):addClass('headerRow-0') | |||
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' }) .. ' Level') | |||
headerRow:tag('th'):attr('rowspan', 2):wikitext('XP') | |||
headerRow:tag('th'):attr('rowspan', 2):wikitext('Skills') | |||
-- Modifiers headers | |||
for _, modType in ipairs(modTypes) do | |||
if modType.inUse then | |||
headerRow:tag('th'):attr('colspan', 2):wikitext(modType.name .. ' Stars') | |||
end | |||
end | |||
local headerRow2 = tableRoot:tag('tr'):addClass('headerRow-1') | |||
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 _, cons in ipairs(recipes) do | |||
local modData = Skills._getConstellationModifiers(cons) | |||
local name = cons.name | |||
local skillIconArray = {} | |||
for _, 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 = tableRoot:tag('tr') | |||
row:tag('td'):attr('rowspan', maxRows):attr('data-sort-value', name):attr('id', name):wikitext(Icons.Icon({ name, type='constellation', notext=true })) | |||
row:tag('td'):attr('rowspan', maxRows):wikitext(Icons.getDLCColumnIcon(cons.id) .. name) | |||
row:tag('td'):attr('rowspan', maxRows):addClass('text-right'):wikitext(cons.level) | |||
row:tag('td'):attr('rowspan', maxRows):addClass('text-right'):wikitext(cons.baseExperience) | |||
row:tag('td'):attr('rowspan', maxRows):wikitext(table.concat(skillIconArray, '<br/>')) | |||
-- Modifiers data | |||
for rowIdx = 1, maxRows do | |||
for _, modType in ipairs(modTypes) do | |||
if modType.inUse then | |||
local masteryLevel = modType.levels[rowIdx] | |||
local rowModData = modData[modType.modKey][rowIdx] | |||
local cell = row:tag('td') | |||
if masteryLevel ~= nil and rowModData ~= nil then | |||
cell:addClass('text-right'):wikitext(masteryLevel) | |||
cell:wikitext(Modifiers.getModifiersText(rowModData, false, false, 10)) | |||
else | |||
cell:attr('colspan', 2):addClass('table-na'):wikitext(' ') | |||
end | |||
end | |||
end | |||
if rowIdx < maxRows then | |||
tableRoot:tag('tr') | |||
end | |||
end | |||
end | |||
return tostring(root) | |||
end | end | ||
edits