.mw-parser-output .documentation,.mw-parser-output .documentation-metadata{border:1px solid var(--border-color-base,#a2a9b1);background-color:#ecfcf4;color:inhe
local _module = {}
_module.create = function(frame)
------------- Functions -------------
local strFind = string.find
local strMatch = string.match
local strSplit = mw.text.split
local strFormat = string.format
local strTrim = mw.text.trim
local strSub = string.sub
local strUpper = string.upper
------------- Arguments -------------
local args = frame.args
local matchesPerTeam = tonumber(args.matchesPerTeam) or error("Invalid or missing parameter 'matchesPerTeam'")
local teams = strSplit(args.teams or error("Invalid or missing parameter 'teams'"), ',', true)
local playoffLabels = {}
if args.playoffLabels and args.playoffLabels ~= "" then
playoffLabels = strSplit(args.playoffLabels, ',', true)
end
local numPlayoffs = #playoffLabels
local matchReportArticle = args.matchReportArticle or ''
local caption = args.caption
local colours_win = "#99FF99"
local colours_loss = "#FFDDDD"
local colours_tie = "#FFFFCC"
local colours_noResult = "#DFDFFF"
local colours_eliminated = "#DCDCDC"
local classes_win = "yes table-yes2"
local classes_loss = "no table-no2"
local classes_tie = "table-partial"
local classes_noResult = "noresult"
local output = {}
local function print(s)
table.insert(output, s)
end
-- Header
print(strFormat([[
{| class="wikitable" style="text-align: center; font-size: 100%%"
%s
! scope="col" rowspan="2" | Team
! colspan="%d" style="border-left: 4px solid #454545" | Group matches
]], caption and '|+ ' .. caption or '', matchesPerTeam))
if numPlayoffs > 0 then
print(strFormat('! colspan="%d" style="border-left: 4px solid #454545" | Play-offs\n', numPlayoffs))
end
print('|-\n')
for i = 1, matchesPerTeam do
print(strFormat('! scope="col" style="width: 45px;%s" | %d\n', i == 1 and " border-left: 4px solid #454545" or "", i))
end
for i = 1, numPlayoffs do
print(strFormat('! scope="col" style="width: 40px;%s" | %s\n', i == 1 and " border-left: 4px solid #454545" or "", strTrim(playoffLabels[i])))
end
local argCounter = 1
-- Rows
for i = 1, #teams do
local team = strTrim(teams[i])
print('\n|-\n! scope="row" style="text-align: left; padding-right: 10px" | ' .. team .. '\n')
local groupResultsRaw = args[argCounter] or ''
local playoffResultsRaw = args[argCounter + 1] or ''
argCounter = argCounter + 2
local g_results = strSplit(groupResultsRaw, ',', true)
local p_results = strSplit(playoffResultsRaw, ',', true)
local runningScore = 0
-- 1. Group Stage
for j = 1, matchesPerTeam do
local resultData = strTrim(g_results[j] or "")
local cellStart = (j == 1) and '| style="border-left: 4px solid #454545; ' or '|| style="'
if resultData ~= "" then
local res = strUpper(strSub(resultData, 1, 1))
if not strFind("WLTN", res) then
error(strFormat("Invalid Result '%s' for %s. Use W, L, T, or N.", res, team))
end
local match_id = strMatch(resultData, '%d+%a?')
local bonus = tonumber(strMatch(resultData, '%+(%d+)')) or 0
if res == 'W' then runningScore = runningScore + 2
elseif res == 'T' or res == 'N' then runningScore = runningScore + 1 end
runningScore = runningScore + bonus
local color = (res == 'W' and colours_win) or (res == 'L' and colours_loss) or (res == 'T' and colours_tie) or colours_noResult
local class = (res == 'W' and classes_win) or (res == 'L' and classes_loss) or (res == 'T' and classes_tie) or classes_noResult
print(strFormat('%sbackground-color: %s" class="%s" | [[%s#match%s|%d]] ', cellStart, color, class, matchReportArticle, match_id or '', runningScore))
else
print(cellStart .. '" | ')
end
end
-- 2. Play-offs
if numPlayoffs > 0 then
for k = 1, numPlayoffs do
local pData = strTrim(p_results[k] or "")
local cellStart = (k == 1) and '|| style="border-left: 4px solid #454545; ' or '|| style="'
if pData ~= "" then
local res = strUpper(strSub(pData, 1, 1))
if not strFind("WLTNE", res) then
error(strFormat("Invalid Play-off Result '%s' for %s. Use W, L, T, N, or E.", res, team))
end
local match_id = strMatch(pData, '%d+%a?')
local color = (res == 'W' and colours_win) or (res == 'L' and colours_loss) or (res == 'T' and colours_tie) or (res == 'E' and colours_eliminated) or colours_noResult
if res == 'E' then
print(strFormat('%sbackground-color: %s" | — ', cellStart, color))
else
print(strFormat('%sbackground-color: %s" | [[%s#match%s|%s]] ', cellStart, color, matchReportArticle, match_id or '', res))
end
else
-- Check if there is a result in ANY future column for this team
local hasFutureResult = false
for future = k + 1, #p_results do
if strTrim(p_results[future] or "") ~= "" then
hasFutureResult = true
break
end
end
if hasFutureResult then
print(cellStart .. '" | → ')
else
print(cellStart .. '" | ')
end
end
end
end
end
-- Footer Legend
print(strFormat([[
|}
{| class="wikitable" style="text-align: center; font-size: 90%%"
| class="%s" style="background-color: %s" | Win
| class="%s" style="background-color: %s" | Loss
| class="%s" style="background-color: %s" | Tie
| class="%s" style="background-color: %s" | No result
| style="background-color: %s" | Eliminated
|}
<ul style="font-size: 85%%">
<li>'''Note''': The total points at the end of each group match are listed.</li>
<li>'''Note''': Click on the points or results to see the match summary.</li>
</ul>
]], classes_win, colours_win, classes_loss, colours_loss, classes_tie, colours_tie, classes_noResult, colours_noResult, colours_eliminated))
return table.concat(output)
end
return _module
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.