|
|
| Line 5: |
Line 5: |
| local notblank = function(v) return (v or '') ~= '' end | | local notblank = function(v) return (v or '') ~= '' end |
| local rmzero = function(k) return mw.ustring.gsub(k, "0(%d)$", "%1") end | | local rmzero = function(k) return mw.ustring.gsub(k, "0(%d)$", "%1") end |
| | |
|
| |
|
| p['_Bracket'] = function (frame, template, subs, args) | | p['_Bracket'] = function (frame, template, subs, args) |
| -- figure out parameters from template name | | -- figure out parameters from template name |
| local consols = string.find(template, "-Consols") | | local consols = string.find(template, "-Consols") |
| local pagePlayoff = string.find(template, "-PagePlayoff")
| |
| local stepladder = string.find(template, "-Stepladder")
| |
| if (consols or pagePlayoff or stepladder) then args.build = true end
| |
|
| |
| args.rounds = args.rounds or mw.ustring.match(template, "^(%d*)Round") | | args.rounds = args.rounds or mw.ustring.match(template, "^(%d*)Round") |
| if not args.rounds then | | if not args.rounds then |
| Line 18: |
Line 15: |
| if teams and teams > 1 then -- log2(teams) is the number of rounds | | if teams and teams > 1 then -- log2(teams) is the number of rounds |
| args.rounds = math.ceil( math.log(teams)/math.log(2) ) | | args.rounds = math.ceil( math.log(teams)/math.log(2) ) |
| if consols then | | if consols then args.rounds = (args.rounds * 2) - 1 end |
| args.rounds = (args.rounds * 2) - 1
| |
| elseif (pagePlayoff or stepladder) then
| |
| args.rounds = args.rounds + 1
| |
| end
| |
| end | | end |
| end | | end |
|
| |
| local tennis = mw.ustring.match(template, "-Tennis(%d*)") | | local tennis = mw.ustring.match(template, "-Tennis(%d*)") |
| local squash = mw.ustring.match(template, "-Squash(%d*)") | | local squash = mw.ustring.match(template, "-Squash(%d*)") |
| Line 33: |
Line 25: |
| args.nowrap = args.nowrap or 'yes' | | args.nowrap = args.nowrap or 'yes' |
| end | | end |
|
| |
| if string.find(template, "-Compact") then | | if string.find(template, "-Compact") then |
| args.compact = args.compact or 'yes' | | args.compact = args.compact or 'yes' |
| end | | end |
|
| |
| -- remove leading zeros from defaults | | -- remove leading zeros from defaults |
| for k, v in pairs(args) do | | for k, v in pairs(args) do |
| Line 45: |
Line 35: |
| end | | end |
| end | | end |
|
| |
| -- overwrite defaults with frame args and alternative args | | -- overwrite defaults with frame args and alternative args |
| for k, v in pairs(frame.args) do | | for k, v in pairs(frame.args) do |
| Line 58: |
Line 47: |
| args[k] = v | | args[k] = v |
| end | | end |
|
| |
| -- process parameters for '-Info' templates | | -- process parameters for '-Info' templates |
| local info = string.find(template, "-Info") | | local info = string.find(template, "-Info") |
| Line 68: |
Line 56: |
| end | | end |
| end | | end |
| args.build = true
| |
| end | | end |
|
| |
| -- return template | | -- return template |
| local newFrame = frame:newChild{title = ("Template:" .. template), args = args} | | local newFrame = frame:newChild{title = ("Template:" .. template), args = args} |
| if args.build then | | if info or consols then return require('Module:Build bracket').main(newFrame) end |
| return require('Module:Build bracket').main(newFrame) ..
| |
| require('Module:Team bracket tracking').tracking(newFrame)
| |
| end
| |
| return require('Module:Team bracket').main(newFrame) | | return require('Module:Team bracket').main(newFrame) |
| end | | end |
| Line 95: |
Line 78: |
| ['RD1b'] = 'Third place', | | ['RD1b'] = 'Third place', |
| ['RD1b-hide'] = 'y' | | ['RD1b-hide'] = 'y' |
| })
| |
| end
| |
|
| |
| p['3TeamBracket-PagePlayoff'] = function (frame)
| |
| return p._Bracket(frame, '3TeamBracket-PagePlayoff', {
| |
| }, {
| |
| ['col1-matches'] = '3',
| |
| ['col2-matches'] = '5',
| |
| ['col3-matches'] = '3',
| |
|
| |
| ['col1-col2-paths'] = '3-3,3-5:red',
| |
| ['col2-col3-paths'] = '(3,5)-3',
| |
|
| |
| ['RD1'] = '[[Page playoff]]',
| |
| ['RD2'] = 'Semifinal',
| |
| }) | | }) |
| end | | end |
| Line 145: |
Line 113: |
|
| |
|
| ['RD2-team1'] = " ", | | ['RD2-team1'] = " ", |
| })
| |
| end
| |
|
| |
| p['4TeamBracket-PagePlayoff'] = function (frame)
| |
| local RD1b = notblank(frame.args.RD1b)
| |
| return p._Bracket(frame, '4TeamBracket-PagePlayoff', {
| |
| }, {
| |
| ['RD3b-hide'] = 'y',
| |
|
| |
| ['col1-headers'] = '1,' .. (RD1b and '6' or ''),
| |
| ['col2-headers'] = '1',
| |
| ['col3-headers'] = '1,6',
| |
|
| |
| ['col1-matches'] = '3,' .. (RD1b and '8' or '7'),
| |
| ['col2-matches'] = '5',
| |
| ['col3-matches'] = '3,8',
| |
|
| |
| ['col1-col2-paths'] = string.format('3-3, 3-5:red,%s-5', (RD1b and 8 or 7)),
| |
| ['col2-col3-paths'] = '(3,5)-3',
| |
|
| |
| ['RD1'] = 'Semifinals',
| |
| ['RD2'] = 'Preliminary final',
| |
| ['RD3b'] = 'Third place',
| |
| })
| |
| end
| |
|
| |
| p['4TeamBracket-Stepladder'] = function (frame)
| |
| return p._Bracket(frame, '4TeamBracket-Stepladder', {
| |
| }, {
| |
| ['col1-matches'] = '5',
| |
| ['col2-matches'] = '4',
| |
| ['col3-matches'] = '3',
| |
|
| |
| ['col1-col2-paths'] = '5-4',
| |
| ['col2-col3-paths'] = '4-3',
| |
|
| |
| ['RD1'] = 'First round',
| |
| ['RD2'] = 'Second round',
| |
|
| |
| ['RD1-seed1'] = '3',
| |
| ['RD1-seed2'] = '4',
| |
| ['RD2-seed1'] = '2',
| |
| ['RD3-seed1'] = '1',
| |
| }) | | }) |
| end | | end |
| Line 307: |
Line 232: |
| ['RD5-altname'] = "final", | | ['RD5-altname'] = "final", |
| ['text-altname'] = "details", | | ['text-altname'] = "details", |
| })
| |
| end
| |
|
| |
| p['5TeamBracket-Stepladder'] = function (frame)
| |
| return p._Bracket(frame, '5TeamBracket-Stepladder', {
| |
| }, {
| |
| ['col1-matches'] = '6',
| |
| ['col2-matches'] = '5',
| |
| ['col3-matches'] = '4',
| |
| ['col4-matches'] = '3',
| |
|
| |
| ['col1-col2-paths'] = '6-5',
| |
| ['col2-col3-paths'] = '5-4',
| |
| ['col3-col4-paths'] = '4-3',
| |
|
| |
| ['RD1'] = 'First round',
| |
| ['RD2'] = 'Second round',
| |
| ['RD3'] = 'Semifinal',
| |
|
| |
| ['RD1-seed1'] = '4',
| |
| ['RD1-seed2'] = '5',
| |
| ['RD2-seed1'] = '3',
| |
| ['RD3-seed1'] = '2',
| |
| ['RD4-seed1'] = '1',
| |
| }) | | }) |
| end | | end |
| Line 356: |
Line 257: |
| ['RD2-seed3'] = stepdown and '' or 2, | | ['RD2-seed3'] = stepdown and '' or 2, |
| ['RD2-seed4'] = stepdown and 2 or '', | | ['RD2-seed4'] = stepdown and 2 or '', |
| })
| |
| end
| |
|
| |
| p['6TeamBracket-PagePlayoff'] = function (frame)
| |
| return p._Bracket(frame, '6TeamBracket-PagePlayoff', {
| |
| }, {
| |
| ['col1-matches'] = '3,7',
| |
| ['col2-matches'] = '5',
| |
| ['col3-matches'] = '3,7',
| |
| ['col4-matches'] = '5',
| |
|
| |
| ['col1-col2-paths'] = '3-5,7-5:red,7-7',
| |
| ['col2-col3-paths'] = '7-7, 5-3',
| |
| ['col3-col4-paths'] = '(3,7)-5',
| |
|
| |
| ['RD1'] = 'Seeding/Play-in qualifier',
| |
| ['RD2'] = 'Play-in game',
| |
|
| |
| ['RD1-seed1'] = '5',
| |
| ['RD1-seed2'] = '6',
| |
| ['RD1-seed3'] = '3',
| |
| ['RD1-seed4'] = '4',
| |
| ['RD3-seed1'] = '1',
| |
| ['RD3-seed3'] = '2',
| |
| }) | | }) |
| end | | end |
| Line 452: |
Line 329: |
| ['text-altname'] = "details", | | ['text-altname'] = "details", |
|
| |
|
| })
| |
| end
| |
|
| |
| p['7TeamBracket-StepladderToSF'] = function (frame)
| |
| local shift1, shift2, shift3, shift4 = "", "", "", ""
| |
| local matches2 = "4,8"
| |
| local paths12, paths23 = "5-4", "4-3, 8-7"
| |
| local RD3b = (
| |
| notblank(frame.args.RD3b) or
| |
| notblank(frame.args['RD3b-team1']) or
| |
| notblank(frame.args['RD3b-team5'])
| |
| )
| |
|
| |
| if tonumber(frame.args.style) == 2 then
| |
| shift1, shift2, shift3, shift4 = "1", "-1", "1", "1"
| |
| paths12 = "5-8"
| |
| elseif tonumber(frame.args.style) == 3 then
| |
| shift1, shift2, shift3, shift4 = "-2", "0", "2", "2"
| |
| elseif tonumber(frame.args.style) == 4 then
| |
| shift1, shift2, shift3, shift4 = "5", "1", "1", "1"
| |
| matches2 = "2,8"
| |
| paths12, paths23 = "5-8", "2-3, 8-7"
| |
| elseif tonumber(frame.args.style) == 5 then
| |
| shift1, shift2, shift3, shift4 = "-1", "-1", "1", "1"
| |
| matches2 = "4,10"
| |
| paths23 = "4-3, 10-7"
| |
| elseif tonumber(frame.args.style) == 6 then
| |
| shift1, shift2, shift3, shift4 = "-2", "0", "2", "2"
| |
| matches2 = "4,10"
| |
| paths23 = "4-3, 10-7"
| |
| end
| |
|
| |
| return p._Bracket(frame, '7TeamBracket-StepladderToSF', {
| |
| }, {
| |
| ['RD1-shift'] = shift1,
| |
| ['RD2-shift'] = shift2,
| |
| ['RD3-shift'] = shift3,
| |
| ['RD4-shift'] = shift4,
| |
|
| |
| ['RD3b-hide'] = 'y',
| |
| ['RD4b-hide'] = 'y',
| |
|
| |
| ['col1-headers'] = '1',
| |
| ['col2-headers'] = '1',
| |
| ['col3-headers'] = '1,10',
| |
| ['col4-headers'] = RD3b and '1,10' or '1,8',
| |
|
| |
| ['col1-matches'] = '5',
| |
| ['col2-matches'] = matches2,
| |
| ['col3-matches'] = '3,7,12',
| |
| ['col4-matches'] = RD3b and '5,12' or '5,10',
| |
|
| |
| ['col1-col2-paths'] = paths12,
| |
| ['col2-col3-paths'] = paths23,
| |
| ['col3-col4-paths'] = '(3,7)-5',
| |
|
| |
| ['RD1'] = 'Wild card',
| |
| ['RD3b'] = 'Fifth place',
| |
| ['RD4b'] = 'Third place',
| |
| }) | | }) |
| end | | end |
| Line 638: |
Line 456: |
| }) | | }) |
| end | | end |
|
| |
| p['8TeamBracket-PagePlayoff'] = function (frame)
| |
| local cross12 = notblank(frame.args['RD1-RD2-cross'])
| |
| local cross23 = notblank(frame.args['RD2-RD3-cross'])
| |
| local path12 = cross12 and {13, 5} or {5, 13}
| |
| local path23 = cross23 and {13, 5} or {5, 13}
| |
| return p._Bracket(frame, '8TeamBracket-PagePlayoff', {
| |
| }, {
| |
| ['col-spacing'] = (cross12 or cross23) and '12' or '',
| |
| ['shift'] = notblank(frame.args['RD1-text1']) and '1' or '',
| |
|
| |
| ['col1-matches'] = '3,7,11,15',
| |
| ['col2-matches'] = '5,13',
| |
| ['col3-matches'] = '7,11',
| |
| ['col4-matches'] = '9',
| |
|
| |
| ['col1-col2-paths'] = string.format('7-%s,11-%s,3-3,3-5:#FF3333,15-15,15-13:#FF3333',path12[1], path12[2]),
| |
| ['col2-col3-paths'] = string.format('(3,%s)-7, (%s,15)-11', path23[1], path23[2]),
| |
| ['col3-col4-paths'] = '(7,11)-9',
| |
| ['col1-col2-cross'] = cross12 and '9' or '',
| |
| ['col2-col3-cross'] = cross23 and '9' or '',
| |
|
| |
| ['RD1'] = 'Qualifying and elimination finals',
| |
| ['RD2'] = 'Semi-finals',
| |
| ['RD3'] = 'Preliminary finals',
| |
| ['RD4'] = 'Grand final',
| |
|
| |
| ['RD1-seed1'] = '1',
| |
| ['RD1-seed2'] = '4',
| |
| ['RD1-seed3'] = '5',
| |
| ['RD1-seed4'] = '8',
| |
| ['RD1-seed5'] = '6',
| |
| ['RD1-seed6'] = '7',
| |
| ['RD1-seed7'] = '2',
| |
| ['RD1-seed8'] = '3',
| |
| })
| |
| end
| |
|
| |
| p['8TeamBracket-Stepladder'] = function (frame)
| |
| return p._Bracket(frame, '8TeamBracket-Stepladder', {
| |
| }, {
| |
| ['RD4b-hide'] = 'y',
| |
| ['RD4b'] = 'Third place',
| |
|
| |
| ['col1-headers'] = '1',
| |
| ['col2-headers'] = '1',
| |
| ['col3-headers'] = '1',
| |
| ['col4-headers'] = '1,8',
| |
|
| |
| ['col1-matches'] = '5,9',
| |
| ['col2-matches'] = '4,8',
| |
| ['col3-matches'] = '3,7',
| |
| ['col4-matches'] = '5,10',
| |
|
| |
| ['col1-col2-paths'] = '5-4, 9-8',
| |
| ['col2-col3-paths'] = '4-3, 8-7',
| |
| ['col3-col4-paths'] = '(3,7)-5',
| |
|
| |
| ['RD1'] = 'First round',
| |
| ['RD2'] = 'Second round',
| |
| ['RD3'] = 'Semifinals',
| |
| ['RD4'] = 'Final',
| |
|
| |
| ['RD1-seed1'] = '5',
| |
| ['RD1-seed2'] = '8',
| |
| ['RD1-seed3'] = '6',
| |
| ['RD1-seed4'] = '7',
| |
| ['RD2-seed1'] = '4',
| |
| ['RD2-seed3'] = '3',
| |
| ['RD3-seed1'] = '1',
| |
| ['RD3-seed3'] = '2',
| |
| })
| |
| end
| |
| p['8TeamBracket-Double-Stepladder'] = p['8TeamBracket-Stepladder']
| |
|
| |
|
| p['8TeamBracket-Tennis3'] = function (frame) | | p['8TeamBracket-Tennis3'] = function (frame) |
| Line 960: |
Line 704: |
| ['col3-col4-paths'] = "6-5,14-13", | | ['col3-col4-paths'] = "6-5,14-13", |
| ['col4-col5-paths'] = "(5,13)-9", | | ['col4-col5-paths'] = "(5,13)-9", |
| })
| |
| end
| |
|
| |
| p['14TeamBracket-Stepladder'] = function (frame)
| |
| return p._Bracket(frame, '14TeamBracket-Stepladder', {
| |
| }, {
| |
| ['rounds'] = '7',
| |
|
| |
| ['col1-matches'] = '8,15',
| |
| ['col2-matches'] = '7,14',
| |
| ['col3-matches'] = '6,13',
| |
| ['col4-matches'] = '5,12',
| |
| ['col5-matches'] = '4,11',
| |
| ['col6-matches'] = '3,10',
| |
| ['col7-matches'] = '7',
| |
|
| |
| ['col1-col2-paths'] = '8-7,15-14',
| |
| ['col2-col3-paths'] = '7-6,14-13',
| |
| ['col3-col4-paths'] = '6-5,13-12',
| |
| ['col4-col5-paths'] = '5-4,12-11',
| |
| ['col5-col6-paths'] = '4-3,11-10',
| |
| ['col6-col7-paths'] = '(3,10)-7',
| |
|
| |
| ['RD1-seed01'] = '12',
| |
| ['RD1-seed02'] = '13',
| |
| ['RD1-seed03'] = '11',
| |
| ['RD1-seed04'] = '14',
| |
|
| |
| ['RD2-seed01'] = '9',
| |
| ['RD2-seed03'] = '10',
| |
|
| |
| ['RD3-seed01'] = '8',
| |
| ['RD3-seed03'] = '7',
| |
|
| |
| ['RD4-seed01'] = '5',
| |
| ['RD4-seed03'] = '6',
| |
|
| |
| ['RD5-seed01'] = '4',
| |
| ['RD5-seed03'] = '3',
| |
|
| |
| ['RD6-seed01'] = '1',
| |
| ['RD6-seed03'] = '2',
| |
| }) | | }) |
| end | | end |
| Line 1,265: |
Line 967: |
| }) | | }) |
| end | | end |
|
| |
| p['18TeamBracket'] = function (frame)
| |
| return p._Bracket(frame, '18TeamBracket', {
| |
| }, {
| |
| compact = 'yes',
| |
| ['RD1-omit'] = '1/2/5/6/7/8/9/10/11/12/13/14/15/16/17/18/21/22/23/24/25/26/27/28/29/30/31/32',
| |
| RD1 = 'First round',
| |
| RD2 = 'Second round',
| |
| RD3 = 'Quarterfinals',
| |
| RD4 = 'Semifinals',
| |
| RD5 = 'Finals',
| |
|
| |
| ['RD1-seed1'] = 16,
| |
| ['RD1-seed2'] = 17,
| |
| ['RD1-seed3'] = 15,
| |
| ['RD1-seed4'] = 18,
| |
|
| |
| ['RD2-seed01'] = 1,
| |
| ['RD2-seed02'] = '',
| |
| ['RD2-seed03'] = 8,
| |
| ['RD2-seed04'] = 9,
| |
| ['RD2-seed05'] = 4,
| |
| ['RD2-seed06'] = 13,
| |
| ['RD2-seed07'] = 5,
| |
| ['RD2-seed08'] = 12,
| |
| ['RD2-seed09'] = 2,
| |
| ['RD2-seed10'] = '',
| |
| ['RD2-seed11'] = 7,
| |
| ['RD2-seed12'] = 10,
| |
| ['RD2-seed13'] = 3,
| |
| ['RD2-seed14'] = 14,
| |
| ['RD2-seed15'] = 6,
| |
| ['RD2-seed16'] = 11,
| |
| })
| |
| end
| |
|
| |
| p['24TeamBracket'] = function (frame)
| |
| local groups = {"RD1-group1","RD1-group2","RD1-group3","RD1-group4","RD1-group5","RD1-group6","RD1-group7","RD1-group8","RD2-group1","RD2-group2","RD2-group3","RD2-group4","RD3-group1","RD3-group2","RD4-group1"}
| |
| local compact = "yes"
| |
| for _, v in ipairs(groups) do
| |
| if notblank(frame[v]) then
| |
| compact = ""
| |
| break
| |
| end
| |
| end
| |
| return p._Bracket(frame, '24TeamBracket', {
| |
| }, {
| |
| ['RD1=omit'] = '1/2/5/6/9/10/13/14/17/18/21/22/25/26/29/30',
| |
| byes = '1',
| |
| compact = compact,
| |
| RD1 = 'First Round',
| |
| RD2 = 'Round of 16',
| |
| ['RD1-team1'] = ' ',
| |
| ['RD1-team2'] = ' ',
| |
| ['RD1-team3'] = ' ',
| |
| ['RD1-team4'] = ' ',
| |
| ['RD1-team5'] = ' ',
| |
| ['RD1-team6'] = ' ',
| |
| ['RD1-team7'] = ' ',
| |
| ['RD1-team8'] = ' ',
| |
| ['RD1-team9'] = ' ',
| |
| ['RD1-team10'] = ' ',
| |
| ['RD1-team11'] = ' ',
| |
| ['RD1-team12'] = ' ',
| |
| ['RD1-team13'] = ' ',
| |
| ['RD1-team14'] = ' ',
| |
| ['RD1-team15'] = ' ',
| |
| ['RD1-team16'] = ' ',
| |
| })
| |
| end
| |
| p['24TeamBracket-Byes2'] = p['24TeamBracket']
| |
| p['24TeamBracket-NoSeeds'] = p['24TeamBracket']
| |
|
| |
| p['24TeamBracket-Info'] = function (frame)
| |
| local above = notblank(frame.args.above)
| |
| return p._Bracket(frame, '24TeamBracket-Info', {
| |
| }, {
| |
| shift = above and '1' or '',
| |
| ['col1-matches'] = above and '2,5,8,11,14,17,20,23' or '4,7,10,13,16,19,22,25',
| |
| ['col2-matches'] = '3,6,9,12,15,18,21,24',
| |
| ['col3-matches'] = '4.5,10.5,16.5,22.5',
| |
| ['col4-matches'] = '7.5,19.5',
| |
| ['col5-matches'] = '13.5',
| |
|
| |
| ['col1-col2-paths'] = above and '2-3,5-6,8-9,11-12,14-15,17-18,20-21,23-24' or '4-3,7-6,10-9,13-12,16-15,19-18,22-21,25-24',
| |
| ['col2-col3-paths'] = '(3,6)-4.5,(9,12)-10.5,(15,18)-16.5,(21,24)-22.5',
| |
| ['col3-col4-paths'] = '(4.5,10.5)-7.5,(16.5,22.5)-19.5',
| |
| ['col4-col5-paths'] = '(7.5,19.5)-13.5',
| |
|
| |
| ['RD1'] = 'First round',
| |
| ['RD2'] = 'Second round',
| |
| })
| |
| end
| |
| p['24TeamBracket-Byes'] = p['24TeamBracket-Info']
| |
|
| |
|
| p['32TeamBracket'] = function (frame) | | p['32TeamBracket'] = function (frame) |