Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 01:35, 25 January 2026 by Esportsamaze (talk | contribs) (Created page with "local p = {} local html = mw.html -- Helper: Check if file exists local function fileExists(filename) return mw.title.new('File:' .. filename).exists end function p.card(frame) local args = frame:getParent().args local team = args.team or "" local seeding = args.seeding or "" -- 1. Build the Container (roster-card style) local root = html.create('div'):addClass('roster-card') -- 2. HEADER SECTION local header = root:tag('div'):...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}
local html = mw.html

-- Helper: Check if file exists
local function fileExists(filename)
    return mw.title.new('File:' .. filename).exists
end

function p.card(frame)
    local args = frame:getParent().args
    local team = args.team or ""
    local seeding = args.seeding or ""
    
    -- 1. Build the Container (roster-card style)
    local root = html.create('div'):addClass('roster-card')
    
    -- 2. HEADER SECTION
    local header = root:tag('div'):addClass('roster-header')
    local headerContent = header:tag('div'):addClass('header-content')
    
    -- Logo Logic (Light/Dark Mode support)
    local logoDiv = headerContent:tag('div'):addClass('roster-logo')
    local lightFile = team .. '.png'
    local darkFile = team .. '_dark.png'
    local hasLight = fileExists(lightFile)
    local hasDark = fileExists(darkFile)
    
    -- Light Mode Logo
    local lDiv = logoDiv:tag('div'):addClass('logo-lightmode')
    if hasLight then
        lDiv:wikitext('[[File:' .. lightFile .. '|link=]]')
    else
        lDiv:wikitext('[[File:Shield_team.png|link=]]')
    end
    
    -- Dark Mode Logo
    local dDiv = logoDiv:tag('div'):addClass('logo-darkmode')
    if hasDark then
        dDiv:wikitext('[[File:' .. darkFile .. '|link=]]')
    elseif hasLight then
        dDiv:wikitext('[[File:' .. lightFile .. '|link=]]')
    else
        dDiv:wikitext('[[File:Shield_team_dark.png|link=]]')
    end
    
    -- Team Name
    headerContent:tag('div'):addClass('roster-name'):wikitext('[[' .. team .. ']]')
    
    -- Seeding (Optional Subheader)
    if seeding ~= "" then
        root:tag('div'):addClass('roster-subheader'):wikitext(seeding)
    end
    
    -- 3. CONTENT ROWS (Players & Staff)
    local contentRows = root:tag('div'):addClass('roster-content-rows')
    
    -- Count Players (for CSS grid styling)
    local players = {args.p1, args.p2, args.p3, args.p4, args.p5, args.p6}
    local playerCount = 0
    for _, p in ipairs(players) do
        if p and p ~= "" then playerCount = playerCount + 1 end
    end
    
    -- Player Grid
    local playerInner = contentRows:tag('div'):addClass('roster-players-inner'):addClass('count-' .. playerCount)
    for _, player in ipairs(players) do
        if player and player ~= "" then
            playerInner:tag('div'):addClass('roster-row player'):wikitext('[[' .. player .. ']]')
        end
    end
    
    -- Staff Grid (Coach/Analyst)
    if (args.coach and args.coach ~= "") or (args.analyst and args.analyst ~= "") then
        local staffInner = contentRows:tag('div'):addClass('roster-staff-inner')
        
        if args.coach and args.coach ~= "" then
            staffInner:tag('div'):addClass('roster-row staff'):wikitext('C: [[' .. args.coach .. ']]')
        end
        if args.analyst and args.analyst ~= "" then
            staffInner:tag('div'):addClass('roster-row staff'):wikitext('A: [[' .. args.analyst .. ']]')
        end
    end
    
    return tostring(root)
end

return p