League of Legends Wiki

Want to contribute to this wiki?
Sign up for an account, and get started!
You can even turn off ads in your preferences.

Come join the LoL Wiki community Discord server!

READ MORE

League of Legends Wiki
No edit summary
No edit summary
Line 668: Line 668:
 
:tag('th')
 
:tag('th')
 
:wikitext('Champion')
 
:wikitext('Champion')
:css('width','135px')
+
--:css('width','135px')
 
:done()
 
:done()
 
:newline()
 
:newline()

Revision as of 05:45, 2 July 2020

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

-- <pre><nowiki>
local p    = {}

 
local lib       = require('Module:Feature')
-- local json      = require('Module:JSON')
-- local userError = require('Dev:User error')
local FN        = require('Module:Filename')

--[==[
    https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/parser/Parser.php
    https://www.mediawiki.org/wiki/Manual:Parser.php
    
    The actual parser does more complicated things in handleInternalLinks
    it uses the base pattern:
        legal chars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+"
        $tc = Title::legalChars() . '#%';
        # Match a link having the form [[namespace:link|alternate]]trail
		$e1 = "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
		# Match cases where there is no "]]", which might still be images
		$e1_img = "/^([{$tc}]+)\\|(.*)\$/sD";
]==]

function p.striplinks(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return striplinks(args[1])
end

function striplinks(instring)
    local ret = instring
    local subs = 0
    ret, subn = string.gsub(ret, '%[%[([-,:%w]+)|(%w+)%]%]', '%2')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[%s+(:?%w+:%w+)%]%]', ' %1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[:%s+(%w+:%w+)%]%]', ' %1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[:?(%s*%w+:%w+)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[:([%s%w]+)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[(%s+:%s+%w+:%w+)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[(%s+:[%s%w]*)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[([-,%w]+)%]%]', '%1')
    subs = subs + subn
    -- ret = string.gsub
    return ret
end

function p.striplinkstest(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local instring = args[1]
    local ret = instring
    local subs = 0
    ret, subn = string.gsub(ret, '%[%[([:%w]-)|(%w+)%]%]', '%2')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[%s+(:?%w+:%w+)%]%]', ' %1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[:%s+(%w+:%w+)%]%]', ' %1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[:?(%s*%w+:%w+)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[:([%s%w]+)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[(%s+:%s+%w+:%w+)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[(%s+:[%s%w]*)%]%]', '%1')
    subs = subs + subn
    ret, subn = string.gsub(ret, '%[%[(%w+)%]%]', '%1')
    subs = subs + subn
    -- ret = string.gsub
    return subs
end

--[=[
    does not strip URI links
    FSM States:
    s=0 Seen 
    s=1 Seen [
    s=2 Seen [\[
    s=3 Seen [\[ +
    s=4 Seen [\[ +:
    s=5 
    s=6 
    s=7 Seen [\[ *:?.*
    s=8 Seen [\[ *:?.*]
    s=9 Seen [\[ *:?.*|
    s=10 Seen [\[ *:?.*|.*
    s=11 Seen [\[ *:?.*|.*]
    s=11 Seen [\[ *:?.*|]
    s=13 Seen [\[: *
    s=. Seen [ +
    s=. Seen [ *.*
    s=. Seen [ *.*
    s=. Seen [ *.* *
    s=. Seen [ *.* *.*
]=]
function p.striplinks2(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local instring = args[1]
    local ret = ''
    local fstart, fend, bstart, bend
    local fcolon, fpipe = -1, -1
    local s = 0
    -- local strace = '0'
    for i = 1, #instring do
--        local nextchar = string.gmatch(args[1],'.')
        local nextchar = mw.ustring.sub(instring, i, i)
        if s == 0 then
            if nextchar == '[' then
                s = 1
                fstart = i
            else
                s = 0
                ret = ret .. nextchar
            end
        elseif s == 1 then --Seen [
            if nextchar == '[' then
                s = 2
                fend = i
            end
        elseif s == 2 then --Seen [[
            if nextchar == ' ' then
                s = 3
                fend = i-1
            elseif nextchar == ':' then
                s = 13
                fcolon = i
            else
                s = 7
            end
        elseif s == 3 then --Seen [[ +
            if nextchar == ' ' then
                s = 3
                fend = i-1
            elseif nextchar == ':' then
                s = 4
                fcolon = i
            else
                s = 7
                fend = i-1
            end
        elseif s == 4 then --Seen [\[ +:
            if nextchar == ']' then
                s = 8
                fcolon = -1
                bstart = i
            else
                s = 7
            end
        elseif s == 5 then
        elseif s == 6 then 
        elseif s == 7 then --Seen [\[ *:?.*
            if nextchar == '|' then
                s = 9
                fpipe = i
            elseif nextchar == ']' then
                s = 8
                bstart = i
            else
                s = 7
            end
        elseif s == 8 then --Seen [\[ *:?.*]
            if nextchar == ']' then
                s = 0
                if fcolon ~= -1 and fcolon ~= fstart + 2 then
                    ret = ret .. mw.ustring.sub(instring, fcolon, bstart - 1)
                    fcolon = -1
                elseif fcolon ~= -1 then
                    ret = ret .. mw.ustring.sub(instring, fcolon, bstart - 1)
                    fcolon = -1
                else
                    ret = ret .. mw.ustring.sub(instring, fend + 1, bstart - 1)
                    fcolon = -1
                end
            else
                s = 7
            end
        elseif s == 9 then --Seen [\[ *:?.*|
            if nextchar == ']' then
                s = 12
                bstart = i
            else
                s = 10
            end
        elseif s == 10 then --Seen [\[ *:?.*|.*
            if nextchar == ']' then
                s = 11
                bstart = i
            else
                s = 10
            end
        elseif s == 11 then --Seen [\[ *:?.*|.*]
            if nextchar == ']' then
                s = 0
                ret = ret .. mw.ustring.sub(instring, fpipe + 1, bstart - 1)
                fcolon = -1
            else
            end
        elseif s == 12 then --Seen [\[ *:?.*|]
            if nextchar == ']' then
                s = 0
                ret = ret .. mw.ustring.sub(instring, fend + 1, fpipe - 1)
                fcolon = -1
            else
                s = 10
            end
        elseif s == 13 then --Seen [\[: *
            if nextchar == ' ' then
                s = 13
            elseif nextchar == '|' then
                s = 0
                ret = ret .. mw.ustring.sub(instring, fstart, i)
            elseif nextchar == ']' then
                s = 0
                ret = ret .. mw.ustring.sub(instring, fstart, i)
            else
                s = 7
                fcolon = i-1
            end
        elseif s == 14 then 
        elseif s == 15 then 
        elseif s == 16 then
        else
            return instring
        end
        -- strace = strace .. ' ' .. s
    end
    if s ~= 0 then ret = ret .. mw.ustring.sub(instring, fstart, -1) end
    -- if s ~= 0 then return 'error, state trace: ' .. strace .. '; ' .. ret end
    if args[2] ~= nil then ret = '<nowiki>' .. ret .. '</nowiki>' end
    -- if args[2] ~= nil then return ret .. ': ' .. strace end
    return ret
end

function p.querychamps(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local lolData   = mw.loadData('Module:ChampionData/data')
    local get       = require('Module:ChampionData/getter')
    local stat      = args['stat']
    local value     = args['value']
    local output    = args['output']
    local result   = {}
    for champname in pairs(lolData) do
        local v = get[stat](champname)
        if v == nil then
        elseif type(v) == 'table' then
            for _, v2 in pairs(v) do
                if '' .. v2 == value then
                    table.insert(result, champname)
                    break
                end
            end
        elseif '' .. v == value then 
            table.insert(result, champname)
        end
    end
    
    table.sort(result)
    if output ~= nil then
        if output == "custom" then 
            return frame:preprocess(lib.tbl_concat{result, prepend = args['prepend'], append = args['append'], separator = args['separator'], index = args["index"]})
        elseif output == "template" then 
            return frame:preprocess(lib.tbl_concat{result, prepend = "{{" .. args['t_name'] .. "|", append = "}}", separator = args['separator']})
        else
            return lib.tbl_concat{result}
        end
    else
        return lib.tbl_concat{result}
    end
end

function p.queryoptions(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local lolData   = mw.loadData('Module:ChampionData/data')
    local get       = require('Module:ChampionData/getter')
    local stat      = args['stat']
    local output    = args['output']
    local champ1     = false
    if champ1 == false then
        if args['t_name'] == 'cai' or args['t_name'] == 'ai' then
            champ1 = true
        end
    end
    local result   = {}
    for champname in pairs(lolData) do
        if stat == 'skills' then
            local v = get['skill_i'](champname)
            for k2,v2 in pairs(v) do
                if result[v2] == nil then
                    if output == "template" and champ1 then
                        result[v2] = v2 .. '|' .. champname
                    else
                        result[v2] = v2
                    end
                end
            end
            local v = get['skill_q'](champname)
            for k2,v2 in pairs(v) do
                if result[v2] == nil then
                    if output == "template" and champ1 then
                        result[v2] = v2 .. '|' .. champname
                    else
                        result[v2] = v2
                    end
                end
            end
            local v = get['skill_w'](champname)
            for k2,v2 in pairs(v) do
                if result[v2] == nil then
                    if output == "template" and champ1 then
                        result[v2] = v2 .. '|' .. champname
                    else
                        result[v2] = v2
                    end
                end
            end
            local v = get['skill_e'](champname)
            for k2,v2 in pairs(v) do
                if result[v2] == nil then
                    if output == "template" and champ1 then
                        result[v2] = v2 .. '|' .. champname
                    else
                        result[v2] = v2
                    end
                end
            end
            local v = get['skill_r'](champname)
            for k2,v2 in pairs(v) do
                if result[v2] == nil then
                    if output == "template" and champ1 then
                        result[v2] = v2 .. '|' .. champname
                    else
                        result[v2] = v2
                    end
                end
            end
        elseif stat == 'key' then
            if false and (
                lolData[champname]["date"] == ("Upcoming" or "N/A" or "Cancelled" or "")
                or 
                champname == ("Mega Gnar" or "Rhaast" or "Shadow Assassin") )
                then
                --ignore champion                                           
            else
                table.insert(result, champname)
            end 
        else
            local v = get[stat](champname)
            if type(v) == 'table' then
                for k2,v2 in pairs(v) do
                    if result[v2] == nil then
                        if output == "template" and champ1 then
                            result[v2] = v2 .. '|' .. champname
                        else
                            result[v2] = v2
                        end
                    end
                end
            else
                if v == nil then
                elseif result[v] == nil then
                    result[v] = v
                end
            end
        end
    end
    result[''] = nil
    table.sort(result)
    if output ~= nil then
        if output == "custom" then 
            return frame:preprocess(lib.tbl_concat{result, prepend = args['prepend'], append = args['append'], separator = args['separator'], index = args["index"]})
        elseif output == "template" then 
            return frame:preprocess(lib.tbl_concat{result, prepend = "{{" .. args['t_name'] .. "|", append = "}}", separator = args['separator']})
        elseif output == "table" then
            return tableprettyprint(result)
        else
            return lib.tbl_concat{result}
        end
    else
        return lib.tbl_concat{result}
    end
end

function p.test(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local champname = args[1]
    targeting = frame:expandTemplate{title = 'Data_Aatrox/Deathbringer_Stance', args = {'pst2', 'targeting'}}
    return targeting
    
end

function p.test2(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local champname = args[1]
    return p.test3{champname}
end

function p.test3(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    return args[1] .. ' returned'
end

function p.testtbl_concat(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    args["pre"] = args["pre"] or args["prepend"]   or ""
    args["app"] = args["app"] or args["append"]    or ""
    args["sep"] = args["sep"] or args["separator"] or ","
    args["tbl"] = args["tbl"] or args[1]
 
    local s = ""
 
    if args["index"] ~= nil then
        s = s .. args["pre"] .. args["tbl"][tonumber(args["index"])] .. args["app"]
    else
        local num = 0
        for i, v in ipairs(args["tbl"]) do
            if s ~= "" then
                s = s .. args["sep"]
            end
            s = s .. args["pre"] .. v .. args["app"]
            num = num + 1
        end
        local keys = {}
        for k in pairs(args["tbl"]) do
            table.insert(keys, k)
            num = num - 1
        end
        if num < 0 then
            table.sort(keys)
            for _, k in ipairs(keys) do
                if type(k) ~= 'number' then
                    if s ~= "" then
                        s = s .. args["sep"]
                    end
                    s = s .. args["pre"] .. args["tbl"][k] .. args["app"]
                end
            end
        end
    end
 
    return s
end

function p.transfer(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local lolData   = mw.loadData('Module:ChampionData/data')
    local get       = require('Module:ChampionData/getter')
    local stat      = args['stat']
    local output    = args['output']
    local result    = ''
    local sorted    = {} 
    for champname in pairs(lolData) do
        table.insert(sorted, champname)
    end
    table.sort(sorted)
    for _,champname in ipairs(sorted) do
        result = result .. '["' .. champname .. '"] = {\n'
        result = result .. '["skill_i"] = {\n'
        local v = get['skill_i'](champname)
        for k2,v2 in ipairs(v) do
            result = result .. '["' .. v2 .. '"] = {\n},\n'
        end
        result = result .. '},\n'
        result = result .. '["skill_q"] = {\n'
        local v = get['skill_q'](champname)
        for k2,v2 in ipairs(v) do
            result = result .. '["' .. v2 .. '"] = {\n},\n'
        end
        result = result .. '},\n'
        result = result .. '["skill_w"] = {\n'
        local v = get['skill_w'](champname)
        for k2,v2 in ipairs(v) do
            result = result .. '["' .. v2 .. '"] = {\n},\n'
        end
        result = result .. '},\n'
        result = result .. '["skill_e"] = {\n'
        local v = get['skill_e'](champname)
        for k2,v2 in ipairs(v) do
            result = result .. '["' .. v2 .. '"] = {\n},\n'
        end
        result = result .. '},\n'
        result = result .. '["skill_r"] = {\n'
        local v = get['skill_r'](champname)
        for k2,v2 in ipairs(v) do
            result = result .. '["' .. v2 .. '"] = {\n},\n'
        end
        result = result .. '},\n'
        result = result .. '},\n'
    end
    return result
end

function p.getfi(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local flashData   = mw.loadData('Module:Sandbox/DutyS12345/data')
    
    local champion = args['champion'] or args[1]
    local ability   = args['ability'] or args[2]
    local output    = args['output']  or args[3] or nil
    local s         = ''
    
    champion = lib.validateName(champion)
    
    local fi = flashData[champion]['skill_i'][ability]
        or flashData[champion]['skill_q'][ability]
        or flashData[champion]['skill_w'][ability]
        or flashData[champion]['skill_e'][ability]
        or flashData[champion]['skill_r'][ability]
        or nil
    
    local notes = flashData[champion]['skill_i']['notes']
        or flashData[champion]['skill_q']['notes']
        or flashData[champion]['skill_w']['notes']
        or flashData[champion]['skill_e']['notes']
        or flashData[champion]['skill_r']['notes']
        or nil
        
    if fi ~= nil and fi ~= '' then
        for i,v in pairs(fi) do
            if s ~= '' then
                s = s .. ', '
            end
            s = s .. i .. ':' .. v
        end
    end
    
    if notes ~= nil and notes ~= '' then
        abilitynotes = notes[ability]
        if abilitynotes ~= nil then
            if s ~= '' then
                s = s .. ', '
            end
            s = s .. abilitynotes
        end
    end
    
    if output ~= nil then
        if output == 'notes' then
            return s
        else
            return ''
        end
    else
        return s
    end
end

function p.fiTable(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local fiData        = mw.loadData('Module:Sandbox/DutyS12345/data')
    local lolData       = mw.loadData('Module:ChampionData/data')
    local lolTable      = {}
    local tablenode     = mw.html.create('table')
    tablenode
            :addClass('sortable wikitable sticky-header')
            :css('width', '100%')
            --:css('text-align', 'right')
            :css('white-space', 'nowrap')
            :newline()
    
    tablenode
        :tag('tr')
            :tag('th')
                :wikitext('Champion')
                --:css('width', '180px')
                --:attr('class', 'unsortable')
            :done()
            :tag('th')
                :wikitext('Ability')
                --:attr('class', 'unsortable')
            :done()
            :tag('th')
                :wikitext('Targeting Type')
            :done()
            :tag('th')
                :wikitext('FI 1')
            :done()
            :tag('th')
                :wikitext('FI 2')
            :done()
            :tag('th')
                :wikitext('FI 3')
            :done()
        :done()
        :newline()
    
    for champname in pairs(lolData) do
        if  lolData[champname]['date'] == ('Upcoming' or 'N/A' or 'Cancelled' or '')
            then
            --ignore champion
        else
            table.insert(lolTable, champname)
        end
    end
    table.sort(lolTable)
    
    for _, champion in ipairs(lolTable) do
        local champrow  = mw.html.create('')
        local abilities = {}
        local sklist = {'skill_i', 'skill_q', 'skill_w', 'skill_e', 'skill_r'}
        local numabilities = 0
        for _, sk in ipairs(sklist) do
            local skills = lolData[champion][sk]
            for _, skillname in ipairs(skills) do
                numabilities = numabilities + 1
            end
        end
        for i, sk in ipairs(sklist) do
            local abilities = lolData[champion][sk]
            for j, ability in ipairs(abilities) do
                local tablerow  = mw.html.create('tr')
                if i == 1 and j == 1 then
                    tablerow
                        :tag('td')
                            :wikitext('[[File:' .. FN.championsquare{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                            :attr('data-sort-value', champion)
                            :attr('rowspan', numabilities)
                        :done()
                end
                local targeting = frame:expandTemplate{title = 'Data_' .. champion .. '/' .. ability, args = {'pst2', 'targeting'}}
                if targeting == nil then
                    targeting = ''
                end
                local linkfreetargeting = striplinks(targeting)
                tablerow
                    :tag('td')
                        :wikitext('[[File:' .. FN.ability{ability} .. '|20px|alt=' .. ability .. '|link=Template:Data_' .. champion .. '/' .. ability .. ']] [[Template:Data_' .. champion .. '/' .. ability .. '|' .. ability .. ']]')
                        :attr('data-sort-value', i)
                    :done()
                    :tag('td')
                        :wikitext(targeting)
                        :attr('data-sort-value', linkfreetargeting)
                    :done()
                :done()
                champrow
                    :node(tablerow)
            end
        end
        champrow
        :done()
    
        if champrow ~= nil then
        tablenode
            :node(champrow)
            :newline()
        end
    end
    tablenode:allDone()
    return frame:preprocess(tostring(tablenode))
end

local eternalsData = mw.loadData('Module:EternalsData/data')

function p.eternallist(frame)
    local lang           = mw.language.new( "en" )
    local eternals_table = mw.html.create('table')
 
    eternals_table
        :addClass('sortable article-table sticky-header')
        :css('width','100%')
        :css('text-align','left')
        :newline()
        :tag('tr')
            :tag('th')
                :wikitext('Champion')
                --:css('width','135px')
            :done()
            :newline()
--[=[
            :tag('th')
                :wikitext('Set')
            :done()
--]=]
            :newline()
            :tag('th')
                :wikitext('Name')
            :done()
            :newline()
            :tag('th')
                :wikitext('Type')
                :css('width','26px')
            :done()
            :newline()
            :tag('th')
                :wikitext('Description')
            :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 eternalstable = {}
    for x in pairs(eternalsData) do
        table.insert(eternalstable, x)
    end
    table.sort(eternalstable)

    for _, eternalname in pairs(eternalstable) do
        
        local t            = eternalsData[eternalname]
        local eternals_row = mw.html.create('tr')
        local temp         = ""

        -- Champion
        if (t["type"] == "Common") then
            eternals_row
                :tag('td')
                    :attr('data-sort-value', 0)
                    :wikitext(t["type"])
                :done()
        else 
            eternals_row
                :tag('td')
                :addClass('champion-icon')
                :attr('data-sort-value', t["champion"])
                :attr('data-champion', t["champion"])
                :attr('data-skin', "Original")
                :css('text-align', 'left')
                :wikitext('[[File:' .. FN.championcircle({t["champion"], "Original"}) .. '|26px|link=' .. t["champion"] .. ']] ' .. t["champion"])
            :done()
        end


        -- Name
        eternals_row
            :tag('td')
                :addClass('eternal-icon')
                :attr('data-eternal', eternalname)
                :css('text-align', 'left')
                :wikitext(eternalname)
            :done()

        -- Eternal Type
        astring = '<span style="color: cornflowerblue;font-size: large;font-weight: 600;">?</span>'
        if (t["eternal"] == "Empress") then
            astring = tostring(empressnode)
        end
        if (t["eternal"] == "Guide") then
            astring = tostring(guidenode)
        end
        if (t["eternal"] == "Protector") then
            astring = tostring(protectornode)
        end
        if (t["eternal"] == "Trickster") then
            astring = tostring(tricksternode)
        end
        if (t["eternal"] == "Warden") then
            astring = tostring(wardennode)
        end
        if (t["eternal"] == "Warrior") then
            astring = tostring(warriornode)
        end
        eternals_row
            :tag('td')
                :attr('data-sort-value', t["eternal"] or "Missing")
                :tag('span')
                    :attr('title', t["eternal"] or 'Missing')
                    :wikitext(astring)
            :done()
        
        -- Description
        eternals_row
            :tag('td')
                    :wikitext(t["description"])
            :done()

        -- Add skin row to the table
        eternals_table
            :newline()
            :node(eternals_row)
    end
    -- END
 
    eternals_table:allDone()
    return tostring(eternals_table)
end

function tableprettyprint(tbl)
    local s = ''
    for k,v in pairs(tbl) do
        if k == nil then
            s = s .. 'nil' .. ' : '
        else
            s = s .. k .. ' : ' 
        end
        if v == nil then
            s = s .. 'nil' .. '<br>'
        else
            s = s .. v .. '<br>'
        end
    end
    return s
end

function p.statTable(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    
    local _stat     = args[1]
    local lolData   = mw.loadData('Module:ChampionData/data')
    local lolTable  = {}
    local tablenode = mw.html.create('table')
    
    local convert   = {
        ["Health"]          = "hp",
        ["Health regen"]    = "hp5",
        ["Mana"]            = "mp",
        ["Mana regen"]      = "mp5",
        ["Armor"]           = "arm",
        ["Magic resist"]    = "mr",
        ["Attack damage"]   = "dam",
        ["Move speed"]      = "ms",
        ["Attack speed"]    = "as"
    }
-- \/\/\/
    if _stat == "Base" then
        tablenode
            :addClass('sortable wikitable sticky-header')
            :css('width', '100%')
            :css('text-align', 'right')
            :css('white-space', 'nowrap')
            :newline()
-- /\/\/\
-- \/\/\/
    elseif _stat == "Base 18" then
        tablenode
            :addClass('sortable wikitable sticky-header')
            :css('width', '100%')
            :css('text-align', 'center')
            :css('white-space', 'nowrap')
            :tag('caption')
                :wikitext('Champion statistics at level 18 (without skill bonuses)')
            :done()
            :newline()
-- /\/\/\
-- \/\/\/
    elseif _stat == "Manaless" then
        tablenode
            :addClass('sortable wikitable')
            :css('width', '90%')
            :css('text-align', 'center')
            :css('white-space', 'nowrap')
            :css('margin-left', '5%')
            :newline()
-- /\/\/\
-- \/\/\/
    elseif _stat == "Ratings" then
        tablenode
            :addClass('sortable article-table sticky-header')
            :css('width', '100%')
            :css('text-align', 'center')
            :css('white-space', 'nowrap')
            :newline()
    else
-- /\/\/\
    tablenode
        :addClass('sortable article-table sticky-header')
        :css('width', '100%')
        :css('text-align', 'center')
        :newline()
-- \/\/\/
    end
-- /\/\/\
    if _stat == "Attack speed" then
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('Champion')
                    :css('width', '180px')
                :done()
                :tag('th')
                    :wikitext('Base')
                :done()
                :tag('th')
                    :wikitext('AS Ratio')
                :done()
                :tag('th')
                    :wikitext('Deviation')
                :done()
                :tag('th')
                    :wikitext('Bonus growth coefficient')
                :done()
                :tag('th')
                    :wikitext('Bonus at level 18')
                :done()
                :tag('th')
                    :wikitext('Value at level 18')
                :done()
                :tag('th')
                    :wikitext('Additional AS needed to cap at level 18')
                :done()
            :done()
            :newline()
    elseif _stat == "Basic attack" then
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('Champion')
                    :css('width', '180px')
                :done()
                :tag('th')
                    :wikitext('Attack range')
                :done()
                :tag('th')
                    :wikitext('Range type')
                :done()
                :tag('th')
                    :wikitext('Missile speed')
                :done()
                :tag('th')
                    :wikitext('Windup')
                :done()
                :tag('th')
                    :wikitext('Windup modifier')
                :done()
            :done()
            :newline()
    elseif _stat == "Hitbox" then
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('Champion')
                    :css('width', '180px')
                :done()
                :tag('th')
                    :wikitext('Gameplay radius')
                :done()
                :tag('th')
                    :wikitext('Selection radius')
                :done()
                :tag('th')
                    :wikitext('Pathing radius')
                :done()
                :tag('th')
                    :wikitext('Acquisition radius')
                :done()
            :done()
            :newline()
-- \/\/\/
    elseif _stat == "Base" then
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('[[Champion]]s')
                :done()
                :tag('th')
                    :wikitext('[[Health|HP]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('HP+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Health regeneration|HP5]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('HP5+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Mana|MP]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('MP+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Mana regeneration|MP5]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('MP5+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Attack damage|AD]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('AD+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Attack speed|AS]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('AS+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Armor|AR]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('AR+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Magic resistance|MR]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('MR+')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Movement speed|MS]]')
                    :css('width', '4em')
                :done()
                :tag('th')
                    :wikitext('[[Range]]')
                    :css('width', '4em')
                :done()
            :done()
            :newline()
-- /\/\/\
-- \/\/\/
    elseif _stat == "Base 18" then
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('Champion')
                    :css('color', 'black')
                    :css('background-color', 'white')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('HP')
                    :css('color', 'black')
                    :css('background-color', 'lightgreen')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('HP5')
                    :css('color', 'black')
                    :css('background-color', 'lightgreen')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('MP')
                    :css('color', 'black')
                    :css('background-color', 'lightblue')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('MP5')
                    :css('color', 'black')
                    :css('background-color', 'lightblue')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('AD')
                    :css('color', 'black')
                    :css('background-color', '#ffaaaa')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('AS')
                    :css('color', 'black')
                    :css('background-color', '#ffaaaa')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('AR')
                    :css('color', 'black')
                    :css('background-color', '#ffffaa')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('MR')
                    :css('color', 'black')
                    :css('background-color', '#ffffaa')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('Range')
                :done()
                :tag('th')
                    :attr('data-sort-type', 'number')
                    :wikitext('MS')
                :done()
            :done()
            :newline()
-- /\/\/\
-- \/\/\/
    elseif _stat == "Manaless" then
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('Champion')
                :done()
                :tag('th')
                    :wikitext('Secondary Resource')
                :done()
            :done()
            :newline()
-- /\/\/\
-- \/\/\/
    elseif _stat == "Ratings" then
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('Champion')
                :done()
                :tag('th')
                    :wikitext('Primary')
                :done()
                :tag('th')
                    :wikitext('Secondary')
                :done()
                :tag('th')
                    :wikitext('[[File:Damage rating.png|15px|link=]]')
                :done()
                :tag('th')
                    :wikitext('[[File:Toughness rating.png|15px|link=]]')
                :done()
                :tag('th')
                    :wikitext('[[File:Control rating.png|15px|link=]]')
                :done()
                :tag('th')
                    :wikitext('[[File:Mobility rating.png|15px|link=]]')
                :done()
                :tag('th')
                    :wikitext('[[File:Utility rating.png|15px|link=]]')
                :done()
                :tag('th')
                    :wikitext('Style')
                :done()
                :tag('th')
                    :wikitext(frame:expandTemplate{title='sti', args={'Adaptive Damage',icononly='true'}})
                :done()
                :tag('th')
                    :wikitext('Difficulty')
                :done()
            :done()
            :newline()
-- /\/\/\
    else
        tablenode
            :tag('tr')
                :tag('th')
                    :wikitext('Champion')
                    :css('width', '180px')
                :done()
                :tag('th')
                    :wikitext('Base')
                :done()
                :tag('th')
                    :wikitext('Growth coefficient')
                :done()
                :tag('th')
                    :wikitext('Value at 18')
                :done()
            :done()
            :newline()
    end
    
    for champname in pairs(lolData) do
        if  
            lolData[champname]["date"] == ("Upcoming" or "N/A" or "Cancelled" or "")
            or 
            champname == ("Rhaast" or "Shadow Assassin")
            then
            --ignore champion
        else
            table.insert(lolTable, champname)
        end
    end
    table.sort(lolTable)
    
    for _, champion in pairs(lolTable) do
        local t         = lolData[champion]["stats"]
        local tablerow  = mw.html.create('tr')
        
        if _stat == "Attack speed" then
            local as_base   = t["as_base"]
            local as_ratio  = t["as_ratio"]
            local bonus_lvl = t["as_lvl"]
            local bonus_18  = 0 + bonus_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1))
            local variation = string.format("%.f", 100 - 100 / as_base * as_ratio, 3)
                
            if variation == "-0" then
                variation = "0"
            end
            
            local disp_name = champion
            if champion == "Mega Gnar" then disp_name = "Gnar (Mega)" end
            
            if champion == "Jhin" then
                tablerow
                    :tag('td')
                        :attr('data-sort-value', disp_name)
                        :css('text-align', 'left')
                        :wikitext("[[File:" .. FN.championcircle{champion} .. "|20px|alt=" .. champion .. "|link=" .. champion .. "]] [[" .. champion .. "]] <span title='Jhin&#39;s growth increases his base attack speed. He does not gain &#39;bonus attack speed&#39;.'><sup>note</sup></span>")
                    :done()
                    :tag('td')
                        :wikitext(string.format("%0.3f", as_base, 3))
                    :done()
                    :tag('td')
                        :wikitext(string.format("%0.3f", as_ratio, 3))
                    :done()
                    :tag('td')
                        :wikitext("N/A")
                    :done()
                    :tag('td')
                        :wikitext(bonus_lvl .. "%")
                    :done()
                    :tag('td')
                        :wikitext(bonus_18 .. "%")
                    :done()
                    :tag('td')
                        :wikitext(string.format("%0.3f", as_base + as_base * (bonus_18 / 100), 3))
                    :done()
                    :tag('td')
                        :attr('data-sort-value', "9999%")
                        :wikitext(string.format("%0.0f", (2.5 / as_ratio - 1) * 100 - bonus_18, 3) .. "%")
                    :done()
                :done()
            else
                tablerow
                    :tag('td')
                        :attr('data-sort-value', disp_name)
                        :css('text-align', 'left')
                        :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                    :done()
                    :tag('td')
                        :wikitext(string.format("%0.3f", as_base, 3))
                    :done()
                    :tag('td')
                        :wikitext(string.format("%0.3f", as_ratio, 3))
                    :done()
                    :tag('td')
                        :wikitext(variation .. "%")
                    :done()
                    :tag('td')
                        :wikitext(bonus_lvl .. "%")
                    :done()
                    :tag('td')
                        :wikitext(bonus_18 .. "%")
                    :done()
                    :tag('td')
                        :wikitext(string.format("%0.3f", as_base + as_ratio * (bonus_18 / 100), 3))
                    :done()
                    :tag('td')
                        :wikitext(string.format("%0.0f", (2.5 / as_ratio - 1) * 100 - bonus_18, 3) .. "%")
                    :done()
                :done()
            end
        elseif _stat == "Basic attack" then
            local windup
            if (t["attack_cast_time"] and t["attack_total_time"]) then
                windup = t["attack_cast_time"] / t["attack_total_time"]
            else
                windup = 0.3 + (t["attack_delay_offset"] or 0)
            end
            
            local windup_mod
            if t["windup_modifier"] == nil then
                windup_mod = "N/A"
            else
                windup_mod = math.floor(t["windup_modifier"] * 1000 + 0.5) / 1000
            end
            
            tablerow
                :tag('td')
                    :attr('data-sort-value', champion)
                    :css('text-align', 'left')
                    :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                :done()
                :tag('td')
                    :wikitext(t["range"])
                :done()
                :tag('td')
                    :wikitext(lolData[champion]["rangetype"])
                :done()
                :tag('td')
                    :wikitext(t["missile_speed"] or "N/A")
                :done()
                :tag('td')
                    :wikitext((math.floor(math.floor(windup*100*1000+0.5)/1000*100+0.5)/100) .. "%")
                :done()
                :tag('td')
                    :wikitext(windup_mod)
                :done()
            :done()
        elseif _stat == "Hitbox" then
            tablerow
                :tag('td')
                    :attr('data-sort-value', champion)
                    :css('text-align', 'left')
                    :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                :done()
                :tag('td')
                    :wikitext(math.floor(t["gameplay_radius"] or 65 + 0.5))
                :done()
                :tag('td')
                    :wikitext(math.floor(t["selection_radius"] or 0 + 0.5))
                :done()
                :tag('td')
                    :wikitext(math.floor(t["pathing_radius"] or 0 + 0.5))
                :done()
                :tag('td')
                    :wikitext(math.floor(t["acquisition_radius"] or 750 + 0.5))
                :done()
            :done()
-- \/\/\/
        elseif _stat == "Base" then
            local FD        = require('Module:Fd')
            
            local hp_base = FD.get{["args"]={tostring(t["hp_base"])}}
            local hp_lvl  = FD.get{["args"]={tostring(t["hp_lvl"])}}
            local hp5_base = FD.get{["args"]={tostring(t["hp5_base"])}}
            local hp5_lvl  = FD.get{["args"]={tostring(t["hp5_lvl"])}}
            local mp_base = FD.get{["args"]={tostring(t["mp_base"])}}
            local mp_lvl  = FD.get{["args"]={tostring(t["mp_lvl"])}}
            local mp5_base = FD.get{["args"]={tostring(t["mp5_base"])}}
            local mp5_lvl  = FD.get{["args"]={tostring(t["mp5_lvl"])}}
            local dam_base = FD.get{["args"]={tostring(t["dam_base"])}}
            local dam_lvl  = FD.get{["args"]={tostring(t["dam_lvl"])}}
            local as_base = FD.get{["args"]={tostring(t["as_base"])}}
            local as_lvl  = FD.get{["args"]={tostring(t["as_lvl"])}}
            local arm_base = FD.get{["args"]={tostring(t["arm_base"])}}
            local arm_lvl  = FD.get{["args"]={tostring(t["arm_lvl"])}}
            local mr_base = FD.get{["args"]={tostring(t["mr_base"])}}
            local mr_lvl  = FD.get{["args"]={tostring(t["mr_lvl"])}}
            local ms  = FD.get{["args"]={tostring(t["ms"])}}
            local range = FD.get{["args"]={tostring(t["range"])}}
            
            tablerow
                :tag('td')
                    :attr('data-sort-value', champion)
                    :css('text-align', 'left')
                    :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                :done()
                :tag('td')
                    :wikitext(hp_base)
                :done()
                :tag('td')
                    :wikitext('+' .. hp_lvl)
                :done()
                :tag('td')
                    :wikitext(hp5_base)
                :done()
                :tag('td')
                    :wikitext('+' .. hp5_lvl)
                :done()
                :tag('td')
                    :wikitext(mp_base)
                :done()
                :tag('td')
                    :wikitext('+' .. mp_lvl)
                :done()
                :tag('td')
                    :wikitext(mp5_base)
                :done()
                :tag('td')
                    :wikitext('+' .. mp5_lvl)
                :done()
                :tag('td')
                    :wikitext(dam_base)
                :done()
                :tag('td')
                    :wikitext('+' .. dam_lvl)
                :done()
                :tag('td')
                    :wikitext(as_base)
                :done()
                :tag('td')
                    :wikitext('+' .. as_lvl .. '%')
                :done()
                :tag('td')
                    :wikitext(arm_base)
                :done()
                :tag('td')
                    :wikitext('+' .. arm_lvl)
                :done()
                :tag('td')
                    :wikitext(mr_base)
                :done()
                :tag('td')
                    :wikitext('+' .. mr_lvl)
                :done()
                :tag('td')
                    :wikitext(ms)
                :done()
                :tag('td')
                    :wikitext(range)
                :done()
            :done()
-- /\/\/\
-- \/\/\/
        elseif _stat == "Base 18" then
            local FD        = require('Module:Fd')
            
            local hp_base = tonumber(t["hp_base"])
            local hp_lvl  = tonumber(t["hp_lvl"])
            local hp_18 = FD.get{["args"]={tostring(hp_base + hp_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))}}
            local hp5_base = tonumber(t["hp5_base"])
            local hp5_lvl  = tonumber(t["hp5_lvl"])
			local hp5_18 = FD.get{["args"]={tostring(hp5_base + hp5_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))}}
            local mp_base = tonumber(t["mp_base"])
            local mp_lvl  = tonumber(t["mp_lvl"])
			local mp_18 = FD.get{["args"]={tostring(mp_base + mp_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))}}
            local mp5_base = tonumber(t["mp5_base"])
            local mp5_lvl  = tonumber(t["mp5_lvl"])
			local mp5_18 = FD.get{["args"]={tostring(mp5_base + mp5_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))}}
            local dam_base = tonumber(t["dam_base"])
            local dam_lvl  = tonumber(t["dam_lvl"])
			local dam_18 = FD.get{["args"]={tostring(dam_base + dam_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))}}
            local as_base = tonumber(t["as_base"])
            local as_ratio  = tonumber(t["as_ratio"])
            local as_lvl  = tonumber(t["as_lvl"])
            local bonus_as_18  = 0 + as_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1))
            local as_18 = string.format("%0.3f", as_base + as_ratio * (bonus_as_18 / 100), 3)
            if champion == "Jhin" then as_18 = string.format("%0.3f", as_base + as_base * (bonus_as_18 / 100), 3) end
            as_18 = FD.get{["args"]={as_18}}
            
            local arm_base = tonumber(t["arm_base"])
            local arm_lvl  = tonumber(t["arm_lvl"])
			local arm_18 = FD.get{["args"]={tostring(arm_base + arm_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))}}
            local mr_base = tonumber(t["mr_base"])
            local mr_lvl  = tonumber(t["mr_lvl"])
			local mr_18 = FD.get{["args"]={tostring(mr_base + mr_lvl * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))}}
            local range = FD.get{["args"]={tostring(t["range"])}}
            local ms  = FD.get{["args"]={tostring(t["ms"])}}
            
            
            
            local resource = lolData[champion]["resource"]
            if resource == "Rage"
            or resource == "Heat"
            or resource == "Grit"
            or resource == "Fury"
            or resource == "Shield"
            or resource == "Bloodthirst"
            or resource == "Courage"
            or resource == "Health"
            or resource == "Flow"
            or resource == "Ferocity"
            or resource == "Energy"
            or resource == "None" then
                mp_18 = '-'
                mp5_18 = '-'
            end
                
            tablerow
                :tag('td')
                    :attr('data-sort-value', champion)
                    :css('text-align', 'left')
                    :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                :done()
                :tag('td')
                    :wikitext(hp_18)
                    :css('color', 'lightgreen')
                :done()
                :tag('td')
                    :wikitext(hp5_18)
                    :css('color', 'lightgreen')
                :done()
                :tag('td')
                    :wikitext(mp_18)
                    :css('color', 'lightblue')
                :done()
                :tag('td')
                    :wikitext(mp5_18)
                    :css('color', 'lightblue')
                :done()
                :tag('td')
                    :wikitext(dam_18)
                    :css('color', '#ffaaaa')
                :done()
                :tag('td')
                    :wikitext(as_18)
                    :css('color', '#ffaaaa')
                :done()
                :tag('td')
                    :wikitext(arm_18)
                    :css('color', '#ffffaa')
                :done()
                :tag('td')
                    :wikitext(mr_18)
                    :css('color', '#ffffaa')
                :done()
                :tag('td')
                    :wikitext(range)
                    :css('color', '#ffffff')
                :done()
                :tag('td')
                    :wikitext(ms)
                    :css('color', '#ffffff')
                :done()
            :done()
-- /\/\/\
-- \/\/\/
        elseif _stat == "Manaless" then
--        Rage,Heat,Grit,Fury,Mana,Shield,Bloodthirst,Courage,Health,Flow,Ferocity,Energy,None -- as of 1/25/2020
            local resource = lolData[champion]["resource"]
            if resource ~= "Mana" then
                local resource_msg
                if resource == "Flow" 
                or resource == "None" then
                    resource_msg = "''[[Manaless]] champion (uses '''no secondary resource''')''"
                elseif resource == "Bloodthirst" then
                    resource_msg = "''[[Manaless]] champion (uses '''[[Manaless#Health|health]]''', '''[[Manaless#Fury|" .. mw.ustring.lower(resource) .. "]]''')''"
                elseif resource == "Grit" then
                    resource_msg = "''[[Manaless]] champion (uses '''[[Manaless#Fury|" .. mw.ustring.lower(resource) .. "]]''')''"
                elseif resource == "Energy" then
                    resource_msg = "''[[Manaless]] champion (uses '''[[" .. mw.ustring.lower(resource) .. "]]''')''"
                elseif resource == "Shield"then
                    resource_msg = "''[[Manaless]] champion (uses '''[[Manaless#Flow|" .. mw.ustring.lower(resource) .. "]]''')''"
                else
                    resource_msg = "''[[Manaless]] champion (uses '''[[Manaless#" .. resource .. "|" .. mw.ustring.lower(resource) .. "]]''')''"
                end
                tablerow
                    :tag('td')
                        :attr('data-sort-value', champion)
                        :css('text-align', 'left')
                        :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                    :done()
                    :tag('td')
                        :wikitext(resource_msg)
                    :done()
            else
                tablerow = nil
            end
-- /\/\/\
-- \/\/\/
        elseif _stat == "Ratings" then
            local role = lolData[champion]['role']
            local primary = role[1]
            local secondary = role[2]
            local damage = lolData[champion]['damage']
            local toughness = lolData[champion]['toughness']
            local control = lolData[champion]['control']
            local mobility = lolData[champion]['mobility']
            local utility = lolData[champion]['utility']
            local style = lolData[champion]['style']
            local adaptivetype = mw.ustring.lower(lolData[champion]['adaptivetype'])
            local difficulty = lolData[champion]['difficulty']
            
            local primary_msg = ''
            if primary ~= nil then
               primary_msg = frame:expandTemplate{title="tip", args={primary}}
            else 
                primary = ''
            end
            local secondary_msg = ''
            if secondary ~= nil then
                secondary_msg = frame:expandTemplate{title="tip", args={secondary}}
            else
                secondary = ''
            end
            local damage_msg = damage
            local toughness_msg = toughness
            local control_msg = control
            local mobility_msg = mobility
            local utility_msg = utility
            local style_msg = frame:expandTemplate{title="Champion style", args={style, size="100px"}}
            local adaptivetype_msg;
            if adaptivetype == "magic" then
                adaptivetype_msg = "Magic"
            elseif adaptivetype == "physical" then
                adaptivetype_msg = "Physical"
            else
                -- adaptivetype_msg = frame:expandTemplate{title="pending for test"} .. " " .. frame:expandTemplate{title="edit", args={"Module:ChampionData/data"}}
                adaptivetype_msg = "Physical" -- default physical
            end
            local difficulty_msg = difficulty

            
            tablerow
                :tag('td')
                    :attr('data-sort-value', champion)
                    :css('text-align', 'left')
                    :css('padding', '1px')
                    :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                :done()
                :tag('td')
                    :wikitext(primary_msg)
                    :attr('data-sort-value', primary)
                    :css('text-align', 'left')
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(secondary_msg)
                    :attr('data-sort-value', secondary)
                    :css('text-align', 'left')
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(damage_msg)
                    :attr('bgcolor', '#420300')
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(toughness_msg)
                    :attr('bgcolor', '#102E00')
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(control_msg)
                    :attr('bgcolor', '#30004C')
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(mobility_msg)
                    :attr('bgcolor', '#000A4C')
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(utility_msg)
                    :attr('bgcolor', '#5d4407')
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(style_msg)
                    :attr('data-sort-value', style)
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(adaptivetype_msg)
                    :attr('data-sort-value', adaptivetype)
                    :css('padding', '1px')
                :done()
                :tag('td')
                    :wikitext(difficulty_msg)
                    :css('padding', '1px')
                :done()
        else
            local _base = tonumber(t[convert[_stat] .. "_base"])
            local _lvl  = tonumber(t[convert[_stat] .. "_lvl"])
            
            tablerow
                :tag('td')
                    :attr('data-sort-value', champion)
                    :css('text-align', 'left')
                    :wikitext('[[File:' .. FN.championcircle{champion} .. '|20px|alt=' .. champion .. '|link=' .. champion .. ']] [[' .. champion .. ']]')
                :done()
                :tag('td')
                    :wikitext(_base)
                :done()
                :tag('td')
                    :wikitext(_lvl)
                :done()
                :tag('td')
                    :wikitext((_base or 0) + (_lvl or 0) * (18 - 1) * (0.7025 + 0.0175 * (18 - 1)))
                :done()
            :done()
        end
        
        -- Add row to table
        if tablerow ~= nil then
            tablenode
                :node(tablerow)
                :newline()
        end
    end
    
    tablenode:allDone()
    
    return tostring(tablenode)
end

function p.itemefficiency(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local instring = args[1]
    local ret = ''
    return ret
end

function p.buildefficiency(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local instring = args[1]
    local ret = ''
    return ret
end

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