Module:Skills/Gathering/Sandbox: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1,123: Line 1,123:


function p._buildAstrologyConstellationTable(realmID)
function p._buildAstrologyConstellationTable(realmID)
local modTypes = {
    local modTypes = {
{
        {
["name"] = 'Standard',
            name = 'Standard',
["modKey"] = 'standardModifiers',
            modKey = 'standardModifiers',
["levels"] = SkillData.Astrology.standardModifierLevels,
            levels = SkillData.Astrology.standardModifierLevels,
["inUse"] = false
            inUse = false
},
        },
{
        {
["name"] = 'Unique',
            name = 'Unique',
["modKey"] = 'uniqueModifiers',
            modKey = 'uniqueModifiers',
["levels"] = SkillData.Astrology.uniqueModifierLevels,
            levels = SkillData.Astrology.uniqueModifierLevels,
["inUse"] = false
            inUse = false
},
        },
{
        {
["name"] = 'Abyssal',
            name = 'Abyssal',
["modKey"] = 'abyssalModifiers',
            modKey = 'abyssalModifiers',
["levels"] = SkillData.Astrology.abyssalModifierLevels,
            levels = SkillData.Astrology.abyssalModifierLevels,
["inUse"] = false
            inUse = false
},
        },
}
    }


local recipes = GameData.getEntities(SkillData.Astrology.recipes,
    local recipes = GameData.getEntities(SkillData.Astrology.recipes,
function(cons)
        function(cons)
return Skills.getRecipeRealm(cons) == realmID
            return Skills.getRecipeRealm(cons) == realmID
end
        end
)
    )
table.sort(recipes,
    table.sort(recipes,
function(a, b)
        function(a, b)
return Skills.getRecipeLevel('Astrology', a) < Skills.getRecipeLevel('Astrology', b)
            return Skills.getRecipeLevel('Astrology', a) < Skills.getRecipeLevel('Astrology', b)
end
        end
)
    )


-- Figure out which mod types are to be displayed
    -- 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 ~= nil and not Shared.tableIsEmpty(recipeMods) then
                if recipeMods and not Shared.tableIsEmpty(recipeMods) then
modType.inUse = true
                    modType.inUse = true
end
                end
end
            end
end
        end
end
    end


local resultPart = {}
    local root = mw.html.create('table')
table.insert(resultPart, '{|class="wikitable sortable stickyHeader"')
        :addClass('wikitable sortable stickyHeader')
table.insert(resultPart, '\n|- class="headerRow-0"')
table.insert(resultPart, '\n!rowspan="2" colspan="2"|Constellation!!rowspan="2"| ' .. Icons.Icon({"Astrology", type='skill', notext='true'}) .. ' Level')
table.insert(resultPart, '!!rowspan="2"| XP!!rowspan="2"| Skills')


local repCount = 0
    -- Header row
for _, modType in ipairs(modTypes) do
    local headerRow = root:tag('tr')
if modType.inUse then
    headerRow:tag('th'):attr('rowspan', '2'):attr('colspan', '2'):wikitext('Constellation')
repCount = repCount + 1
    headerRow:tag('th'):attr('rowspan', '2'):wikitext(Icons.Icon({"Astrology", type='skill', notext='true'}) .. '<br>Level')
table.insert(resultPart, '!!colspan="2"| ' .. modType.name .. ' Stars')
    headerRow:tag('th'):attr('rowspan', '2'):wikitext('[[DLC]]')
end
    headerRow:tag('th'):attr('rowspan', '2'):wikitext('XP')
end
    headerRow:tag('th'):attr('rowspan', '2'):wikitext('Skills')
table.insert(resultPart, '\n|- class="headerRow-1"')
table.insert(resultPart, string.rep('\n! ' .. Icons.Icon({'Mastery', notext=true}) .. 'Level\n! Modifiers', repCount))


for i, cons in ipairs(recipes) do
    -- Mod types header
local modData = Skills._getConstellationModifiers(cons)
    local headerRow1 = root:tag('tr')
local name = cons.name
    for _, modType in ipairs(modTypes) do
local skillIconArray = {}
        if modType.inUse then
for j, skillID in ipairs(cons.skillIDs) do
            headerRow1:tag('th'):attr('colspan', '2'):wikitext(modType.name .. ' Stars')
table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'}))
        end
end
    end
local maxRows = 1
for _, modTypeData in pairs(modData) do
maxRows = math.max(maxRows, Shared.tableCount(modTypeData))
end
local rowSpan = (maxRows > 1 and 'rowspan="' .. maxRows .. '"') or ''


table.insert(resultPart, '\n|-')
    -- Subheaders for mod types
table.insert(resultPart, '\n|' .. rowSpan .. ' data-sort-value="' .. name .. '" id="'..name..'"| ')
    local headerRow2 = root:tag('tr')
table.insert(resultPart, Icons.Icon({name, type='constellation', notext=true}))
    for _, modType in ipairs(modTypes) do
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. Icons.getDLCColumnIcon(cons.id) .. name)
        if modType.inUse then
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.level)
            headerRow2:tag('th'):wikitext(Icons.Icon({'Mastery', notext='true'}) .. ' Level')
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.baseExperience)
            headerRow2:tag('th'):wikitext('Modifiers')
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. table.concat(skillIconArray, '<br/>'))
        end
    end


-- Generate table text for modifiers
    -- Data rows
for row = 1, maxRows, 1 do
    for i, cons in ipairs(recipes) do
for _, modType in ipairs(modTypes) do
        local modData = Skills._getConstellationModifiers(cons)
if modType.inUse then
        local name = cons.name
local masteryLevel = modType.levels[row]
        local skillIconArray = {}
local rowModData = modData[modType.modKey][row]
        for j, skillID in ipairs(cons.skillIDs) do
if masteryLevel == nil or rowModData == nil then
            table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'}))
table.insert(resultPart, '\n|colspan="2" class="table-na"| ')
        end
else
        local maxRows = 1
table.insert(resultPart, '\n|style="text-align:right"| ' .. masteryLevel)
        for _, modTypeData in pairs(modData) do
table.insert(resultPart, '\n| ' .. Modifiers.getModifiersText(rowModData, false, false, 10))
            maxRows = math.max(maxRows, Shared.tableCount(modTypeData))
end
        end
end
end
if row < maxRows then
table.insert(resultPart, '\n|-')
end
end
end
table.insert(resultPart, '\n|}')


return table.concat(resultPart)
        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)
2,875

edits