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 strRepeat = string.rep 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 matchReportArticle = args.matchReportArticle or local caption = args.caption
-- The colours for each result local colours_win = "#99FF99" -- Win local colours_loss = "#FFDDDD" -- Loss --local colours_tie = "" local colours_noResult = "#DFDFFF" -- No result local colours_eliminated = "#DCDCDC" -- Eliminated local colours_notPossible = "#DCDCDC" -- Not technically possible (only used for some playoff matches with knockoutType=2) -- The CSS classes applied to the cells of each result local classes_win = "yes table-yes2" local classes_loss = "no table-no2" local classes_noResult = "noresult" --local classes_tie = "" -- The output buffer local output = local outputIndex = 1 function print(s) output[outputIndex] = s outputIndex = outputIndex + 1 end -- Construct the header print(strFormat(class="wikitable" style="text-align: center"%s! scope="col" rowspan="2" | Team! colspan="%d" style="border-left: 4px solid #454545" | Group matches|-]], caption and '\n|+' .. caption or , matchesPerTeam)) for i = 1, matchesPerTeam do -- Generate the headers for each group match print(strFormat('! scope="col" style="width: 30px;%s" | %d\n', i
1 and '| style="border-left: 4px solid #454545; ' or '|| style="') local rpos = strFind(gs, '%S', startPos) if rpos and (rpos < comma or comma
-- Check that the match number is a valid non-negative integer greater than the preceding match number. if not match or match <= 0 or match % 1 ~= 0 then error(strFormat("Match number does not exist or is not a valid integer greater than 0 for group stage result #%d (team: %s)", j, team)) elseif match <= lastMatch then error(strFormat("Invalid match number: %d for group stage result #%d, must be greater than the preceding match number (%d) (team: %s)", match, j, lastMatch, team)) end lastMatch = match if result
'L' then -- Loss print(strFormat('background-color: %s" class="%s" | %d ', colours_loss, classes_loss, matchReportArticle, match, runningScore)) elseif result
'T' then -- Tie -- runningScore = runningScore + 1 -- print(strFormat('background-color: %s" class="%s" | %d ', colours_tie, classes_tie, matchReportArticle, match, runningScore)) else error(strFormat("Invalid group stage result #%d: '%s', expecting 'W', 'L', 'N', or 'T' as first character (team: %s)", j, result, team)) end else -- Result not given print('" | ') end until comma
Win | Loss | No result |
return _module