Module:Bracket
This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
Wrapper for bracket templates, which can be used in place of the following for reduced Post-expand include size:
- {{4TeamBracket}}
- {{4TeamBracket-Tennis3}}
- {{4TeamBracket-Tennis5}}
- {{4TeamBracket-Tennis35}}
- {{6TeamBracket}}
- {{7TeamBracket}}
- {{8TeamBracket}}
- {{8TeamBracket-Byes}}
- {{8TeamBracket-Tennis3}}
- {{8TeamBracket-Tennis5}}
- {{16TeamBracket}}
- {{16TeamBracket-Byes}}
- {{16TeamBracket-Tennis3}}
- {{16TeamBracket-Compact-Tennis3}}
- {{16TeamBracket-Compact-Tennis3-Byes}}
- {{16TeamBracket-Tennis5}}
- {{16TeamBracket-Compact-Tennis5}}
- {{16TeamBracket-Compact-Tennis5-Byes}}
Usage
mali niŋ{{#invoke:Bracket|template_name}}
Example
mali niŋ{{#invoke:Bracket|16TeamBracket-Compact-Tennis3}}
1st round | 2nd round | Semifinals | Finals | ||||||||||||||||||||||||
local p = {}
local teamBracket = require('Module:Team bracket').main
function p._teamBracket(frame, template, subs, defs)
args = {}
-- assign defaults
for k, v in pairs(defs) do
args[k] = v
end
-- figure out parameters from template name
teams = tonumber(mw.ustring.match(template or '', "^(%d*)Team"))
if not teams then
teams = mw.ustring.match(template or '', "^(%d*)Round")
elseif teams <= 2 then
args.rounds = args.rounds or 1
elseif teams <= 4 then
args.rounds = args.rounds or 2
elseif teams <= 8 then
args.rounds = args.rounds or 3
elseif teams <= 16 then
args.rounds = args.rounds or 4
end
tennis = mw.ustring.match(template or '', "-Tennis(%d*)")
if tennis then
args.sets = args.sets or tennis
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
-- get 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{title = ("Template:" .. template), args = args})
end
function p.FourTeamBracket(frame)
return p._teamBracket(frame, '4TeamBracket', {
group1 = "RD1-group1"
}, {
autoseeds = "y",
['RD1-group1'] = ""
})
end
p['4TeamBracket'] = p.FourTeamBracket
function p.FourTeamBracketTennis3(frame)
return p._teamBracket(frame, '4TeamBracket-Tennis3', {}, {
RD2 = "Final",
['team-width'] = 125
})
end
p['4TeamBracket-Tennis3'] = p.FourTeamBracketTennis3
function p.FourTeamBracketTennis5(frame)
return p._teamBracket(frame, '4TeamBracket-Tennis5', {}, {
seeds = '',
RD1 = "Quarterfinals",
RD2 = "Semifinals",
['team-width'] = 125,
['RD1-seed1'] = '',
['RD1-seed2'] = '',
['RD1-seed3'] = '',
['RD1-seed4'] = '',
})
end
p['4TeamBracket-Tennis5'] = p.FourTeamBracketTennis5
function p.FourTeamBracketTennis35(frame)
return p._teamBracket(frame, '4TeamBracket-Tennis35', {}, {
sets = "3/5",
RD1 = "Semifinals",
RD2 = "Final",
['RD1-seed1'] = '',
['RD1-seed2'] = '',
['RD1-seed3'] = '',
['RD1-seed4'] = '',
})
end
p['4TeamBracket-Tennis35'] = p.FourTeamBracketTennis35
function p.SixTeamBracket(frame)
stepdown = require('Module:yesno')(frame.args.stepdown)
return p._teamBracket(frame, '6TeamBracket', {
group1 = "RD1-group1",
group2 = "RD1-group2",
group3 = "RD2-group1",
}, {
compact = "y",
seeds = "y",
byes = '',
['RD1-omit'] = stepdown and "3/4/7/8" or "1/2/5/6",
['RD1-group1'] = "",
['RD1-group2'] = "",
['RD2-group1'] = "",
['RD1-seed1'] = 4,
['RD1-seed2'] = 5,
['RD1-seed3'] = 3,
['RD1-seed4'] = 6,
['RD2-seed1'] = stepdown and '' or 1,
['RD2-seed2'] = stepdown and 1 or '',
['RD2-seed3'] = stepdown and '' or 2,
['RD2-seed4'] = stepdown and 2 or '',
})
end
p['6TeamBracket'] = p.SixTeamBracket
function p.SevenTeamBracket(frame)
return p._teamBracket(frame, '7TeamBracket', {
group1 = "RD1-group1",
group2 = "RD1-group2",
group3 = "RD2-group1",
['RD1-seed01'] = 'RD1-seed1',
['RD1-seed02'] = 'RD1-seed2',
['RD1-seed03'] = 'RD1-seed3',
['RD1-seed04'] = 'RD1-seed4',
['RD1-seed05'] = 'RD1-seed5',
['RD1-seed06'] = 'RD1-seed6',
['RD2-seed01'] = 'RD2-seed1',
['RD1-team01'] = 'RD1-team1',
['RD1-team02'] = 'RD1-team2',
['RD1-team03'] = 'RD1-team3',
['RD1-team04'] = 'RD1-team4',
['RD1-team05'] = 'RD1-team5',
['RD1-team06'] = 'RD1-team6',
}, {
['RD1-omit'] = "1/2",
byes = 1,
['RD1-group1'] = "",
['RD1-group2'] = "",
['RD2-group1'] = "",
['RD1-seed1'] = 4,
['RD1-seed2'] = 5,
['RD1-seed3'] = 2,
['RD1-seed4'] = 7,
['RD1-seed5'] = 3,
['RD1-seed6'] = 6,
['RD2-seed1'] = 1,
['RD1-team1'] = ' ',
['RD1-team2'] = ' ',
['RD1-team3'] = ' ',
['RD1-team4'] = ' ',
['RD1-team5'] = ' ',
['RD1-team6'] = ' ',
})
end
p['7TeamBracket'] = p.SevenTeamBracket
function p.EightTeamBracket(frame)
return p._teamBracket(frame, '8TeamBracket', {
group1 = 'RD1-group1',
group2 = 'RD1-group2',
group3 = 'RD2-group1',
['RD1-seed01'] = 'RD1-seed1',
['RD1-seed02'] = 'RD1-seed2',
['RD1-seed03'] = 'RD1-seed3',
['RD1-seed04'] = 'RD1-seed4',
['RD1-seed05'] = 'RD1-seed5',
['RD1-seed06'] = 'RD1-seed6',
['RD1-seed07'] = 'RD1-seed7',
['RD1-seed08'] = 'RD1-seed8',
}, {
['RD1-seed1'] = 1,
['RD1-seed2'] = 8,
['RD1-seed3'] = 4,
['RD1-seed4'] = 5,
['RD1-seed5'] = 2,
['RD1-seed6'] = 7,
['RD1-seed7'] = 3,
['RD1-seed8'] = 6,
})
end
p['8TeamBracket'] = p.EightTeamBracket
function p.EightTeamBracketByes(frame)
return p._teamBracket(frame, '8TeamBracket-Byes', {
group1 = "RD1-group1",
group2 = "RD1-group2",
group3 = "RD2-group1",
Consol = "RD3b"
}, {
seeds = 'yes',
byes = 1,
['team-width'] = '11em',
['score-width'] = '2em',
['RD1-group1'] = '',
['RD1-group2'] = '',
['RD2-group1'] = '',
RD3b = frame.args['RD3-team3'] and "Third place" or ""
})
end
p['3RoundBracket-Byes'] = p.EightTeamBracketByes
p['8TeamBracket-Byes'] = p.EightTeamBracketByes
function p.EightTeamBracketTennis3(frame)
return p._teamBracket(frame, '8TeamBracket-Tennis3', {}, {
RD1 = 'Quarterfinals',
RD2 = 'Semifinals',
RD3 = 'Final',
['team-width'] = 140,
['RD1-seed1'] = 1,
['RD1-seed2'] = 8,
['RD1-seed3'] = 4,
['RD1-seed4'] = 5,
['RD1-seed5'] = 3,
['RD1-seed6'] = 6,
['RD1-seed7'] = 2,
['RD1-seed8'] = 7,
})
end
p['8TeamBracket-Tennis3'] = p.EightTeamBracketTennis3
function p.EightTeamBracketTennis5(frame)
return p._teamBracket(frame, '8TeamBracket-Tennis5', {}, {
RD1 = 'Quarterfinals',
RD2 = 'Semifinals',
RD3 = 'Final',
})
end
p['8TeamBracket-Tennis5'] = p.EightTeamBracketTennis5
function p.SixteenTeamBracket(frame)
return p._teamBracket(frame, '16TeamBracket', {
subgroup1 = 'RD1-group1',
subgroup2 = 'RD1-group2',
subgroup3 = 'RD1-group3',
subgroup4 = 'RD1-group4',
group1 = 'RD2-group1',
group2 = 'RD2-group2',
group3 = 'RD3-group1',
['RD1-seed01'] = 'RD1-seed1',
['RD1-seed02'] = 'RD1-seed2',
['RD1-seed03'] = 'RD1-seed3',
['RD1-seed04'] = 'RD1-seed4',
['RD1-seed05'] = 'RD1-seed5',
['RD1-seed06'] = 'RD1-seed6',
['RD1-seed07'] = 'RD1-seed7',
['RD1-seed08'] = 'RD1-seed8',
['RD1-seed09'] = 'RD1-seed9',
}, {
['RD1-seed1'] = 1,
['RD1-seed2'] = 16,
['RD1-seed3'] = 8,
['RD1-seed4'] = 9,
['RD1-seed5'] = 5,
['RD1-seed6'] = 12,
['RD1-seed7'] = 4,
['RD1-seed8'] = 13,
['RD1-seed9'] = 6,
['RD1-seed10'] = 11,
['RD1-seed11'] = 3,
['RD1-seed12'] = 14,
['RD1-seed13'] = 7,
['RD1-seed14'] = 10,
['RD1-seed15'] = 2,
['RD1-seed16'] = 15,
})
end
p['16TeamBracket'] = p.SixteenTeamBracket
function p.SixteenTeamBracketByes(frame)
return p._teamBracket(frame, '16TeamBracket-Byes', {
group1 = "RD1-group1",
group2 = "RD2-group2",
}, {
seeds = 'yes',
byes = 1,
RD1 = 'First round',
RD2 = 'Second round',
RD3 = 'Semifinals',
RD4 = 'Final',
['team-width'] = '11em',
['score-width'] = '2em',
['RD1-group1'] = '',
['RD2-group2'] = '',
})
end
p['4RoundBracket-Byes'] = p.SixteenTeamBracketByes
p['16TeamBracket-Byes'] = p.SixteenTeamBracketByes
function p.SixteenTeamBracketTennis3(frame)
return p._teamBracket(frame, '16TeamBracket-Tennis3', {}, {
['team-width'] = 140,
['score-width'] = 25,
RD1 = 'First round',
RD2 = 'Quarterfinals',
RD3 = 'Semifinals',
RD4 = 'Final',
})
end
p['16TeamBracket-Tennis3'] = p.SixteenTeamBracketTennis3
function p.SixteenTeamBracketCompactTennis3(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis3', {}, {
RD1 = '1st round',
RD2 = '2nd round',
})
end
p['16TeamBracket-Compact-Tennis3'] = p.SixteenTeamBracketCompactTennis3
function p.SixteenTeamBracketCompactTennis3Byes(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis3-Byes', {}, {
byes = 2,
['seed-width'] = 25,
['team-width'] = 150,
RD1 = '1st round',
RD2 = '2nd round',
RD3 = 'Semifinals',
RD4 = 'Final',
})
end
p['16TeamBracket-Compact-Tennis3-Byes'] = p.SixteenTeamBracketCompactTennis3Byes
p['4RoundBracket-Compact-Tennis3-Byes'] = p.SixteenTeamBracketCompactTennis3Byes
function p.SixteenTeamBracketTennis5(frame)
return p._teamBracket(frame, '16TeamBracket-Tennis5', {}, {
RD1 = 'First round',
RD2 = 'Quarterfinals',
RD3 = 'Semifinals',
RD4 = 'Final',
['seed-width'] = 25,
['team-width'] = 150,
['score-width'] = 12,
})
end
p['16TeamBracket-Tennis5'] = p.SixteenTeamBracketTennis5
function p.SixteenTeamBracketCompactTennis5(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis5', {}, {
RD1 = 'First round',
RD2 = 'Second round',
RD3 = 'Third round',
RD4 = 'Fourth round',
})
end
p['16TeamBracket-Compact-Tennis5'] = p.SixteenTeamBracketCompactTennis5
function p.SixteenTeamBracketCompactTennis5Byes(frame)
return p._teamBracket(frame, '16TeamBracket-Compact-Tennis5-Byes', {}, {
byes = 1,
RD1 = 'First round',
RD2 = 'Second round',
RD3 = 'Semifinals',
RD4 = 'Final',
})
end
p['16TeamBracket-Compact-Tennis5-Byes'] = p.SixteenTeamBracketCompactTennis5Byes
p['4RoundBracket-Compact-Tennis5-Byes'] = p.SixteenTeamBracketCompactTennis5Byes
return p