Module:Skills/Gathering/Sandbox: Difference between revisions

no edit summary
(Undo revision 75873 by Ricewind (talk))
Tag: Undo
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 in use
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 ~= nil 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.insert(resultPart, '{|class="wikitable sortable stickyHeader"')
    local tableRoot = root:tag('table')
table.insert(resultPart, '\n|- class="headerRow-0"')
    tableRoot:addClass('wikitable sortable stickyHeader')
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 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')


local repCount = 0
    -- Modifiers headers
for _, modType in ipairs(modTypes) do
    for _, modType in ipairs(modTypes) do
if modType.inUse then
        if modType.inUse then
repCount = repCount + 1
            headerRow:tag('th'):attr('colspan', 2):wikitext(modType.name .. ' Stars')
table.insert(resultPart, '!!colspan="2"| ' .. modType.name .. ' Stars')
        end
end
    end
end
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
    local headerRow2 = tableRoot:tag('tr'):addClass('headerRow-1')
local modData = Skills._getConstellationModifiers(cons)
    for _, modType in ipairs(modTypes) do
local name = cons.name
        if modType.inUse then
local skillIconArray = {}
            headerRow2:tag('th'):wikitext(Icons.Icon({'Mastery', notext=true}) .. ' Level')
for j, skillID in ipairs(cons.skillIDs) do
            headerRow2:tag('th'):wikitext('Modifiers')
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|-')
    -- Data rows
table.insert(resultPart, '\n|' .. rowSpan .. ' data-sort-value="' .. name .. '" id="'..name..'"| ')
    for _, cons in ipairs(recipes) do
table.insert(resultPart, Icons.Icon({name, type='constellation', notext=true}))
        local modData = Skills._getConstellationModifiers(cons)
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. Icons.getDLCColumnIcon(cons.id) .. name)
        local name = cons.name
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.level)
        local skillIconArray = {}
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.baseExperience)
        for _, skillID in ipairs(cons.skillIDs) do
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. table.concat(skillIconArray, '<br/>'))
            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


-- Generate table text for modifiers
        local row = tableRoot:tag('tr')
for row = 1, maxRows, 1 do
        row:tag('td'):attr('rowspan', maxRows):attr('data-sort-value', name):attr('id', name):wikitext(Icons.Icon({ name, type='constellation', notext=true }))
for _, modType in ipairs(modTypes) do
        row:tag('td'):attr('rowspan', maxRows):wikitext(Icons.getDLCColumnIcon(cons.id) .. name)
if modType.inUse then
        row:tag('td'):attr('rowspan', maxRows):addClass('text-right'):wikitext(cons.level)
local masteryLevel = modType.levels[row]
        row:tag('td'):attr('rowspan', maxRows):addClass('text-right'):wikitext(cons.baseExperience)
local rowModData = modData[modType.modKey][row]
        row:tag('td'):attr('rowspan', maxRows):wikitext(table.concat(skillIconArray, '<br/>'))
if masteryLevel == nil or rowModData == nil then
table.insert(resultPart, '\n|colspan="2" class="table-na"| ')
else
table.insert(resultPart, '\n|style="text-align:right"| ' .. masteryLevel)
table.insert(resultPart, '\n| ' .. Modifiers.getModifiersText(rowModData, false, false, 10))
end
end
end
if row < maxRows then
table.insert(resultPart, '\n|-')
end
end
end
table.insert(resultPart, '\n|}')


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


2,875

edits