Mudanças entre as edições de "Módulo:Guild"
Ir para navegação
Ir para pesquisar
m (estaleiro lvls) |
m (skins) |
||
| (3 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 35: | Linha 35: | ||
label = "Designer", | label = "Designer", | ||
levels = { | levels = { | ||
{ image = "Designer_lvl1. | { image = "Designer_lvl1.gif" }, | ||
{ image = "Designer_lvl2. | { image = "Designer_lvl2.gif" }, | ||
{ image = "Designer_lvl3. | { image = "Designer_lvl3.gif" }, | ||
{ image = "Designer_lvl4. | { image = "Designer_lvl4.gif" }, | ||
{ image = "Designer_lvl5. | { image = "Designer_lvl5.gif" }, | ||
}, | }, | ||
}, | }, | ||
| Linha 65: | Linha 65: | ||
label = "Quartos", | label = "Quartos", | ||
levels = { | levels = { | ||
{ image = "Quartos_lvl1. | { image = "Quartos_lvl1.gif" }, | ||
{ image = "Quartos_lvl2. | { image = "Quartos_lvl2.gif" }, | ||
{ image = "Quartos_lvl3. | { image = "Quartos_lvl3.gif" }, | ||
{ image = "Quartos_lvl4. | { image = "Quartos_lvl4.gif" }, | ||
{ image = "Quartos_lvl5. | { image = "Quartos_lvl5.gif" }, | ||
}, | }, | ||
}, | }, | ||
| Linha 75: | Linha 75: | ||
label = "Sala de Guerra", | label = "Sala de Guerra", | ||
levels = { | levels = { | ||
{ image = "SalaDeGuerra_lvl1. | { image = "SalaDeGuerra_lvl1.gif" }, | ||
{ image = "SalaDeGuerra_lvl2. | { image = "SalaDeGuerra_lvl2.gif" }, | ||
{ image = "SalaDeGuerra_lvl3. | { image = "SalaDeGuerra_lvl3.gif" }, | ||
{ image = "SalaDeGuerra_lvl4. | { image = "SalaDeGuerra_lvl4.gif" }, | ||
{ image = "SalaDeGuerra_lvl5. | { image = "SalaDeGuerra_lvl5.gif" }, | ||
}, | }, | ||
}, | }, | ||
| Linha 95: | Linha 95: | ||
label = "Ferreiro", | label = "Ferreiro", | ||
levels = { | levels = { | ||
{ image = "Ferreiro_lvl1. | { image = "Ferreiro_lvl1.gif" }, | ||
{ image = "Ferreiro_lvl2. | { image = "Ferreiro_lvl2.gif" }, | ||
{ image = "Ferreiro_lvl3. | { image = "Ferreiro_lvl3.gif" }, | ||
{ image = "Ferreiro_lvl4. | { image = "Ferreiro_lvl4.gif" }, | ||
{ image = "Ferreiro_lvl5. | { image = "Ferreiro_lvl5.gif" }, | ||
}, | }, | ||
}, | }, | ||
| Linha 105: | Linha 105: | ||
label = "Cozinha", | label = "Cozinha", | ||
levels = { | levels = { | ||
{ image = " | { image = "Cozinhalvl1.gif" }, | ||
{ image = " | { image = "Cozinhalvl2.gif" }, | ||
{ image = " | { image = "Cozinhalvl3.gif" }, | ||
{ image = " | { image = "Cozinhalvl4.gif" }, | ||
{ image = "Cozinhalvl5.gif" }, | { image = "Cozinhalvl5.gif" }, | ||
}, | }, | ||
| Linha 133: | Linha 133: | ||
local args = frame:getParent().args or {} | local args = frame:getParent().args or {} | ||
local n = args.n or args[1] or "" | local n = args.n or args[1] or "" | ||
local comp = p.getComponent(n) | local skinRaw = mw.text.trim(args.skin or ""):lower() | ||
local isSkin = skinRaw == "yes" | |||
local comp = nil | |||
local skinNames = { "Default", "Black Castle", "Shogun's Fort", "Dune Fortress" } | |||
if not isSkin then | |||
comp = p.getComponent(n) | |||
if not comp then | |||
return '<div class="utab">Componente não encontrado: ' .. mw.text.nowiki(n) .. '</div>' | |||
end | |||
end | end | ||
local root = mw.html.create('div'):addClass('utab') | local root = mw.html.create('div'):addClass('utab') | ||
local section = root:tag('div'):addClass('utab__section'):attr('data-tab', | if isSkin then | ||
root:addClass('utab--skin'):attr('data-utab-skin', '1') | |||
end | |||
local sectionLabel = comp and comp.label or n | |||
local section = root:tag('div'):addClass('utab__section'):attr('data-tab', sectionLabel) | |||
-- Níveis: imagem + descrição livre por nível (nv1, nv2...) | -- Níveis: imagem + descrição livre por nível (nv1, nv2...) | ||
for i, lvl in ipairs( | local levels = {} | ||
if isSkin then | |||
for i = 1, 7 do | |||
local img = mw.text.trim(args['img' .. i] or "") | |||
if img ~= "" then | |||
local wikitext = img | |||
if not img:find("%[%[") then | |||
wikitext = '[[File:' .. img .. '|link=]]' | |||
end | |||
table.insert(levels, { image = wikitext }) | |||
end | |||
end | |||
else | |||
levels = comp.levels | |||
end | |||
for i, lvl in ipairs(levels) do | |||
local level = section:tag('div'):addClass('utab__level'):attr('data-level', tostring(i)) | local level = section:tag('div'):addClass('utab__level'):attr('data-level', tostring(i)) | ||
if isSkin then | |||
local skinName = skinNames[i] | |||
if skinName then | |||
level:attr('data-skin-name', skinName) | |||
end | |||
end | |||
local content = level:tag('div'):addClass('utab__content') | local content = level:tag('div'):addClass('utab__content') | ||
content:tag('div'):addClass('utab__mediaImage'):wikitext('[[File:' .. lvl.image .. '|link=]]') | if isSkin then | ||
content:tag('div'):addClass('utab__mediaImage'):wikitext(lvl.image) | |||
else | |||
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 | end | ||
end | end | ||
Edição atual tal como às 12h33min de 9 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.gif" },
{ image = "Designer_lvl2.gif" },
{ image = "Designer_lvl3.gif" },
{ image = "Designer_lvl4.gif" },
{ image = "Designer_lvl5.gif" },
},
},
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 = "Mainhalllvl1.gif" },
{ image = "Mainhalllvl2.gif" },
{ image = "Mainhalllvl3.gif" },
{ image = "Mainhalllvl4.gif" },
{ image = "Mainhalllvl5.gif" },
},
},
Quartos = {
label = "Quartos",
levels = {
{ image = "Quartos_lvl1.gif" },
{ image = "Quartos_lvl2.gif" },
{ image = "Quartos_lvl3.gif" },
{ image = "Quartos_lvl4.gif" },
{ image = "Quartos_lvl5.gif" },
},
},
["Sala de Guerra"] = {
label = "Sala de Guerra",
levels = {
{ image = "SalaDeGuerra_lvl1.gif" },
{ image = "SalaDeGuerra_lvl2.gif" },
{ image = "SalaDeGuerra_lvl3.gif" },
{ image = "SalaDeGuerra_lvl4.gif" },
{ image = "SalaDeGuerra_lvl5.gif" },
},
},
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.gif" },
{ image = "Ferreiro_lvl2.gif" },
{ image = "Ferreiro_lvl3.gif" },
{ image = "Ferreiro_lvl4.gif" },
{ image = "Ferreiro_lvl5.gif" },
},
},
Cozinha = {
label = "Cozinha",
levels = {
{ image = "Cozinhalvl1.gif" },
{ image = "Cozinhalvl2.gif" },
{ image = "Cozinhalvl3.gif" },
{ image = "Cozinhalvl4.gif" },
{ image = "Cozinhalvl5.gif" },
},
},
Estaleiro = {
label = "Estaleiro",
levels = {
{ image = "Estaleirolvl1.gif" },
{ image = "Estaleirolvl2.gif" },
{ image = "Estaleirolvl3.gif" },
{ image = "Estaleirolvl4.gif" },
{ image = "Estaleirolvl5.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 skinRaw = mw.text.trim(args.skin or ""):lower()
local isSkin = skinRaw == "yes"
local comp = nil
local skinNames = { "Default", "Black Castle", "Shogun's Fort", "Dune Fortress" }
if not isSkin then
comp = p.getComponent(n)
if not comp then
return '<div class="utab">Componente não encontrado: ' .. mw.text.nowiki(n) .. '</div>'
end
end
local root = mw.html.create('div'):addClass('utab')
if isSkin then
root:addClass('utab--skin'):attr('data-utab-skin', '1')
end
local sectionLabel = comp and comp.label or n
local section = root:tag('div'):addClass('utab__section'):attr('data-tab', sectionLabel)
-- Níveis: imagem + descrição livre por nível (nv1, nv2...)
local levels = {}
if isSkin then
for i = 1, 7 do
local img = mw.text.trim(args['img' .. i] or "")
if img ~= "" then
local wikitext = img
if not img:find("%[%[") then
wikitext = '[[File:' .. img .. '|link=]]'
end
table.insert(levels, { image = wikitext })
end
end
else
levels = comp.levels
end
for i, lvl in ipairs(levels) do
local level = section:tag('div'):addClass('utab__level'):attr('data-level', tostring(i))
if isSkin then
local skinName = skinNames[i]
if skinName then
level:attr('data-skin-name', skinName)
end
end
local content = level:tag('div'):addClass('utab__content')
if isSkin then
content:tag('div'):addClass('utab__mediaImage'):wikitext(lvl.image)
else
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
end
return tostring(root)
end
return p