Module:RequirementBox

Revision as of 02:42, 3 January 2026 by Admin Jeremy (talk | contribs) (Created page with "local p = {} function p.render(frame) local title = frame.args.title or "Game" local game = frame.args.game or "" local state = frame.args.state or "" -- Grab content for each category local appear = frame.args.appear or "" local visit = frame.args.visit or "" local resident = frame.args.resident or "" local romance = frame.args.romance or "" local tricks = frame.args.tricks or "" -- Helper to render a category...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:RequirementBox/doc

local p = {}

function p.render(frame)
    local title = frame.args.title or "Game"
    local game  = frame.args.game or ""
    local state = frame.args.state or ""
    
    -- Grab content for each category
    local appear   = frame.args.appear or ""
    local visit    = frame.args.visit or ""
    local resident = frame.args.resident or ""
    local romance  = frame.args.romance or ""
    local tricks   = frame.args.tricks or ""
    
    -- Helper to render a category
    local function renderCategory(title, list)
        if list == "" then return "" end
        return string.format([[
<div class="vp-requirements-category">
  <div class="requirements-header">%s</div>
  <ul class="vp-requirements-list">
    %s
  </ul>
</div>
]], title, list)
    end
    
    -- Build the requirements HTML
    local requirementsHTML = '<div class="vp-requirements">\n'
    requirementsHTML = requirementsHTML .. renderCategory("Appear", appear)
    requirementsHTML = requirementsHTML .. renderCategory("Visit", visit)
    requirementsHTML = requirementsHTML .. renderCategory("Resident", resident)
    requirementsHTML = requirementsHTML .. renderCategory("Romance", romance)
    requirementsHTML = requirementsHTML .. renderCategory("Tricks", tricks)
    requirementsHTML = requirementsHTML .. '\n</div>'
    
    -- Build the top-level <details>
    local openAttr = ""
    if state ~= "mw-collapsed" and state ~= "" then
        openAttr = ' open="open"'
    elseif state == "" then
        openAttr = ' open="open"'  -- default open
    end
    
    local html = string.format([[
<details class="vp-gamebox"%s>
  <summary class="vp-gamebox-header">%s</summary>
  <div class="vp-gamebox-content">
    %s
  </div>
</details>
]], openAttr, title, requirementsHTML)
    
    return html
end

return p