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

De Wiki Gla
Ir para navegação Ir para pesquisar
Etiqueta: Revertido
Etiquetas: Reversão manual Revertido
Linha 1: Linha 1:
-- Módulo:BossDisplay (responsivo)
local p = {}
local p = {}


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


-- caixa de texto
    local function g(k, default)
local textBox = main:tag("div"):css{ flex = 1 }
        return mw.text.trim(args[k] or "") ~= "" and args[k] or default
 
    end
 
textBox:tag("div")
:css{ ["font-size"] = "1.25em", ["font-weight"] = "bold", color = "#e82b2b" }
:wikitext(nome)


    local img        = g("img",        "Placeholder.png")
    local nome      = g("nome",      "Nome do Boss")
    local frase      = g("frase",      "Frase ou lema do boss.")
    local hp        = g("hp",        "???")
    local exp        = g("exp",        "???")
    local nivel      = g("nivel",      "???")
    local fresco    = g("fresco",    "-")
    local forte      = g("forte",      "-")
    local reflete    = g("reflete",    "-")
    local comum      = g("comum",      "")
    local semiraro  = g("semiraro",  "")
    local raro      = g("raro",      "")
    local muitoRaro  = g("muitoraro",  "")


-----------------------------------------------------------------
    ----------------------------------------------------
-- Stats
    -- CSS responsivo embutido
-----------------------------------------------------------------
    ----------------------------------------------------
local stats = main:tag("div")
    local css = [[
:css{
<style>
display = "flex",
@media screen and (max-width: 650px) {
["flex-direction"] = "column",
  .boss-main {
gap = "5px",
    flex-direction: column !important;
["min-width"] = "170px"
    text-align: center;
}
    gap: 16px;
  }


  .boss-img-box img {
    width: 70px !important;
    height: 70px !important;
  }


local statBox = stats:tag("div")
  .boss-stats {
:css{
    align-items: center !important;
padding = "12px 18px",
  }
["border-radius"] = "8px",
["background-color"] = theme.variantB
}
}
</style>
]]


    local html = mw.html.create()


statBox:wikitext(string.format('<span style="font-size:1.1em; color:#fb3d3d; font-weight:bold;">❤️ %s</span> ', hp))
    html:wikitext(css)
statBox:wikitext(string.format('<span style="font-size:1.1em; color:#ffe568; font-weight:bold;">💰 %s</span> ', exp))
statBox:wikitext(string.format('<span style="font-size:1.1em; color:#6ca8fb; font-weight:bold;">⚔️ %s</span>', nivel))


    local box = html:tag("div")
        :addClass("boss-container")
        :css{
            background = "#18181b",
            ["border-radius"] = "12px",
            padding = "30px",
            color = "#fff",
            ["max-width"] = "750px",
            width = "100%",
            margin = "auto",
            ["font-family"] = "Verdana,sans-serif",
            ["box-sizing"] = "border-box"
        }


stats:tag("div")
    ----------------------------------------------------
:css{ ["font-size"] = "90%" }
    -- Cabeçalho
:wikitext(string.format(
    ----------------------------------------------------
"<b>Frescor:</b> %s • <b>Forte:</b> %s • <b>Reflete:</b> %s",
    box:tag("div")
fresco, forte, reflete
        :css{ ["font-size"] = "1.5em", ["font-weight"] = "bold", ["margin-bottom"] = "10px" }
))
        :wikitext("Bosses")


    local var = box:tag("div")
        :css("margin-bottom", "24px")


-----------------------------------------------------------------
    var:tag("span")
-- LOOT TABLE
        :css{
-----------------------------------------------------------------
            ["background-color"] = "#232329",
local loot = box:tag("div")
            ["border-radius"] = "7px 0 0 7px",
:css{
            padding = "7px 20px",
padding = "18px",
            ["font-size"] = "1em",
["margin-top"] = "25px",
            color = "#cbcdd7",
["border-radius"] = "10px",
            ["font-weight"] = "600"
background = theme.lootBox
        }
}
        :wikitext("Unbound Crimsonveil")
 


local t = loot:tag("table"):css{ width = "100%" }
    var:tag("span")
        :css{
            ["background-color"] = "#19171c",
            ["border-radius"] = "0 7px 7px 0",
            padding = "7px 20px",
            ["font-size"] = "1em",
            color = "#fff",
            ["font-weight"] = "600",
            border = "2px solid #c7a047",
            ["border-left"] = "0"
        }
        :wikitext("Archon Crimsonveil")


    ----------------------------------------------------
    -- Corpo principal (responsivo)
    ----------------------------------------------------
    local main = box:tag("div")
        :addClass("boss-main")
        :css{
            display = "flex",
            gap = "20px",
            ["align-items"] = "center",
            ["justify-content"] = "space-between",
            ["flex-wrap"] = "wrap"
        }


local function row(label, color, value)
    main:tag("div")
local tr = t:tag("tr")
        :addClass("boss-img-box")
tr:tag("th"):css{ ["text-align"] = "left", color = color, padding = "6px" }:wikitext(label)
        :css{ ["flex"] = "none" }
tr:tag("td"):wikitext(value)
        :wikitext(string.format("[[Arquivo:%s|90px]]", img))
end


    local textBox = main:tag("div")
        :css{ ["flex"] = "1", ["min-width"] = "200px" }


row("Comum:", "#f3e8bb", comum)
    textBox:tag("div")
row("Semi-Raro:", "#aeccff", semiraro)
        :css{ ["font-size"] = "1.2em", ["font-weight"] = "bold", color = "#e82b2b" }
row("Raro:", "#e6e5ff", raro)
        :wikitext(nome)
row("Muito Raro:", "#f9538f", muitoRaro)


    textBox:tag("div")
        :css{ ["font-size"] = "95%", color = "#eaa85d", ["font-style"] = "italic" }
        :wikitext(string.format('"%s"', frase))


    ----------------------------------------------------
    -- Stats
    ----------------------------------------------------
    local stats = main:tag("div")
        :addClass("boss-stats")
        :css{
            display = "flex",
            ["flex-direction"] = "column",
            ["align-items"] = "flex-end",
            gap = "6px",
            ["min-width"] = "160px"
        }


-- Função principal -------------------------------------------------
    local statBox = stats:tag("div")
function p.bossInfo(frame)
        :css{
local args = frame:getParent().args
            ["background-color"] = "#222126",
local tema = mw.text.trim(args["tema"] or "dark"):lower()
            ["border-radius"] = "8px",
if not temas[tema] then tema = "dark" end
            padding = "12px 20px",
            ["min-width"] = "170px"
        }


    local sline = statBox:tag("div")
        :css{
            display = "flex",
            ["align-items"] = "center",
            ["justify-content"] = "center",
            gap = "16px",
            ["flex-wrap"] = "wrap"
        }


-- MULTIBOSS: |1= |2= |3=
    sline:wikitext(string.format('<span style="color:#fb3d3d;font-weight:bold;font-size:1.15em;">&#x2764;&#xFE0F; %s</span>', hp))
local finalHtml = {}
    sline:wikitext(string.format('<span style="color:#ffe568;font-weight:bold;font-size:1.08em;">&#x1F4B0; %s</span>', exp))
    sline:wikitext(string.format('<span style="color:#6ca8fb;font-weight:bold;font-size:1.04em;">&#x2694;&#xFE0F; %s</span>', nivel))


    stats:tag("div")
        :css{
            ["margin-top"] = "5px",
            ["font-size"] = "90%",
            color = "#cfccff",
            ["text-align"] = "right"
        }
        :wikitext(string.format(
            "<b>Frescor:</b> %s &nbsp;&nbsp; <b>Forte:</b> %s &nbsp;&nbsp; <b>Reflete:</b> %s",
            fresco, forte, reflete
        ))


local count = 0
    ----------------------------------------------------
for k, v in pairs(args) do
    -- Tabela de loot
if tonumber(k) then
    ----------------------------------------------------
count = count + 1
    local loot = box:tag("div")
local subArgs = mw.clone(args)
        :css{
for subk, subv in mw.text.gsplit(v, ";", true) do end
            ["margin-top"] = "28px",
subArgs.nome = v
            background = "#232329",
table.insert(finalHtml, renderBoss(subArgs, temas[tema]))
            ["border-radius"] = "10px",
end
            padding = "18px"
end
        }


    local tableEl = loot:tag("table")
        :css{
            width = "100%",
            color = "#fff",
            ["table-layout"] = "auto"
        }


if count == 0 then
    local function row(label, color, content)
table.insert(finalHtml, renderBoss(args, temas[tema]))
        local tr = tableEl:tag("tr")
end
        tr:tag("th")
            :css{
                ["text-align"] = "left",
                color = color,
                padding = "6px",
                ["font-size"] = "1.07em"
            }
            :wikitext(label)
        tr:tag("td"):wikitext(content)
    end


    row("Comum:",      "#f3e8bb", comum)
    row("Semi-Raro:",  "#aeccff", semiraro)
    row("Raro:",      "#e6e5ff", raro)
    row("Muito Raro:", "#f9538f", muitoRaro)


return table.concat(finalHtml, "\n\n")
    return tostring(html)
end
end


return p
return p

Edição das 21h45min de 22 de novembro de 2025

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

-- Módulo:BossDisplay (responsivo)
local p = {}

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

    local function g(k, default)
        return mw.text.trim(args[k] or "") ~= "" and args[k] or default
    end

    local img        = g("img",        "Placeholder.png")
    local nome       = g("nome",       "Nome do Boss")
    local frase      = g("frase",      "Frase ou lema do boss.")
    local hp         = g("hp",         "???")
    local exp        = g("exp",        "???")
    local nivel      = g("nivel",      "???")
    local fresco     = g("fresco",     "-")
    local forte      = g("forte",      "-")
    local reflete    = g("reflete",    "-")
    local comum      = g("comum",      "")
    local semiraro   = g("semiraro",   "")
    local raro       = g("raro",       "")
    local muitoRaro  = g("muitoraro",  "")

    ----------------------------------------------------
    -- CSS responsivo embutido
    ----------------------------------------------------
    local css = [[
<style>
@media screen and (max-width: 650px) {
  .boss-main {
    flex-direction: column !important;
    text-align: center;
    gap: 16px;
  }

  .boss-img-box img {
    width: 70px !important;
    height: 70px !important;
  }

  .boss-stats {
    align-items: center !important;
  }
}
</style>
]]

    local html = mw.html.create()

    html:wikitext(css)

    local box = html:tag("div")
        :addClass("boss-container")
        :css{
            background = "#18181b",
            ["border-radius"] = "12px",
            padding = "30px",
            color = "#fff",
            ["max-width"] = "750px",
            width = "100%",
            margin = "auto",
            ["font-family"] = "Verdana,sans-serif",
            ["box-sizing"] = "border-box"
        }

    ----------------------------------------------------
    -- Cabeçalho
    ----------------------------------------------------
    box:tag("div")
        :css{ ["font-size"] = "1.5em", ["font-weight"] = "bold", ["margin-bottom"] = "10px" }
        :wikitext("Bosses")

    local var = box:tag("div")
        :css("margin-bottom", "24px")

    var:tag("span")
        :css{
            ["background-color"] = "#232329",
            ["border-radius"] = "7px 0 0 7px",
            padding = "7px 20px",
            ["font-size"] = "1em",
            color = "#cbcdd7",
            ["font-weight"] = "600"
        }
        :wikitext("Unbound Crimsonveil")

    var:tag("span")
        :css{
            ["background-color"] = "#19171c",
            ["border-radius"] = "0 7px 7px 0",
            padding = "7px 20px",
            ["font-size"] = "1em",
            color = "#fff",
            ["font-weight"] = "600",
            border = "2px solid #c7a047",
            ["border-left"] = "0"
        }
        :wikitext("Archon Crimsonveil")

    ----------------------------------------------------
    -- Corpo principal (responsivo)
    ----------------------------------------------------
    local main = box:tag("div")
        :addClass("boss-main")
        :css{
            display = "flex",
            gap = "20px",
            ["align-items"] = "center",
            ["justify-content"] = "space-between",
            ["flex-wrap"] = "wrap"
        }

    main:tag("div")
        :addClass("boss-img-box")
        :css{ ["flex"] = "none" }
        :wikitext(string.format("[[Arquivo:%s|90px]]", img))

    local textBox = main:tag("div")
        :css{ ["flex"] = "1", ["min-width"] = "200px" }

    textBox:tag("div")
        :css{ ["font-size"] = "1.2em", ["font-weight"] = "bold", color = "#e82b2b" }
        :wikitext(nome)

    textBox:tag("div")
        :css{ ["font-size"] = "95%", color = "#eaa85d", ["font-style"] = "italic" }
        :wikitext(string.format('"%s"', frase))

    ----------------------------------------------------
    -- Stats
    ----------------------------------------------------
    local stats = main:tag("div")
        :addClass("boss-stats")
        :css{
            display = "flex",
            ["flex-direction"] = "column",
            ["align-items"] = "flex-end",
            gap = "6px",
            ["min-width"] = "160px"
        }

    local statBox = stats:tag("div")
        :css{
            ["background-color"] = "#222126",
            ["border-radius"] = "8px",
            padding = "12px 20px",
            ["min-width"] = "170px"
        }

    local sline = statBox:tag("div")
        :css{
            display = "flex",
            ["align-items"] = "center",
            ["justify-content"] = "center",
            gap = "16px",
            ["flex-wrap"] = "wrap"
        }

    sline:wikitext(string.format('<span style="color:#fb3d3d;font-weight:bold;font-size:1.15em;">&#x2764;&#xFE0F; %s</span>', hp))
    sline:wikitext(string.format('<span style="color:#ffe568;font-weight:bold;font-size:1.08em;">&#x1F4B0; %s</span>', exp))
    sline:wikitext(string.format('<span style="color:#6ca8fb;font-weight:bold;font-size:1.04em;">&#x2694;&#xFE0F; %s</span>', nivel))

    stats:tag("div")
        :css{
            ["margin-top"] = "5px",
            ["font-size"] = "90%",
            color = "#cfccff",
            ["text-align"] = "right"
        }
        :wikitext(string.format(
            "<b>Frescor:</b> %s &nbsp;&nbsp; <b>Forte:</b> %s &nbsp;&nbsp; <b>Reflete:</b> %s",
            fresco, forte, reflete
        ))

    ----------------------------------------------------
    -- Tabela de loot
    ----------------------------------------------------
    local loot = box:tag("div")
        :css{
            ["margin-top"] = "28px",
            background = "#232329",
            ["border-radius"] = "10px",
            padding = "18px"
        }

    local tableEl = loot:tag("table")
        :css{
            width = "100%",
            color = "#fff",
            ["table-layout"] = "auto"
        }

    local function row(label, color, content)
        local tr = tableEl:tag("tr")
        tr:tag("th")
            :css{
                ["text-align"] = "left",
                color = color,
                padding = "6px",
                ["font-size"] = "1.07em"
            }
            :wikitext(label)
        tr:tag("td"):wikitext(content)
    end

    row("Comum:",      "#f3e8bb", comum)
    row("Semi-Raro:",  "#aeccff", semiraro)
    row("Raro:",       "#e6e5ff", raro)
    row("Muito Raro:", "#f9538f", muitoRaro)

    return tostring(html)
end

return p