local p = local getArgs = require('Module:Arguments').getArgs
local function drawMatchTable(roundNo, matchNo, args) function getMatchArg(text, team, num, nbsp) num = num or 0 empty = ' ' if nbsp
' .. '\n') table.insert(output, '
' .. '\n') table.insert(output, getMatchArg('above', 1, 0, false)) table.insert(output, '
' .. '\n') table.insert(output, '
-' .. '\n') table.insert(output, ' | ' .. getMatchArg('team', 1)) if (getMatchArg('seed', 1) ~= ' ') then table.insert(output, ' (' .. getMatchArg('seed', 1) .. ')') end table.insert(output, '\n') for i=1, scoreCells do table.insert(output, ' | ' .. getMatchArg('score', 1, i) .. '\n') end table.insert(output, ' | -' .. '\n') table.insert(output, ' | ' .. getMatchArg('team', 2)) if (getMatchArg('seed', 2) ~= ' ') then table.insert(output, ' (' .. getMatchArg('seed', 2) .. ')') end table.insert(output, '\n') for i=1, scoreCells do table.insert(output, ' | ' .. getMatchArg('score', 2, i) .. '\n') end table.insert(output, ' |
' .. '\n') table.insert(output, getMatchArg('below', 2, 0, false)) table.insert(output, '
' .. '\n') table.insert(output, '
' .. '\n') return table.concat(output) end
local function drawLines(roundNo, matchNo, args) local output = if roundNo >= 2 then local leftRowStart = 2 ^ (roundNo - 2) + (matchNo - 1) * 2 * 2 ^ (roundNo - 1) local leftRowEnd = leftRowStart + 2 ^ (roundNo - 1) local rightRowStart = 2 ^ (roundNo - 1) * (matchNo - 1) + 1 local rightRowEnd = rightRowStart + 2 ^ (roundNo - 1) - 1 table.insert(output, '
' .. '\n') table.insert(output, '
' .. '\n') end return table.concat(output) end
local function getRoundName(round, totalRounds, args) if args['RD' .. round] then return args['RD' .. round] end local finalRounds = totalRounds - round if finalRounds
1 then return "Semi-finals" elseif finalRounds
function p.main(frame) local output = local args = getArgs(frame) local rounds = args.rounds local teams = 2 ^ rounds local matchWidth = args['match-width'] or '18em'; table.insert(output, '
' .. '\n') --table.insert(output, '
' .. '\n') for i=1, rounds do table.insert(output, '
' .. getRoundName(i, rounds, args) .. '
' .. '\n') for j=1, teams / (2^i) do table.insert(output, drawMatchTable(i, j, args))
table.insert(output, drawLines(i, j, args)) end end table.insert(output, '
' .. '\n') return table.concat(output) end
return p