Mudanças entre as edições de "Módulo:Larifk"
Ir para navegação
Ir para pesquisar
Etiqueta: Reversão manual |
|||
| Linha 1: | Linha 1: | ||
local p = {} | local p = {} | ||
local BAU_IMAGENS = { | |||
comum = 'CommonChest.png', | |||
ouro = 'GoldChest.png' | |||
} | |||
function p.render(frame) | function p.render(frame) | ||
| Linha 24: | Linha 29: | ||
local tabs = root:tag('div'):attr('class', 'lk-tabs') | local tabs = root:tag('div'):attr('class', 'lk-tabs') | ||
for idx, n in ipairs(baus) do | for idx, n in ipairs(baus) do | ||
local | local tipo = mw.text.trim(args['bau' .. n .. 'tipo'] or '') | ||
local tabImg = BAU_IMAGENS[tipo] or '' | |||
local tab = tabs:tag('span') | local tab = tabs:tag('span') | ||
:attr('class', idx == 1 and 'lk-tab active' or 'lk-tab') | :attr('class', idx == 1 and 'lk-tab active' or 'lk-tab') | ||
:attr('data-tab', 'b' .. n) | :attr('data-tab', 'b' .. n) | ||
if tabImg ~= '' then | if tabImg ~= '' then | ||
tab: | tab:node(mw.html.create(''):wikitext('[[File:' .. tabImg .. '|20px]]')) | ||
end | end | ||
tab:tag('span'):wikitext('Baú ' .. string.format('%02d', n)) | tab:tag('span'):wikitext('Baú ' .. string.format('%02d', n)) | ||
| Linha 39: | Linha 43: | ||
local px = 'bau' .. n | local px = 'bau' .. n | ||
local tipo = mw.text.trim(args[px .. 'tipo'] or '') | local tipo = mw.text.trim(args[px .. 'tipo'] or '') | ||
local video = mw.text.trim(args[px .. 'video'] or '') | local video = mw.text.trim(args[px .. 'video'] or '') | ||
local imagem = mw.text.trim(args[px .. 'imagem'] or '') | local imagem = mw.text.trim(args[px .. 'imagem'] or '') | ||
local bauImg = BAU_IMAGENS[tipo] or '' | |||
local panel = root:tag('div') | local panel = root:tag('div') | ||
| Linha 49: | Linha 53: | ||
local left = panel:tag('div'):attr('class', 'lk-left') | local left = panel:tag('div'):attr('class', 'lk-left') | ||
local baubox = left:tag('div'):attr('class', 'lk-bau-box') | local baubox = left:tag('div'):attr('class', 'lk-bau-box') | ||
if | if bauImg ~= '' then | ||
baubox: | baubox:node(mw.html.create(''):wikitext('[[File:' .. bauImg .. '|64px]]')) | ||
end | end | ||
left:tag('span'):attr('class', 'lk-badge ' .. tipo):wikitext(tipo) | left:tag('span'):attr('class', 'lk-badge ' .. tipo):wikitext(tipo) | ||
| Linha 68: | Linha 72: | ||
local sprite = item:tag('div'):attr('class', 'lk-rsprite') | local sprite = item:tag('div'):attr('class', 'lk-rsprite') | ||
if rimg ~= '' then | if rimg ~= '' then | ||
sprite: | sprite:node(mw.html.create(''):wikitext('[[File:' .. rimg .. '|36px]]')) | ||
end | end | ||
if qty ~= '' then | if qty ~= '' then | ||
item:tag('span'):attr('class', 'lk-rqty'):wikitext(qty) | local num, sufixo = qty:match('^(%d+)(.*)') | ||
if num then | |||
local qspan = item:tag('span'):attr('class', 'lk-rqty') | |||
qspan:tag('span'):attr('class', 'lk-rqty-num'):wikitext(num) | |||
qspan:tag('span'):attr('class', 'lk-rqty-x'):wikitext(sufixo ~= '' and sufixo or 'x') | |||
else | |||
item:tag('span'):attr('class', 'lk-rqty'):wikitext(qty) | |||
end | |||
end | end | ||
j = j + 1 | j = j + 1 | ||
Edição das 19h32min de 16 de março de 2026
A documentação para este módulo pode ser criada em Módulo:Larifk/doc
local p = {}
local BAU_IMAGENS = {
comum = 'CommonChest.png',
ouro = 'GoldChest.png'
}
function p.render(frame)
local args = frame:getParent().args
local nome = mw.text.trim(args['nome'] or '')
local root = mw.html.create('div'):attr('class', 'lk-wrap')
if nome ~= '' then
root:tag('div'):attr('class', 'lk-titulo'):wikitext(nome)
end
local baus = {}
local i = 1
while true do
local tipo = mw.text.trim(args['bau' .. i .. 'tipo'] or '')
if tipo == '' then break end
baus[#baus + 1] = i
i = i + 1
end
if #baus == 0 then return tostring(root) end
local tabs = root:tag('div'):attr('class', 'lk-tabs')
for idx, n in ipairs(baus) do
local tipo = mw.text.trim(args['bau' .. n .. 'tipo'] or '')
local tabImg = BAU_IMAGENS[tipo] or ''
local tab = tabs:tag('span')
:attr('class', idx == 1 and 'lk-tab active' or 'lk-tab')
:attr('data-tab', 'b' .. n)
if tabImg ~= '' then
tab:node(mw.html.create(''):wikitext('[[File:' .. tabImg .. '|20px]]'))
end
tab:tag('span'):wikitext('Baú ' .. string.format('%02d', n))
end
for idx, n in ipairs(baus) do
local px = 'bau' .. n
local tipo = mw.text.trim(args[px .. 'tipo'] or '')
local video = mw.text.trim(args[px .. 'video'] or '')
local imagem = mw.text.trim(args[px .. 'imagem'] or '')
local bauImg = BAU_IMAGENS[tipo] or ''
local panel = root:tag('div')
:attr('class', idx == 1 and 'lk-panel active' or 'lk-panel')
:attr('data-panel', 'b' .. n)
local left = panel:tag('div'):attr('class', 'lk-left')
local baubox = left:tag('div'):attr('class', 'lk-bau-box')
if bauImg ~= '' then
baubox:node(mw.html.create(''):wikitext('[[File:' .. bauImg .. '|64px]]'))
end
left:tag('span'):attr('class', 'lk-badge ' .. tipo):wikitext(tipo)
local right = panel:tag('div'):attr('class', 'lk-right')
local rsec = right:tag('div')
rsec:tag('div'):attr('class', 'lk-slabel'):wikitext('Recompensas')
local grid = rsec:tag('div'):attr('class', 'lk-rewards')
local j = 1
while true do
local qty = mw.text.trim(args[px .. 'reward' .. j] or '')
local rimg = mw.text.trim(args[px .. 'rewardimg' .. j] or '')
if qty == '' and rimg == '' then break end
local item = grid:tag('div'):attr('class', 'lk-reward')
local sprite = item:tag('div'):attr('class', 'lk-rsprite')
if rimg ~= '' then
sprite:node(mw.html.create(''):wikitext('[[File:' .. rimg .. '|36px]]'))
end
if qty ~= '' then
local num, sufixo = qty:match('^(%d+)(.*)')
if num then
local qspan = item:tag('span'):attr('class', 'lk-rqty')
qspan:tag('span'):attr('class', 'lk-rqty-num'):wikitext(num)
qspan:tag('span'):attr('class', 'lk-rqty-x'):wikitext(sufixo ~= '' and sufixo or 'x')
else
item:tag('span'):attr('class', 'lk-rqty'):wikitext(qty)
end
end
j = j + 1
end
if video ~= '' or imagem ~= '' then
right:tag('div'):attr('class', 'lk-divider')
local msec = right:tag('div')
msec:tag('div'):attr('class', 'lk-slabel'):wikitext('Como chegar')
local mwrap = msec:tag('div'):attr('class', 'lk-media-wrap')
if video ~= '' then
mwrap:attr('data-video', video)
else
mwrap:tag('img'):attr('src', imagem):attr('alt', 'como chegar')
end
end
end
return tostring(root)
end
return p