FANDOM


-- <pre>
local p         = {}
local lib       = require('Módulo:Feature')
local userError = require('Dev:User error')
 
function p.get(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    args['champname'] = args['champname']     or args[1]
    args['set']       = tonumber(args['set']) or tonumber(args[2])
    args['datatype']  = args['datatype']      or args[3]
 
    local get    = require ('Módulo:TFTUnitData/getter')
    local result = get[args['datatype']](args['champname'], args['set'])
 
    if (args['datatype'] == "active" or args['datatype'] == "passive") and result ~= nil then
        return frame:preprocess(result)
    elseif result == nil then
        return ""
    else
        return result
    end
end
 
function p.getSets(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    args['champname'] = args['champname'] or args[1]
 
    local get = require ('Módulo:TFTUnitData/getter')
 
    return get["sets"](args['champname'])
end
 
function p.getFirstSet(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    args['champname'] = args['champname'] or args[1]
 
    local datatable = require('Módulo:TFTUnitData/data')
 
    for setnumber in pairs(datatable[args['champname']]) do
        firstSet = setnumber
        break;
    end
 
    return firstSet
end
 
function p.getLastSet(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    args['champname'] = args['champname'] or args[1]
 
    local datatable = require('Módulo:TFTUnitData/data')
 
    for setnumber in pairs(datatable[args['champname']]) do
        lastSet = setnumber
    end
 
    return lastSet
end
 
function p.getTooltipSets(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    args['champname'] = args['champname'] or args[1]
 
    local datatable = require('Módulo:TFTUnitData/data')
    local s         = ""
 
    for setnumber in pairs(datatable[args['champname']]) do
        if s ~= "" then s = s .. "," end
        s = s .. "TFT" .. setnumber
    end
 
    return s
end
 
function p.checkRoster(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    args['champname'] = args['champname'] or args[1]
 
    local datatable  = require('Módulo:TFTUnitData/data')
 
    for champname in pairs(datatable) do
        if champname == args['champname'] then
            return true
        end
    end
 
    return false
end
 
function p.getRoster(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    local IL         = require('Módulo:ImageLink')
    local datatable  = require('Módulo:TFTUnitData/data')
    local cmd        = require('Módulo:Maintenance data')
    local champtable = {}
    local roster     = ""
 
    args['set']      = tonumber(args['set']) or tonumber(args[1]) or tonumber(cmd.main{'TFTSet'})
 
    for champname in pairs(datatable) do
        if datatable[champname][args['set']] then
            table.insert(champtable, champname)
        end
    end
    table.sort(champtable)
 
    for _, champname in pairs(champtable) do
        roster = roster .. tostring(IL.TFTchampion{
            ["champion"] = champname,
            ["set"]      = args['set'],
            ["size"]     = 46,
            ["text"]     = "*none*",
            ["display"]  = "inline-block"
        })
    end
 
    return roster
end
 
function p.getGroup(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
 
    local IL         = require('Módulo:ImageLink')
    local datatable  = require('Módulo:TFTUnitData/data')
    local champtable = {}
    local roster     = ""
    local count      = 0
 
    args['synergy'] = args['synergy']       or args[1]
    args['set']     = tonumber(args['set']) or tonumber(args[2])
    args['count']   = args['count']         or 'false'
 
    for champname in pairs(datatable) do
        table.insert(champtable, champname)
    end
    table.sort(champtable)
 
    for _, champname in pairs(champtable) do
        for dataset, v in pairs(datatable[champname]) do
            if dataset == args['set'] then
                for _, classname in pairs(v.class) do
                    if classname == args['synergy'] then
                        roster = roster .. tostring(IL.TFTchampion{
                            ["champion"] = champname,
                            ["set"]      = args['set'],
                            ["size"]     = 46,
                            ["text"]     = "*none*"
                        })
                    count = count + 1
                    end
                end
                for _, originname in pairs(v.origin) do
                    if originname == args['synergy'] then
                        roster = roster .. tostring(IL.TFTchampion{
                            ["champion"] = champname,
                            ["set"]      = args['set'],
                            ["size"]     = 46,
                            ["text"]     = "*none*"
                        })
                    count = count + 1
                    end
                end
            end
        end
    end
 
 
    if args['count'] == 'true' then
        return roster, count
    else
        return roster
    end
end
 
function p.championlist(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    local lang = mw.language.new( "en" )
    local list = mw.html.create('table')
    local IL   = require('Módulo:ImageLink')
 
    list
        :addClass('sortable article-table sticky-header')
        :css('width', '100%')
        :css('text-align', 'left')
        :newline()
 
        --TABLE HEADER    
        :tag('tr')
            :tag('th')
                :wikitext('Champion')
            :done()
            :tag('th')
                :wikitext('Tier')
            :done()
            :tag('th')
                :wikitext('Origin')
            :done()
            :tag('th')
                :wikitext('Class')
            :done()
            :tag('th')
                :addClass('unsortable')
                :wikitext('Ability')
            :done()
        :done()
        :newline()
 
 
        -- TABLE ENTRIES
        local datatable  = require('Módulo:TFTUnitData/data')
        local champtable = {}
        local tierimage  = {
            [1] = "",
            [2] = "&nbsp;[[File:Standard Skin.png|20px|link=]]",
            [3] = "&nbsp;[[File:Epic Skin.png|20px|link=]]",
            [4] = "&nbsp;[[File:Mythic Skin.png|20px|link=]]",
            [5] = "&nbsp;[[File:Ultimate Skin.png|20px|link=]]",
            [7] = "&nbsp;[[File:China Skin Tier 9.png|20px|link=]]"
        }
 
        args['set'] = tonumber(args['set']) or tonumber(args[1]) 
 
        for champname in pairs(datatable) do
            table.insert(champtable, champname)
        end
        table.sort(champtable)
 
        for _, champname in pairs(champtable) do
            if datatable[champname][args['set']] then
                local listentry = mw.html.create('tr')
                local tier      = datatable[champname][args['set']]['tier']
                local origin    = datatable[champname][args['set']]['origin']
                local class     = datatable[champname][args['set']]['class']
                local s         = ''
 
                -- Champion
                listentry
                    :tag('td')
                        :attr('data-sort-value', champname)
                        :wikitext(tostring(IL.TFTchampion{
                            ["champion"] = champname,
                            ["set"]      = args['set']
                        }))
                    :done()
 
                -- Tier
                listentry
                    :tag('td')
                        :attr('data-sort-value', tier)
                        :wikitext(tier .. tierimage[tier])
                    :done()
 
                -- Origin
                s = tostring(IL.TFTtrait{
                    ["trait"]  = origin[1],
                    ["set"]    = args['set'],
                    ["border"] = 'false'
                })
                if origin[2] then
                    s = s .. '<br />' .. tostring(IL.TFTtrait{
                        ["trait"]  = origin[2],
                        ["set"]    = args['set'],
                        ["border"] = 'false'
                    })
                end
                listentry
                    :tag('td')
                        :attr('data-sort-value', lib.ternary(origin[2], '!Multi', origin[1]))
                        :wikitext(s)
                    :done()
 
                -- Class
                s = tostring(IL.TFTtrait{
                    ["trait"]  = class[1],
                    ["set"]    = args['set'],
                    ["border"] = 'false'
                })
                if class[2] then
                    s = s .. '<br />' .. tostring(IL.TFTtrait{
                        ["trait"]  = class[2],
                        ["set"]    = args['set'],
                        ["border"] = 'false'
                    })
                end
                listentry
                    :tag('td')
                        :attr('data-sort-value', lib.ternary(class[2], '!Multi', class[1]))
                        :wikitext(s)
                    :done()
 
                --Ability
                local p = lib.ternary(datatable[champname][args['set']]['passive'], datatable[champname][args['set']]['passive'], '')
                local a = lib.ternary(datatable[champname][args['set']]['active'], datatable[champname][args['set']]['active'], '')
 
                if p and a then 
                    s = p .. '<br />' .. a
                else 
                    s = p or a
                end    
 
                listentry
                    :tag('td')
                        :addClass('mw-collapsible mw-collapsed')
                        :attr('data-expandtext', 'Show')
                        :attr('data-collapsetext', 'Hide')
                        :tag('span')
                            :css('white-space', 'nowrap')
                            :wikitext('[[File:' .. datatable[champname][args['set']]['abilityicon'] .. '|border|20px|link=]] ' .. datatable[champname][args['set']]['abilityname'])
                        :done()
                        :tag('div')
                            :addClass('mw-collapsible-content')
                            :wikitext(s)
                        :done()
                    :done()
 
                list
                    :node(listentry)
                    :newline()
            end
        end
        -- TABLE END
 
    list:allDone()
    return frame:preprocess(tostring(list))
end
 
return p
-- </pre>
-- [[Categoría:Lua]]
El contenido de la comunidad está disponible bajo CC-BY-SA a menos que se indique lo contrario.