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

De Wiki Gla
Ir para navegação Ir para pesquisar
m
m
Linha 28: Linha 28:
     ferreiro = "Ferreiro",
     ferreiro = "Ferreiro",
     cozinha = "Cozinha",
     cozinha = "Cozinha",
    estaleiro = "Estaleiro",
}
}


Linha 44: Linha 45:
         label = "Cofre",
         label = "Cofre",
         levels = {
         levels = {
             { image = "Cofre_lvl1.png" },
             { image = "Cofrelvl1.gif" },
             { image = "Cofre_lvl2.png" },
             { image = "Cofrelvl2.gif" },
             { image = "Cofre_lvl3.png" },
             { image = "Cofrelvl3.gif" },
             { image = "Cofre_lvl4.png" },
             { image = "Cofrelvl4.gif" },
             { image = "Cofre_lvl5.png" },
             { image = "Cofrelvl5.gif" },
         },
         },
     },
     },
Linha 109: Linha 110:
             { image = "Cozinha_lvl4.png" },
             { image = "Cozinha_lvl4.png" },
             { image = "Cozinhalvl5.gif" },
             { image = "Cozinhalvl5.gif" },
        },
    },
    Estaleiro = {
        label = "Estaleiro",
        levels = {
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
         },
         },
     },
     },

Edição das 22h40min de 7 de fevereiro de 2026

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

--[[
Module:Guild – Dados dos componentes da base de guild.
Uso via predefinição: {{Guild|n=Cozinha|desc=texto livre aqui}}
]]

local p = {}

local function normalize(name)
    if not name or name == "" then return nil end
    local s = mw.text.trim(name):lower()
    s = mw.ustring.gsub(s, "ó", "o")
    s = mw.ustring.gsub(s, "ã", "a")
    s = mw.ustring.gsub(s, "á", "a")
    s = mw.ustring.gsub(s, "é", "e")
    s = mw.ustring.gsub(s, " ", "")
    return s
end

local aliasMap = {
    designer = "Designer",
    cofre = "Cofre",
    salaoprincipal = "Salão Principal",
    salao = "Salão Principal",
    quartos = "Quartos",
    saladeguerra = "Sala de Guerra",
    salaguerra = "Sala de Guerra",
    treinamento = "Treinamento",
    ferreiro = "Ferreiro",
    cozinha = "Cozinha",
    estaleiro = "Estaleiro",
}

local data = {
    Designer = {
        label = "Designer",
        levels = {
            { image = "Designer_lvl1.png" },
            { image = "Designer_lvl2.png" },
            { image = "Designer_lvl3.png" },
            { image = "Designer_lvl4.png" },
            { image = "Designer_lvl5.png" },
        },
    },
    Cofre = {
        label = "Cofre",
        levels = {
            { image = "Cofrelvl1.gif" },
            { image = "Cofrelvl2.gif" },
            { image = "Cofrelvl3.gif" },
            { image = "Cofrelvl4.gif" },
            { image = "Cofrelvl5.gif" },
        },
    },
    ["Salão Principal"] = {
        label = "Salão Principal",
        levels = {
            { image = "SalaoPrincipal_lvl1.png" },
            { image = "SalaoPrincipal_lvl2.png" },
            { image = "SalaoPrincipal_lvl3.png" },
            { image = "SalaoPrincipal_lvl4.png" },
            { image = "SalaoPrincipal_lvl5.png" },
        },
    },
    Quartos = {
        label = "Quartos",
        levels = {
            { image = "Quartos_lvl1.png" },
            { image = "Quartos_lvl2.png" },
            { image = "Quartos_lvl3.png" },
            { image = "Quartos_lvl4.png" },
            { image = "Quartos_lvl5.png" },
        },
    },
    ["Sala de Guerra"] = {
        label = "Sala de Guerra",
        levels = {
            { image = "SalaDeGuerra_lvl1.png" },
            { image = "SalaDeGuerra_lvl2.png" },
            { image = "SalaDeGuerra_lvl3.png" },
            { image = "SalaDeGuerra_lvl4.png" },
            { image = "SalaDeGuerra_lvl5.png" },
        },
    },
    Treinamento = {
        label = "Treinamento",
        levels = {
            { image = "Treinamentolvl1.gif" },
            { image = "Treinamentolvl2.gif" },
            { image = "Treinamentolvl3.gif" },
            { image = "Treinamentolvl4.gif" },
            { image = "Treinamentolvl5.gif" },
        },
    },
    Ferreiro = {
        label = "Ferreiro",
        levels = {
            { image = "Ferreiro_lvl1.png" },
            { image = "Ferreiro_lvl2.png" },
            { image = "Ferreiro_lvl3.png" },
            { image = "Ferreiro_lvl4.png" },
            { image = "Ferreiro_lvl5.png" },
        },
    },
    Cozinha = {
        label = "Cozinha",
        levels = {
            { image = "Cozinha_lvl1.png" },
            { image = "Cozinha_lvl2.png" },
            { image = "Cozinha_lvl3.png" },
            { image = "Cozinha_lvl4.png" },
            { image = "Cozinhalvl5.gif" },
        },
    },
    Estaleiro = {
        label = "Estaleiro",
        levels = {
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
            { image = "Estaleirolvl1.gif" },
        },
    },
}

function p.getComponent(name)
    local key = aliasMap[normalize(name)]
    if not key then return nil end
    return data[key]
end

function p.main(frame)
    local args = frame:getParent().args or {}
    local n = args.n or args[1] or ""
    local comp = p.getComponent(n)
    if not comp then
        return '<div class="utab">Componente não encontrado: ' .. mw.text.nowiki(n) .. '</div>'
    end

    local root = mw.html.create('div'):addClass('utab')
    local section = root:tag('div'):addClass('utab__section'):attr('data-tab', comp.label)

    -- Níveis: imagem + descrição livre por nível (nv1, nv2...)
    for i, lvl in ipairs(comp.levels) do
        local level = section:tag('div'):addClass('utab__level'):attr('data-level', tostring(i))
        local content = level:tag('div'):addClass('utab__content')
        content:tag('div'):addClass('utab__mediaImage'):wikitext('[[File:' .. lvl.image .. '|link=]]')
        local desc = mw.text.trim(args['nv' .. i] or "")
        if desc ~= "" then
            content:tag('div'):addClass('utab__desc'):wikitext('\n' .. desc .. '\n')
        end
    end

    return tostring(root)
end

return p