Mudanças entre as edições de "Módulo:Teste"

De Wiki Gla
Ir para navegação Ir para pesquisar
m
m
Linha 1: Linha 1:
--[[
local p = {}
Module:Guild – Dados dos componentes da base de guild.
 
Uso: {{#invoke:Guild|main|n=Ferreiro}}
local BAU_COMUM = 'https://i.imgur.com/URL_COMUM'
Predefinição: {{Guild|n=Ferreiro}}
local BAU_OURO  = 'https://i.imgur.com/URL_OURO'
]]
 
function p.main(frame)
    local args = frame:getParent().args


local p = {}
    local cards = {}
 
    local i = 1
    while true do
        local nome = args['nome' .. i]
        if not nome or mw.text.trim(nome) == '' then break end
 
        local link = args['link' .. i] or ''
        local img  = args['img'  .. i] or ''
        local qtd  = args['qtd'  .. i] or '0'
        local bau  = mw.text.trim(args['bau' .. i] or 'comum')
 
        local bauSrc = bau == 'ouro' and BAU_OURO or BAU_COMUM
 
        local imgFile = mw.getCurrentFrame():callParserFunction(
            '#tag', 'span',
            frame:preprocess('[[File:' .. img .. '|150px|link=' .. link .. ']]')
        )


local function normalize(name)
        local card = mw.html.create('a')
    if not name or name == "" then return nil end
            :addClass('island-card')
    local s = mw.text.trim(name):lower()
            :attr('href', tostring(mw.uri.localUrl(link)))
    s = mw.ustring.gsub(s, "ó", "o")
    s = mw.ustring.gsub(s, "ã", "a")
    s = mw.ustring.gsub(s, "á", "a")
    s = mw.ustring.gsub(s, " ", "")
    return s
end


local map = {
        card:tag('span')
    designer = "Designer",
            :addClass('island-img')
    cofre = "Cofre",
            :wikitext('[[File:' .. img .. '|150px|link=]]')
    salaoprincipal = "Salão Principal",
    salao = "Salão Principal",
    quartos = "Quartos",
    saladeguerra = "Sala de Guerra",
    salaguerra = "Sala de Guerra",
    treinamento = "Treinamento",
    ferreiro = "Ferreiro",
    cozinha = "Cozinha",
}


local data = {
         card:tag('span')
    Designer = {
             :addClass('island-name')
         label = "Designer",
             :wikitext(link ~= '' and '[[' .. link .. '|' .. nome .. ']]' or nome)
        levels = {
             { image = "Designer_lvl1.png", stats = { "1 pilar de artefato disponível", "27 símbolos disponíveis", "1 plano de fundo disponível", "6 cores disponíveis", "2% de EXP", "4% de sorte", "5% de pontos de aliança" } },
             { image = "Designer_lvl2.png", stats = { "2 pilares de artefato disponíveis", "9 planos de fundo disponíveis", "47 símbolos disponíveis", "12 cores disponíveis", "4% de EXP", "9% de sorte", "12% de pontos de aliança" } },
            { image = "Designer_lvl3.png", stats = { "2 pilares de artefato disponíveis", "34 planos de fundo disponíveis", "72 símbolos disponíveis", "30 cores disponíveis", "6% de EXP", "15% de sorte", "22% de pontos de aliança" } },
            { image = "Designer_lvl4.png", stats = { "3 pilares de artefato disponíveis", "34 planos de fundo disponíveis", "92 símbolos disponíveis", "30 cores disponíveis", "8% de EXP", "22% de sorte", "35% de pontos de aliança" } },
            { image = "Designer_lvl5.png", stats = { "4 pilares de artefato disponíveis", "34 planos de fundo disponíveis", "112 símbolos disponíveis", "30 cores disponíveis", "10% de EXP", "30% de sorte", "50% de pontos de aliança" } },
        },
    },
    Cofre = {
        label = "Cofre",
        levels = {
            { image = "Cofre_lvl1.png", stats = { "10% de bônus pra aliança" } },
            { image = "Cofre_lvl2.png", stats = { "+ 100 espaços extra no cofre", "25% de bônus pra aliança" } },
            { image = "Cofre_lvl3.png", stats = { "+ 200 espaços extra no cofre", "45% de bônus pra aliança" } },
            { image = "Cofre_lvl4.png", stats = { "+ 300 espaços extra no cofre", "75% de bônus pra aliança" } },
            { image = "Cofre_lvl5.png", stats = { "+ 400 espaços extra no cofre", "100% de bônus pra aliança" } },
        },
    },
    ["Salão Principal"] = {
        label = "Salão Principal",
        levels = {
            { image = "SalaoPrincipal_lvl1.png", stats = { "Descrição do nível 1" } },
            { image = "SalaoPrincipal_lvl2.png", stats = { "Descrição do nível 2" } },
            { image = "SalaoPrincipal_lvl3.png", stats = { "Descrição do nível 3" } },
            { image = "SalaoPrincipal_lvl4.png", stats = { "Descrição do nível 4" } },
            { image = "SalaoPrincipal_lvl5.png", stats = { "Descrição do nível 5" } },
        },
    },
    Quartos = {
        label = "Quartos",
        levels = {
            { image = "Quartos_lvl1.png", stats = { "Descrição do nível 1" } },
            { image = "Quartos_lvl2.png", stats = { "Descrição do nível 2" } },
            { image = "Quartos_lvl3.png", stats = { "Descrição do nível 3" } },
            { image = "Quartos_lvl4.png", stats = { "Descrição do nível 4" } },
            { image = "Quartos_lvl5.png", stats = { "Descrição do nível 5" } },
        },
    },
    ["Sala de Guerra"] = {
        label = "Sala de Guerra",
        levels = {
            { image = "SalaDeGuerra_lvl1.png", stats = { "Descrição do nível 1" } },
            { image = "SalaDeGuerra_lvl2.png", stats = { "Descrição do nível 2" } },
            { image = "SalaDeGuerra_lvl3.png", stats = { "Descrição do nível 3" } },
            { image = "SalaDeGuerra_lvl4.png", stats = { "Descrição do nível 4" } },
            { image = "SalaDeGuerra_lvl5.png", stats = { "Descrição do nível 5" } },
        },
    },
    Treinamento = {
        label = "Treinamento",
        levels = {
            { image = "Treinamento_lvl1.png", stats = { "Descrição do nível 1" } },
            { image = "Treinamento_lvl2.png", stats = { "Descrição do nível 2" } },
            { image = "Treinamento_lvl3.png", stats = { "Descrição do nível 3" } },
            { image = "Treinamento_lvl4.png", stats = { "Descrição do nível 4" } },
            { image = "Treinamento_lvl5.png", stats = { "Descrição do nível 5" } },
        },
    },
    Ferreiro = {
        label = "Ferreiro",
        levels = {
            { image = "Ferreiro_lvl1.png", stats = { "Descrição do nível 1" } },
            { image = "Ferreiro_lvl2.png", stats = { "Descrição do nível 2" } },
            { image = "Ferreiro_lvl3.png", stats = { "Descrição do nível 3" } },
            { image = "Ferreiro_lvl4.png", stats = { "Descrição do nível 4" } },
            { image = "Ferreiro_lvl5.png", stats = { "Descrição do nível 5" } },
        },
    },
    Cozinha = {
        label = "Cozinha",
        levels = {
            { image = "Cozinha_lvl1.png", stats = { "Descrição do nível 1" } },
            { image = "Cozinha_lvl2.png", stats = { "Descrição do nível 2" } },
            { image = "Cozinha_lvl3.png", stats = { "Descrição do nível 3" } },
            { image = "Cozinha_lvl4.png", stats = { "Descrição do nível 4" } },
            { image = "Cozinhalvl5.gif",  stats = { "Descrição do nível 5" } },
        },
    },
}


function p.getComponent(name)
        card:tag('span')
    local key = map[normalize(name)]
            :addClass('island-chests')
    if not key then return nil end
            :wikitext(qtd .. ' [[File:' .. (bau == 'ouro' and 'Chest_gold.png' or 'Chest_normal.png') .. '|link=]]')
    return data[key]
end


function p.main(frame)
        cards[#cards + 1] = tostring(card)
    local args = frame:getParent().args or {}
         i = i + 1
    local n = args.n or args[1] or ""
    local comp = p.getComponent(n)
    if not comp then
         return ""
     end
     end
     local html = {}
 
    html[#html + 1] = '<div class="utab">'
     local grid = mw.html.create('div')
    html[#html + 1] = '<section class="utab__section" data-tab="' .. mw.text.nowiki(comp.label) .. '">'
         :addClass('island-grid')
    for i, lvl in ipairs(comp.levels) do
         :wikitext(table.concat(cards))
         html[#html + 1] = '<div class="utab__level" data-level="' .. i .. '">'
 
        html[#html + 1] = '<div class="utab__content">'
     return tostring(grid)
         html[#html + 1] = '<div class="utab__mediaImage">[[File:' .. lvl.image .. ']]</div>'
        html[#html + 1] = '<ul class="utab__statList">'
        for _, stat in ipairs(lvl.stats) do
            html[#html + 1] = '<li>' .. stat .. '</li>'
        end
        html[#html + 1] = '</ul>'
        html[#html + 1] = '</div>'
        html[#html + 1] = '</div>'
    end
    html[#html + 1] = '</section>'
    html[#html + 1] = '</div>'
     return table.concat(html)
end
end


return p
return p

Edição das 22h18min de 12 de março de 2026

A documentação para este módulo pode ser criada em Módulo:Teste/doc

local p = {}

local BAU_COMUM = 'https://i.imgur.com/URL_COMUM'
local BAU_OURO  = 'https://i.imgur.com/URL_OURO'

function p.main(frame)
    local args = frame:getParent().args

    local cards = {}

    local i = 1
    while true do
        local nome = args['nome' .. i]
        if not nome or mw.text.trim(nome) == '' then break end

        local link = args['link' .. i] or ''
        local img  = args['img'  .. i] or ''
        local qtd  = args['qtd'  .. i] or '0'
        local bau  = mw.text.trim(args['bau' .. i] or 'comum')

        local bauSrc = bau == 'ouro' and BAU_OURO or BAU_COMUM

        local imgFile = mw.getCurrentFrame():callParserFunction(
            '#tag', 'span',
            frame:preprocess('[[File:' .. img .. '|150px|link=' .. link .. ']]')
        )

        local card = mw.html.create('a')
            :addClass('island-card')
            :attr('href', tostring(mw.uri.localUrl(link)))

        card:tag('span')
            :addClass('island-img')
            :wikitext('[[File:' .. img .. '|150px|link=]]')

        card:tag('span')
            :addClass('island-name')
            :wikitext(link ~= '' and '[[' .. link .. '|' .. nome .. ']]' or nome)

        card:tag('span')
            :addClass('island-chests')
            :wikitext(qtd .. ' [[File:' .. (bau == 'ouro' and 'Chest_gold.png' or 'Chest_normal.png') .. '|link=]]')

        cards[#cards + 1] = tostring(card)
        i = i + 1
    end

    local grid = mw.html.create('div')
        :addClass('island-grid')
        :wikitext(table.concat(cards))

    return tostring(grid)
end

return p