Module:Tournament
From eSportsAmaze
More actions
Documentation for this module may be created at Module:Tournament/doc
local p = {}
local html = mw.html
local cargo = mw.ext.cargo
local lang = mw.getContentLanguage()
-- ... (Keep existing formatCurrency, formatDateRange, getCleanTitle, getSmallTeamLogo, getTeamFromPrizeMoney, getSocials, getSeriesNav, getInfoboxLogo, getTourneyLogo, listRow, listRowMain, infobox) ...
-- (Paste all the helper functions and the other main functions here. I will only show the changed function below to save space, but YOU MUST KEEP THE FULL MODULE)
-- ============================================================
-- HELPER: Get Tier Class
-- ============================================================
local function getTierClass(tier)
if not tier then return "tier-misc" end
local t = tier:lower()
if string.find(t, "s") and string.find(t, "tier") then return "tier-s" end
if string.find(t, "a") and string.find(t, "tier") then return "tier-a" end
if string.find(t, "b") and string.find(t, "tier") then return "tier-b" end
if string.find(t, "c") and string.find(t, "tier") then return "tier-c" end
return "tier-misc"
end
-- ============================================================
-- MAIN 2: TABLE ROW (UPDATED FOR HYBRID DESIGN)
-- ============================================================
function p.tableRow(frame)
local args = frame.args
local page = args.Page or ""
local name = getCleanTitle(page)
local startDate = args.start_date or ""
local endDate = args.end_date or ""
local prize = args.prize_pool or "0"
local tier = args.tier or "-"
-- Auto-Fetch Winners
local winner = args.winner
if not winner or winner == "" then winner = getTeamFromPrizeMoney(page, name, "1") end
local runnerUp = args.runner_up
if not runnerUp or runnerUp == "" then runnerUp = getTeamFromPrizeMoney(page, name, "2") end
local row = html.create('tr')
-- 1. Date (Desktop: Box, Mobile: Label)
row:tag('td')
:attr('data-label', 'Date') -- For Mobile
:attr('data-sort-value', startDate)
:tag('div'):addClass('tr-date'):wikitext(formatDateRange(startDate, endDate))
-- 2. Tier (Color Coded Pill)
row:tag('td')
:attr('data-label', 'Tier')
:css('text-align', 'center')
:tag('span'):addClass('tier-badge'):addClass(getTierClass(tier)):wikitext(tier)
-- 3. Tournament Name
row:tag('td')
:attr('data-label', 'Tournament')
:css('font-weight', 'bold'):wikitext('[[' .. page .. '|' .. name .. ']]')
-- 4. Location
row:tag('td')
:attr('data-label', 'Location')
:wikitext(args.location or '-')
-- 5. Prize
row:tag('td')
:attr('data-label', 'Prize')
:attr('data-sort-value', prize)
:addClass('tr-prize')
:css('text-align', 'right')
:wikitext(formatCurrency(prize))
-- 6. Winner (Gold Background on Desktop)
local winCell = row:tag('td')
:attr('data-label', 'Winner')
:addClass('cell-winner') -- For Gold Background
if winner and winner ~= "" then
winCell:wikitext(getSmallTeamLogo(winner) .. '[[' .. winner .. ']]')
else
winCell:css('text-align', 'center'):wikitext('-')
end
-- 7. Runner Up
local runCell = row:tag('td'):attr('data-label', 'Runner Up')
if runnerUp and runnerUp ~= "" then
runCell:wikitext(getSmallTeamLogo(runnerUp) .. '[[' .. runnerUp .. ']]')
else
runCell:css('text-align', 'center'):wikitext('-')
end
return tostring(row)
end
return p