League of Legends Wiki
Advertisement
League of Legends Wiki

Documentation for this module may be created at Module:EternalsData/doc

-- <pre>
local p = {}
 
local eternalsData = mw.loadData('Module:EternalsData/data')
local lib          = require('Module:Feature')
local color        = require('Module:Color')
local FN           = require('Module:Filename')

-- wrapper template Template:List_of_eternals
function p.eternalList(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else 
        if frame:getParent().args ~= nil then args = lib.arguments(lib.mergeFrames(frame, frame:getParent())) else args = lib.arguments(frame.args) end
    end

    args["series"]    = tonumber(args["series"])
    local resultTable = mw.html.create('table')
    
    local temp = resultTable
        :addClass('sortable article-table sticky-header')
        :css('width','100%')
        :css('text-align','left')
        :newline()
        :tag('tr')
            :tag('th')
                :wikitext('Champion')
                :css('white-space','nowrap')
            :done()
            :newline()
    if args["series"] == nil and args["champion"] ~= nil then 
        temp
            :tag('th')
                :wikitext('Series')
                :css('white-space','nowrap')
            :done()
            :newline()
    end
        temp
            :tag('th')
                :wikitext('Name')
                :css('white-space','nowrap')
            :done()
            :newline()
            :tag('th')
                :wikitext('Type')
                :css('white-space','nowrap')
            :done()
            :newline()
            :tag('th')
                :wikitext('Description')
                :css('white-space','nowrap')
            :done()
        :done()
    :done()
    :newline()
    
    local empressNode = mw.html.create('span')
    empressNode
        :css('color', 'violet')
        :css('vertical-align', 'text-top')
        :attr('data-sort-value', "empress")
        :wikitext("EMP")

    local guideNode = mw.html.create('span')
    guideNode
        :css('color', 'green')
        :css('font-weight', '600')
        :css('vertical-align', 'text-top')
        :attr('data-sort-value', "guide")
        :wikitext("GUI")

    local protectorNode = mw.html.create('span')
    protectorNode
        :css('color', 'yellow')
        :css('vertical-align', 'text-top')
        :attr('data-sort-value', "protector")
        :wikitext("PRT")
        
    local tricksterNode = mw.html.create('span')
    tricksterNode
        :css('color', 'purple')
        :css('vertical-align', 'text-top')
        :attr('data-sort-value', "trickster")
        :wikitext("TRK")
        
    local wardenNode = mw.html.create('span')
    wardenNode
        :css('color', 'blue')
        :css('vertical-align', 'text-top')
        :attr('data-sort-value', "warden")
        :wikitext("WRD")
        
    local warriorNode = mw.html.create('span')
    warriorNode
        :css('color', 'red')
        :css('vertical-align', 'text-top')
        :attr('data-sort-value', "warrior")
        :wikitext("WAR")
    
    local function eternalsRow(eternalChampion, eternalSeries, eternalName, eternalType, eternalDescription, legacy)
        local eternalsTableRow = mw.html.create('tr')
        -- Champion
        if (eternalChampion == "Common") then
            eternalsTableRow
                :tag('td')
                    :attr('data-sort-value', 0)
                    :css('white-space', 'nowrap')
                    :wikitext('Common')
                :done()
        else 
            eternalsTableRow
                :tag('td')
                :addClass('champion-icon')
                :attr('data-sort-value', eternalChampion)
                :attr('data-champion', eternalChampion)
                :attr('data-skin', "Original")
                :attr('data-game', "lol")
                :css('text-align', 'left')
                :css('white-space', 'nowrap')
                :wikitext('[[File:' .. FN.championcircle({eternalChampion, "Original"}) .. '|26px|link=' .. eternalChampion .. ']] ' .. eternalChampion)
            :done()
        end
        -- Series
        if args["series"] == nil and args["champion"] ~= nil then 
            eternalsTableRow
                :tag('td')
                    :wikitext(eternalSeries)
                :done()
        end
        
        local temp = eternalsTableRow
            :tag('td')
        
        -- Legacy
        if legacy then
            temp
                :wikitext(mw.text.decode('[[File:Legacy skin.png|26px|link=|Legacy]]&nbsp;'))
        end
        
        -- Name
        temp
            :addClass('eternal-icon')
            :attr('data-eternal', eternalName)
            :css('text-align', 'left')
            :wikitext(eternalName)
            
        -- Eternal Type
        astring = '<span style="color: cornflowerblue;font-size: large;font-weight: 600;">?</span>'
        if     (eternalType == "Empress") then
            astring = tostring(empressNode)
        elseif (eternalType == "Guide") then
            astring = tostring(guideNode)
        elseif (eternalType == "Protector") then
            astring = tostring(protectorNode)
        elseif (eternalType == "Trickster") then
            astring = tostring(tricksterNode)
        elseif (eternalType == "Warden") then
            astring = tostring(wardenNode)
        elseif (eternalType == "Warrior") then
            astring = tostring(warriorNode)
        end
        eternalsTableRow
            :tag('td')
                :attr('data-sort-value', eternalType or "Missing")
                :tag('span')
                    :attr('title', eternalType or 'Missing')
                    :wikitext(astring)
            :done()
        
        -- Description
        eternalsTableRow
            :tag('td')
                    :wikitext(eternalDescription)
            :done()
        return eternalsTableRow
    end
    
    -- Common Eternals
    if args["champion"] == nil then
        local commonEternals = eternalsData['Common']
        if commonEternals ~= nil and commonEternals[args["series"]] ~= nil then
            local seriesEternals = commonEternals[args["series"]]
            if seriesEternals ~= nil then
                local eternalsTable = {}
                for x in pairs(seriesEternals) do
                    table.insert(eternalsTable, x)
                end
                table.sort(eternalsTable)
                for _, eternalName in pairs(eternalsTable) do
                    -- Add row to table
                    resultTable
                        :newline()
                        :node(eternalsRow('Common', args["series"], eternalName, seriesEternals[eternalName]['eternal'], seriesEternals[eternalName]['description'], seriesEternals[eternalName]['legacy']))
                end
            end
        end
    end
    
    -- Unique Eternals
    local uniqueEternals = eternalsData['Unique']
    if uniqueEternals ~= nil then
        local championsTable = {}
        if args["champion"] == nil then
            for x in pairs(uniqueEternals) do
                table.insert(championsTable, x)    
            end
            table.sort(championsTable)
        else
            table.insert(championsTable, args["champion"])
        end
        for _, eternalChampion in pairs(championsTable) do
            local seriesTable = {}
            if args["series"] == nil then
                for x in pairs(uniqueEternals[eternalChampion]) do
                    table.insert(seriesTable, x)
                end
                table.sort(seriesTable)
            else
                table.insert(seriesTable, args["series"])
            end
            for _, eternalSeries in pairs(seriesTable) do
                local seriesEternals = uniqueEternals[eternalChampion][eternalSeries]
                if seriesEternals ~= nil then
                    local eternalsTable = {}
                    for x in pairs(seriesEternals) do
                        table.insert(eternalsTable, x)
                    end
                    table.sort(eternalsTable)
                    for _, eternalName in pairs(eternalsTable) do
                        -- Add row to table
                        resultTable
                        :newline()
                        :node(eternalsRow(eternalChampion, eternalSeries, eternalName, seriesEternals[eternalName]['eternal'], seriesEternals[eternalName]['description'], seriesEternals[eternalName]['legacy']))
                    end
                end
            end
        end
    end
    
    -- END
    resultTable:allDone()
    return tostring(resultTable)
end

-- wrapper template Template:Champion_eternals
function p.eternalPage(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else 
        if frame:getParent().args ~= nil then args = lib.arguments(lib.mergeFrames(frame, frame:getParent())) else args = lib.arguments(frame.args) end
    end
    local _champion = args['champion'] or args[1]
    local _series = tonumber(args['series'])
    local s = ''
    
    local function eternalsRows(eternalSeries)
        local rows = {}
        local eternalsTable = {}
        for eternalName in pairs(eternalSeries) do
            table.insert(eternalsTable, eternalName)
        end
        table.sort(eternalsTable)
        for _, eternalName in ipairs(eternalsTable) do
            local eternalType = eternalSeries[eternalName]['eternal']
            local eternalDescription = eternalSeries[eternalName]['description']
            local eternalLegacy = eternalSeries[eternalName]['legacy']
            local eternalRow = mw.html.create('div')
                :cssText('position:relative; display:flex; align-items:center; width:100%; overflow:auto; border: 1px solid #404040; box-sizing: border-box; margin-bottom: 12px')
            if eternalType == 'Empress' then
                eternalRow
                    :cssText('background:linear-gradient(25deg, rgba(196,102,255,0.1), rgba(196,102,255,0.05), rgba(1,10,19,0.3), rgba(1,10,19,0.4), rgba(1, 10, 19, 0.5));')
            elseif eternalType == 'Guide' then
                eternalRow
                    :cssText('background:linear-gradient(25deg, rgba(3,252,119,0.1), rgba(3,252,119,0.05), rgba(1,10,19,0.3), rgba(1,10,19,0.4), rgba(1, 10, 19, 0.5));')
            elseif eternalType == 'Protector' then
                eternalRow
                    :cssText('background:linear-gradient(25deg, rgba(255,251,31,0.1), rgba(255,251,31,0.05), rgba(1,10,19,0.3), rgba(1,10,19,0.4), rgba(1, 10, 19, 0.5));')
            elseif eternalType == 'Trickster' then
                eternalRow
                    :cssText('background:linear-gradient(25deg, rgba(227,3,252,0.1), rgba(227,3,252,0.05), rgba(1,10,19,0.3), rgba(1,10,19,0.4), rgba(1, 10, 19, 0.5));')
            elseif eternalType == 'Warden' then
                eternalRow
                    :cssText('background:linear-gradient(25deg, rgba(0,200,255,0.1), rgba(0,200,255,0.05), rgba(1,10,19,0.3), rgba(1,10,19,0.4), rgba(1, 10, 19, 0.5));')
            elseif eternalType == 'Warrior' then
                eternalRow
                    :cssText('background:linear-gradient(25deg, rgba(255,47,15,0.1), rgba(255,47,15,0.05), rgba(1,10,19,0.3), rgba(1,10,19,0.4), rgba(1, 10, 19, 0.5));')
            end
            eternalRow
                :tag('div')
                    :css('float', 'left')
                    :css('margin-right', '10px')
                    :wikitext('[[File:The ' .. eternalType .. ' Eternal unique icon.png|frameless|' .. eternalType .. '|link=Eternals#Types]]')
                :done()
            if eternalLegacy then
                eternalRow
                    :tag('div')
                        :cssText('position:absolute; top:82px; left:82px;')
                        :wikitext('[[File:Legacy skin.png|40px|Legacy|link=Eternals#Types]]')
                    :done()
            end
            eternalRow
                :tag('div')
                    :css('margin-right', '15px')
                    :wikitext('<span class="league-font" style="font-size:18px"><b>' .. eternalName .. '</b></span><br>' .. eternalDescription)
                :done()
            rows[#rows+1] = tostring(eternalRow)
        end
        return table.concat(rows)
    end
    if _series then
        local eternalSeries = eternalsData['Unique'][_champion][_series] or {}
	    s = eternalsRows(eternalSeries)
    else
        local allEternalSeries = eternalsData['Unique'][_champion] or {}
        local seriesTable = {}
        for series in pairs(allEternalSeries) do
            table.insert(seriesTable, series)
        end
        table.sort(seriesTable, function(a,b) return a > b end)
        local tabberargs = {}
        for series in ipairs(seriesTable) do
            tabberargs[#tabberargs+1] = 'Series '
            tabberargs[#tabberargs+1] = series
            tabberargs[#tabberargs+1] = '='
            tabberargs[#tabberargs+1] = eternalsRows(allEternalSeries[series])
            tabberargs[#tabberargs+1] = '|-|'
        end
        tabberargs = table.concat(tabberargs)
        s = frame:callParserFunction{ name = '#tag:tabber', args = tabberargs }
    end
    return s
end

return p
 
-- </pre>
-- [[Category:Lua]]