Anonymous

Module:Skills/Gathering/Sandbox: Difference between revisions

From Melvor Idle
Undo revision 75873 by Ricewind (talk)
(Undo revision 75874 by Ricewind (talk))
Tag: Undo
(Undo revision 75873 by Ricewind (talk))
Tag: Undo
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
    )
)


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


    local root = mw.html.create('table')
local resultPart = {}
        :addClass('wikitable sortable stickyHeader')
table.insert(resultPart, '{|class="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')


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


    -- Mod types header
for i, cons in ipairs(recipes) do
    local headerRow1 = root:tag('tr')
local modData = Skills._getConstellationModifiers(cons)
    for _, modType in ipairs(modTypes) do
local name = cons.name
        if modType.inUse then
local skillIconArray = {}
            headerRow1:tag('th'):attr('colspan', '2'):wikitext(modType.name .. ' Stars')
for j, skillID in ipairs(cons.skillIDs) do
        end
table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'}))
    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 ''


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


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


        local row = root:tag('tr')
return table.concat(resultPart)
        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