Module:Bracket Explained

local p =

function p._teamBracket(frame, template, subs, args) -- figure out parameters from template name args.rounds = args.rounds or mw.ustring.match(template or , "^(%d*)Round") if not args.rounds then local teams = tonumber(mw.ustring.match(template or , "^(%d*)Team")) if teams and teams > 1 then -- log2(teams) is the number of rounds args.rounds = math.ceil(math.log(teams)/math.log(2)) end end local tennis = mw.ustring.match(template or , "-Tennis(%d*)") local squash = mw.ustring.match(template or , "-Squash(%d*)") if tennis or squash then args.sets = args.sets or tennis or squash args.seeds = args.seeds or 'yes' args.nowrap = args.nowrap or 'yes' end if string.find(template, "-Compact") then args.compact = args.compact or 'yes' end -- overwrite defaults with frame args and alternative args for k, v in pairs(frame.args) do if subs[k] then args[subs[k]] = v else args[k] = v end end --return template return require('Module:Team bracket').main(frame:newChild)end

function p.TwoTeamBracket(frame) return p._teamBracket(frame, '2TeamBracket',,)endp['2TeamBracket'] = p.TwoTeamBracket

function p.FourTeamBracket(frame) return p._teamBracket(frame, '4TeamBracket',,)endp['4TeamBracket'] = p.FourTeamBracket

function p.FourTeamBracketTennis3(frame) return p._teamBracket(frame, '4TeamBracket-Tennis3',,)endp['4TeamBracket-Tennis3'] = p.FourTeamBracketTennis3

function p.FourTeamBracketTennis5(frame) return p._teamBracket(frame, '4TeamBracket-Tennis5',,)endp['4TeamBracket-Tennis5'] = p.FourTeamBracketTennis5

function p.FourTeamBracketTennis35(frame) return p._teamBracket(frame, '4TeamBracket-Tennis35',,)endp['4TeamBracket-Tennis35'] = p.FourTeamBracketTennis35

function p.SixTeamBracket(frame) stepdown = require('Module:yesno')(frame.args.stepdown) return p._teamBracket(frame, '6TeamBracket',,)endp['6TeamBracket'] = p.SixTeamBracket

function p.SevenTeamBracket(frame) return p._teamBracket(frame, '7TeamBracket',,)endp['7TeamBracket'] = p.SevenTeamBracket

function p.EightTeamBracket(frame) return p._teamBracket(frame, '8TeamBracket',,)endp['8TeamBracket'] = p.EightTeamBracket

function p.EightTeamBracketByes(frame) return p._teamBracket(frame, '8TeamBracket-Byes',,)endp['3RoundBracket-Byes'] = p.EightTeamBracketByesp['8TeamBracket-Byes'] = p.EightTeamBracketByes

function p.EightTeamBracketCompactNoSeedsByes(frame) return p._teamBracket(frame, '8TeamBracket-Compact-NoSeeds-Byes',,)endp['8TeamBracket-Compact-NoSeeds-Byes'] = p.EightTeamBracketCompactNoSeedsByes

function p.EightTeamBracketTennis3(frame) return p._teamBracket(frame, '8TeamBracket-Tennis3',,)endp['8TeamBracket-Tennis3'] = p.EightTeamBracketTennis3

function p.EightTeamBracketTennis5(frame) return p._teamBracket(frame, '8TeamBracket-Tennis5',,)endp['8TeamBracket-Tennis5'] = p.EightTeamBracketTennis5

function p.SixteenTeamBracket(frame) return p._teamBracket(frame, '16TeamBracket',,)endp['16TeamBracket'] = p.SixteenTeamBracket

function p.SixteenTeamBracketByes(frame) return p._teamBracket(frame, '16TeamBracket-Byes',,)endp['4RoundBracket-Byes'] = p.SixteenTeamBracketByesp['16TeamBracket-Byes'] = p.SixteenTeamBracketByes

function p.SixteenTeamBracketTennis3(frame) return p._teamBracket(frame, '16TeamBracket-Tennis3',,)endp['16TeamBracket-Tennis3'] = p.SixteenTeamBracketTennis3

function p.SixteenTeamBracketCompactNoSeedsByes(frame) return p._teamBracket(frame, '16TeamBracket-Compact-NoSeeds-Byes',,)endp['16TeamBracket-Compact-NoSeeds-Byes'] = p.SixteenTeamBracketCompactNoSeedsByes

function p.SixteenTeamBracketCompactTennis3(frame) return p._teamBracket(frame, '16TeamBracket-Compact-Tennis3',,)endp['16TeamBracket-Compact-Tennis3'] = p.SixteenTeamBracketCompactTennis3

function p.SixteenTeamBracketCompactTennis3Byes(frame) return p._teamBracket(frame, '16TeamBracket-Compact-Tennis3-Byes',,)endp['16TeamBracket-Compact-Tennis3-Byes'] = p.SixteenTeamBracketCompactTennis3Byesp['4RoundBracket-Compact-Tennis3-Byes'] = p.SixteenTeamBracketCompactTennis3Byes

function p.SixteenTeamBracketCompactArchery(frame) return p._teamBracket(frame, '16TeamBracket-Compact-Archery',,)endp['16TeamBracket-Compact-Archery'] = p.SixteenTeamBracketCompactArchery

function p.SixteenTeamBracketTennis5(frame) return p._teamBracket(frame, '16TeamBracket-Tennis5',,)endp['16TeamBracket-Tennis5'] = p.SixteenTeamBracketTennis5

function p.SixteenTeamBracketCompactTennis5(frame) return p._teamBracket(frame, '16TeamBracket-Compact-Tennis5',,)endp['16TeamBracket-Compact-Tennis5'] = p.SixteenTeamBracketCompactTennis5

function p.SixteenTeamBracketCompactTennis5Byes(frame) return p._teamBracket(frame, '16TeamBracket-Compact-Tennis5-Byes',,)endp['16TeamBracket-Compact-Tennis5-Byes'] = p.SixteenTeamBracketCompactTennis5Byesp['4RoundBracket-Compact-Tennis5-Byes'] = p.SixteenTeamBracketCompactTennis5Byes

function p.ThirtyTwoTeamBracket(frame) return p._teamBracket(frame, '32TeamBracket',,)endp['32TeamBracket'] = p.ThirtyTwoTeamBracket

function p.ThirtyTwoTeamBracketByes(frame) return p._teamBracket(frame, '32TeamBracket-Byes',,)endp['32TeamBracket-Byes'] = p.ThirtyTwoTeamBracketByes

function p.ThirtyTwoTeamBracketCompactNoSeedsByes(frame) return p._teamBracket(frame, '32TeamBracket-Compact-NoSeeds-Byes',,)endp['32TeamBracket-Compact-NoSeeds-Byes'] = p.ThirtyTwoTeamBracketCompactNoSeedsByes

function p.ThirtyTwoTeamBracketCompactSquash5(frame) return p._teamBracket(frame, '32TeamBracket-Compact-Squash5',,)endp['32TeamBracket-Compact-Squash5'] = p.ThirtyTwoTeamBracketCompactSquash5

function p.ThirtyTwoTeamBracketCompactTennis3(frame) return p._teamBracket(frame, '32TeamBracket-Compact-Tennis3',,)endp['32TeamBracket-Compact-Tennis3'] = p.ThirtyTwoTeamBracketCompactTennis3

function p.ThirtyTwoTeamBracketTennis3(frame) return p._teamBracket(frame, '32TeamBracket-Tennis3',,)endp['32TeamBracket-Tennis3'] = p.ThirtyTwoTeamBracketTennis3

function p.SixtyFourTeamBracket(frame) return p._teamBracket(frame, '64TeamBracket',,)endp['64TeamBracket'] = p.SixtyFourTeamBracket

function p.list(frame) local funcs=

for k,_ in pairs(p) do if string.match(k, "^%d+Team") then table.insert(funcs, k) end end table.sort(funcs, function (a,b) na, nb = tonumber(string.match(a, "^%d+")), tonumber(string.match(b, "^%d+")) return na

nb and string.match(a, "^%d*(.*)$") < string.match(b, "^%d*(.*)$") or na < nb end) return frame.preprocess(frame, "\n* \n* ")end

function p.doc(frame) local pagename = mw.title.getCurrentTitle.rootText if type(p[pagename])

"function" then return frame.preprocess(frame, " can be " .. "replaced with .") end return frame.preprocess(frame, "In most cases, the name of the bracket " .. "template can be used as the function name for, e.g. " .. "→" .. ".")end

return p