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

De Wiki Gla
Ir para navegação Ir para pesquisar
Etiqueta: Revertido
 
(29 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
local p = {}
local p = {}


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


-- caixa de texto
    local normal_nivel    = mw.text.trim(args['normal_nivel']    or '140')
local textBox = main:tag("div"):css{ flex = 1 }
    local normal_equip    = mw.text.trim(args['normal_equip']    or 'Set +8')
    local hard_personagem = mw.text.trim(args['hard_personagem'] or 'personagem 4 ou 5 estrelas (Diamante)')
    local hard_equip      = mw.text.trim(args['hard_equip']      or 'Set +16')


    local root = mw.html.create('div')
    root:addClass('gb-wrap')


textBox:tag("div")
    -- CSS via TemplateStyles (recomendado) ou inline
:css{ ["font-size"] = "1.25em", ["font-weight"] = "bold", color = "#e82b2b" }
    -- Botões (tabs)
:wikitext(nome)
    local btns = root:tag('div'):addClass('gb-btns')


    btns:tag('button')
        :addClass('gb-btn'):addClass('active')
        :attr('onclick', "gbSwitch('n',this)")
        :wikitext('Normal ')
        :tag('span'):addClass('gb-badge'):addClass('badge-n')
        :wikitext('Nível ' .. normal_nivel)


-----------------------------------------------------------------
    btns:tag('button')
-- Stats
        :addClass('gb-btn')
-----------------------------------------------------------------
        :attr('onclick', "gbSwitch('h',this)")
local stats = main:tag("div")
        :wikitext('Hard ')
:css{
        :tag('span'):addClass('gb-badge'):addClass('badge-h')
display = "flex",
        :wikitext(hard_equip)
["flex-direction"] = "column",
gap = "5px",
["min-width"] = "170px"
}


    -- Painel Normal
    local pn = root:tag('div'):addClass('gb-panel'):addClass('active'):attr('id', 'gbpanel-n')
    pn:tag('div'):addClass('gb-title'):wikitext('Requisitos — Normal')
    local ln = pn:tag('ul'):addClass('gb-list')
    ln:tag('li')
        :tag('span'):addClass('gb-dot'):addClass('dot-n'):done()
        :tag('span'):wikitext('Nível mínimo: '):tag('b'):wikitext(normal_nivel)
    ln:tag('li')
        :tag('span'):addClass('gb-dot'):addClass('dot-n'):done()
        :tag('span'):wikitext('Equipamento recomendado: '):tag('b'):wikitext(normal_equip)


local statBox = stats:tag("div")
    -- Painel Hard
:css{
    local ph = root:tag('div'):addClass('gb-panel'):attr('id', 'gbpanel-h')
padding = "12px 18px",
    ph:tag('div'):addClass('gb-title'):wikitext('Requisitos — Hard')
["border-radius"] = "8px",
    local lh = ph:tag('ul'):addClass('gb-list')
["background-color"] = theme.variantB
    lh:tag('li')
}
        :tag('span'):addClass('gb-dot'):addClass('dot-h'):done()
        :tag('span'):wikitext('Recomendado utilizar um '):tag('b'):wikitext(hard_personagem)
    lh:tag('li')
        :tag('span'):addClass('gb-dot'):addClass('dot-h'):done()
        :tag('span'):wikitext('Equipamento recomendado: '):tag('b'):wikitext(hard_equip)


    -- Script
    local script = mw.html.create('script')
    script:wikitext([[
function gbSwitch(tab,btn){
['n','h'].forEach(function(t){document.getElementById('gbpanel-'+t).classList.remove('active');});
document.querySelectorAll('.gb-btn').forEach(function(b){b.classList.remove('active');});
document.getElementById('gbpanel-'+tab).classList.add('active');
btn.classList.add('active');
}]])


statBox:wikitext(string.format('<span style="font-size:1.1em; color:#fb3d3d; font-weight:bold;">❤️ %s</span> ', hp))
    -- CSS inline
statBox:wikitext(string.format('<span style="font-size:1.1em; color:#ffe568; font-weight:bold;">💰 %s</span> ', exp))
    local style = mw.html.create('style')
statBox:wikitext(string.format('<span style="font-size:1.1em; color:#6ca8fb; font-weight:bold;">⚔️ %s</span>', nivel))
    style:wikitext([[
.gb-wrap{font-family:sans-serif;max-width:600px}
.gb-btns{display:flex;border-bottom:2px solid #a2a9b1;margin-bottom:0}
.gb-btn{padding:8px 22px;font-size:14px;font-weight:bold;color:#54595d;background:transparent;border:none;border-bottom:3px solid transparent;margin-bottom:-2px;cursor:pointer;display:flex;align-items:center;gap:6px}
.gb-btn:hover{color:#202122}
.gb-btn.active{color:#202122;border-bottom-color:#3680b0}
.gb-badge{font-size:11px;padding:2px 8px;border-radius:20px;font-weight:bold}
.badge-n{background:#ddeeff;color:#185FA5}
.badge-h{background:#fce8e8;color:#a32d2d}
.gb-panel{display:none;padding:14px 2px}
.gb-panel.active{display:block}
.gb-title{font-size:11px;font-weight:bold;color:#72777d;text-transform:uppercase;letter-spacing:.06em;margin-bottom:10px}
.gb-list{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:8px}
.gb-list li{display:flex;align-items:flex-start;gap:8px;font-size:14px;color:#202122;line-height:1.5}
.gb-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0;margin-top:5px}
.dot-n{background:#3680b0}
.dot-h{background:#e24b4a}
@media(max-width:480px){.gb-btn{padding:8px 14px;font-size:13px}}]])


 
    return tostring(style) .. tostring(root) .. tostring(script)
stats:tag("div")
:css{ ["font-size"] = "90%" }
:wikitext(string.format(
"<b>Frescor:</b> %s • <b>Forte:</b> %s • <b>Reflete:</b> %s",
fresco, forte, reflete
))
 
 
-----------------------------------------------------------------
-- LOOT TABLE
-----------------------------------------------------------------
local loot = box:tag("div")
:css{
padding = "18px",
["margin-top"] = "25px",
["border-radius"] = "10px",
background = theme.lootBox
}
 
 
local t = loot:tag("table"):css{ width = "100%" }
 
 
local function row(label, color, value)
local tr = t:tag("tr")
tr:tag("th"):css{ ["text-align"] = "left", color = color, padding = "6px" }:wikitext(label)
tr:tag("td"):wikitext(value)
end
end
row("Comum:", "#f3e8bb", comum)
row("Semi-Raro:", "#aeccff", semiraro)
row("Raro:", "#e6e5ff", raro)
row("Muito Raro:", "#f9538f", muitoRaro)
-- Função principal -------------------------------------------------
function p.bossInfo(frame)
local args = frame:getParent().args
local tema = mw.text.trim(args["tema"] or "dark"):lower()
if not temas[tema] then tema = "dark" end
-- MULTIBOSS: |1= |2= |3=
local finalHtml = {}
local count = 0
for k, v in pairs(args) do
if tonumber(k) then
count = count + 1
local subArgs = mw.clone(args)
for subk, subv in mw.text.gsplit(v, ";", true) do end
subArgs.nome = v
table.insert(finalHtml, renderBoss(subArgs, temas[tema]))
end
end
if count == 0 then
table.insert(finalHtml, renderBoss(args, temas[tema]))
end
return table.concat(finalHtml, "\n\n")
end


return p
return p

Edição atual tal como às 04h47min de 17 de março de 2026

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

local p = {}

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

    local normal_nivel    = mw.text.trim(args['normal_nivel']    or '140')
    local normal_equip    = mw.text.trim(args['normal_equip']    or 'Set +8')
    local hard_personagem = mw.text.trim(args['hard_personagem'] or 'personagem 4 ou 5 estrelas (Diamante)')
    local hard_equip      = mw.text.trim(args['hard_equip']      or 'Set +16')

    local root = mw.html.create('div')
    root:addClass('gb-wrap')

    -- CSS via TemplateStyles (recomendado) ou inline
    -- Botões (tabs)
    local btns = root:tag('div'):addClass('gb-btns')

    btns:tag('button')
        :addClass('gb-btn'):addClass('active')
        :attr('onclick', "gbSwitch('n',this)")
        :wikitext('Normal ')
        :tag('span'):addClass('gb-badge'):addClass('badge-n')
        :wikitext('Nível ' .. normal_nivel)

    btns:tag('button')
        :addClass('gb-btn')
        :attr('onclick', "gbSwitch('h',this)")
        :wikitext('Hard ')
        :tag('span'):addClass('gb-badge'):addClass('badge-h')
        :wikitext(hard_equip)

    -- Painel Normal
    local pn = root:tag('div'):addClass('gb-panel'):addClass('active'):attr('id', 'gbpanel-n')
    pn:tag('div'):addClass('gb-title'):wikitext('Requisitos — Normal')
    local ln = pn:tag('ul'):addClass('gb-list')
    ln:tag('li')
        :tag('span'):addClass('gb-dot'):addClass('dot-n'):done()
        :tag('span'):wikitext('Nível mínimo: '):tag('b'):wikitext(normal_nivel)
    ln:tag('li')
        :tag('span'):addClass('gb-dot'):addClass('dot-n'):done()
        :tag('span'):wikitext('Equipamento recomendado: '):tag('b'):wikitext(normal_equip)

    -- Painel Hard
    local ph = root:tag('div'):addClass('gb-panel'):attr('id', 'gbpanel-h')
    ph:tag('div'):addClass('gb-title'):wikitext('Requisitos — Hard')
    local lh = ph:tag('ul'):addClass('gb-list')
    lh:tag('li')
        :tag('span'):addClass('gb-dot'):addClass('dot-h'):done()
        :tag('span'):wikitext('Recomendado utilizar um '):tag('b'):wikitext(hard_personagem)
    lh:tag('li')
        :tag('span'):addClass('gb-dot'):addClass('dot-h'):done()
        :tag('span'):wikitext('Equipamento recomendado: '):tag('b'):wikitext(hard_equip)

    -- Script
    local script = mw.html.create('script')
    script:wikitext([[
function gbSwitch(tab,btn){
['n','h'].forEach(function(t){document.getElementById('gbpanel-'+t).classList.remove('active');});
document.querySelectorAll('.gb-btn').forEach(function(b){b.classList.remove('active');});
document.getElementById('gbpanel-'+tab).classList.add('active');
btn.classList.add('active');
}]])

    -- CSS inline
    local style = mw.html.create('style')
    style:wikitext([[
.gb-wrap{font-family:sans-serif;max-width:600px}
.gb-btns{display:flex;border-bottom:2px solid #a2a9b1;margin-bottom:0}
.gb-btn{padding:8px 22px;font-size:14px;font-weight:bold;color:#54595d;background:transparent;border:none;border-bottom:3px solid transparent;margin-bottom:-2px;cursor:pointer;display:flex;align-items:center;gap:6px}
.gb-btn:hover{color:#202122}
.gb-btn.active{color:#202122;border-bottom-color:#3680b0}
.gb-badge{font-size:11px;padding:2px 8px;border-radius:20px;font-weight:bold}
.badge-n{background:#ddeeff;color:#185FA5}
.badge-h{background:#fce8e8;color:#a32d2d}
.gb-panel{display:none;padding:14px 2px}
.gb-panel.active{display:block}
.gb-title{font-size:11px;font-weight:bold;color:#72777d;text-transform:uppercase;letter-spacing:.06em;margin-bottom:10px}
.gb-list{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:8px}
.gb-list li{display:flex;align-items:flex-start;gap:8px;font-size:14px;color:#202122;line-height:1.5}
.gb-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0;margin-top:5px}
.dot-n{background:#3680b0}
.dot-h{background:#e24b4a}
@media(max-width:480px){.gb-btn{padding:8px 14px;font-size:13px}}]])

    return tostring(style) .. tostring(root) .. tostring(script)
end

return p