Módulo:ItemInfobox

De Cronicas Eternas Wiki
NOME
INFORMAÇÃO BÁSICA

local p = {}

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

    local sections = {
        ["INFORMAÇÃO BÁSICA"] = {
            {"Apelido", args["nickname"]},
            {"Localização", args["location"]},
            {"Tipo", args["type"]},
            {"Valor", args["value"]},
            {"Raridade", args["rarity"]},
            {"Sintonização", args["attunement"]},
            {"Escola", args["school"]},
        },
    }

    local infobox = string.format('<div style="width:22em; background:#f9f9f9; border:1px solid #aaa; float:right; padding:5px; font-size:90%%;">' ..
        '<div style="text-align:center; background:#ccc; font-size:120%%; padding:4px;">%s</div>', args["name"] or "NOME")

    for section, fields in pairs(sections) do
        infobox = infobox .. string.format('<div style="text-align:center; background:#ddd; font-size:110%%; padding:4px; margin-top:5px;">%s</div>', section)
        for _, field in ipairs(fields) do
            local label, value = field[1], field[2]
            if value and value ~= "" then
                infobox = infobox .. string.format('<div style="padding:2px 5px;"><strong>%s:</strong> %s</div>', label, value)
            end
        end
    end

    infobox = infobox .. '</div>'

    return infobox
end

return p