From 02cb9e4e415ece8aa016cc40f936d22e4c20aa75 Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Sun, 5 Feb 2023 13:29:23 -0800 Subject: [PATCH] Update double-elimination bracket to match 2023 rules. --- bracket/double_elimination.go | 22 +++++++++++----------- bracket/double_elimination_test.go | 22 +++++++++++----------- bracket/matchup_test.go | 6 +++--- templates/bracket.svg | 24 ++++++++++++------------ 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/bracket/double_elimination.go b/bracket/double_elimination.go index d4fe159..25f827b 100644 --- a/bracket/double_elimination.go +++ b/bracket/double_elimination.go @@ -34,15 +34,15 @@ var doubleEliminationBracketMatchupTemplates = []matchupTemplate{ matchupKey: newMatchupKey(1, 3), displayName: "3", NumWinsToAdvance: 1, - redAllianceSource: allianceSource{allianceId: 3}, - blueAllianceSource: allianceSource{allianceId: 6}, + redAllianceSource: allianceSource{allianceId: 2}, + blueAllianceSource: allianceSource{allianceId: 7}, }, { matchupKey: newMatchupKey(1, 4), displayName: "4", NumWinsToAdvance: 1, - redAllianceSource: allianceSource{allianceId: 2}, - blueAllianceSource: allianceSource{allianceId: 7}, + redAllianceSource: allianceSource{allianceId: 3}, + blueAllianceSource: allianceSource{allianceId: 6}, }, { matchupKey: newMatchupKey(2, 1), @@ -90,28 +90,28 @@ var doubleEliminationBracketMatchupTemplates = []matchupTemplate{ matchupKey: newMatchupKey(4, 1), displayName: "11", NumWinsToAdvance: 1, - redAllianceSource: newWinnerAllianceSource(3, 2), - blueAllianceSource: newWinnerAllianceSource(3, 1), + redAllianceSource: newWinnerAllianceSource(2, 3), + blueAllianceSource: newWinnerAllianceSource(2, 4), }, { matchupKey: newMatchupKey(4, 2), displayName: "12", NumWinsToAdvance: 1, - redAllianceSource: newWinnerAllianceSource(2, 3), - blueAllianceSource: newWinnerAllianceSource(2, 4), + redAllianceSource: newWinnerAllianceSource(3, 2), + blueAllianceSource: newWinnerAllianceSource(3, 1), }, { matchupKey: newMatchupKey(5, 1), displayName: "13", NumWinsToAdvance: 1, - redAllianceSource: newLoserAllianceSource(4, 2), - blueAllianceSource: newWinnerAllianceSource(4, 1), + redAllianceSource: newLoserAllianceSource(4, 1), + blueAllianceSource: newWinnerAllianceSource(4, 2), }, { matchupKey: newMatchupKey(6, 1), displayName: "F", NumWinsToAdvance: 2, - redAllianceSource: newWinnerAllianceSource(4, 2), + redAllianceSource: newWinnerAllianceSource(4, 1), blueAllianceSource: newWinnerAllianceSource(5, 1), }, } diff --git a/bracket/double_elimination_test.go b/bracket/double_elimination_test.go index d9ca4df..039c5bb 100644 --- a/bracket/double_elimination_test.go +++ b/bracket/double_elimination_test.go @@ -22,8 +22,8 @@ func TestDoubleEliminationInitial(t *testing.T) { if assert.Equal(t, 4, len(matches)) { assertMatch(t, matches[0], "1", 1, 8) assertMatch(t, matches[1], "2", 4, 5) - assertMatch(t, matches[2], "3", 3, 6) - assertMatch(t, matches[3], "4", 2, 7) + assertMatch(t, matches[2], "3", 2, 7) + assertMatch(t, matches[3], "4", 3, 6) } } @@ -65,21 +65,21 @@ func TestDoubleEliminationProgression(t *testing.T) { assertMatch(t, matches[5], "7", 8, 4) } - scoreMatch(database, "3", game.RedWonMatch) + scoreMatch(database, "3", game.BlueWonMatch) assert.Nil(t, bracket.Update(database, &dummyStartTime)) matches, err = database.GetMatchesByType("elimination") assert.Nil(t, err) assert.Equal(t, 6, len(matches)) - scoreMatch(database, "4", game.BlueWonMatch) + scoreMatch(database, "4", game.RedWonMatch) assert.Nil(t, bracket.Update(database, &dummyStartTime)) matches, err = database.GetMatchesByType("elimination") assert.Nil(t, err) if assert.Equal(t, 8, len(matches)) { assertMatch(t, matches[4], "5", 1, 5) - assertMatch(t, matches[5], "6", 6, 2) + assertMatch(t, matches[5], "6", 2, 6) assertMatch(t, matches[6], "7", 8, 4) - assertMatch(t, matches[7], "8", 3, 7) + assertMatch(t, matches[7], "8", 7, 3) } scoreMatch(database, "5", game.BlueWonMatch) @@ -88,7 +88,7 @@ func TestDoubleEliminationProgression(t *testing.T) { assert.Nil(t, err) assert.Equal(t, 8, len(matches)) - scoreMatch(database, "6", game.BlueWonMatch) + scoreMatch(database, "6", game.RedWonMatch) assert.Nil(t, bracket.Update(database, &dummyStartTime)) matches, err = database.GetMatchesByType("elimination") assert.Nil(t, err) @@ -102,13 +102,13 @@ func TestDoubleEliminationProgression(t *testing.T) { assertMatch(t, matches[8], "9", 8, 2) } - scoreMatch(database, "8", game.RedWonMatch) + scoreMatch(database, "8", game.BlueWonMatch) assert.Nil(t, bracket.Update(database, &dummyStartTime)) matches, err = database.GetMatchesByType("elimination") assert.Nil(t, err) if assert.Equal(t, 11, len(matches)) { assertMatch(t, matches[9], "10", 7, 5) - assertMatch(t, matches[10], "12", 4, 3) + assertMatch(t, matches[10], "11", 4, 3) } scoreMatch(database, "9", game.RedWonMatch) @@ -122,8 +122,8 @@ func TestDoubleEliminationProgression(t *testing.T) { matches, err = database.GetMatchesByType("elimination") assert.Nil(t, err) if assert.Equal(t, 12, len(matches)) { - assertMatch(t, matches[10], "11", 7, 8) - assertMatch(t, matches[11], "12", 4, 3) + assertMatch(t, matches[10], "11", 4, 3) + assertMatch(t, matches[11], "12", 7, 8) } scoreMatch(database, "11", game.RedWonMatch) diff --git a/bracket/matchup_test.go b/bracket/matchup_test.go index 8cb1cfb..b324d1a 100644 --- a/bracket/matchup_test.go +++ b/bracket/matchup_test.go @@ -17,7 +17,7 @@ func TestMatchupDisplayNames(t *testing.T) { assert.Equal(t, "Finals", bracket.FinalsMatchup.LongDisplayName()) assert.Equal(t, "F-1", bracket.FinalsMatchup.matchDisplayName(1)) - assert.Equal(t, "W 12", bracket.FinalsMatchup.RedAllianceSourceDisplayName()) + assert.Equal(t, "W 11", bracket.FinalsMatchup.RedAllianceSourceDisplayName()) assert.Equal(t, "W 13", bracket.FinalsMatchup.BlueAllianceSourceDisplayName()) match13, err := bracket.GetMatchup(5, 1) @@ -25,8 +25,8 @@ func TestMatchupDisplayNames(t *testing.T) { assert.Equal(t, "Match 13", match13.LongDisplayName()) assert.Equal(t, "13", match13.matchDisplayName(1)) assert.Equal(t, "13-2", match13.matchDisplayName(2)) - assert.Equal(t, "L 12", match13.RedAllianceSourceDisplayName()) - assert.Equal(t, "W 11", match13.BlueAllianceSourceDisplayName()) + assert.Equal(t, "L 11", match13.RedAllianceSourceDisplayName()) + assert.Equal(t, "W 12", match13.BlueAllianceSourceDisplayName()) bracket, err = NewSingleEliminationBracket(8) assert.Nil(t, err) diff --git a/templates/bracket.svg b/templates/bracket.svg index 95346b9..b59eb54 100644 --- a/templates/bracket.svg +++ b/templates/bracket.svg @@ -211,8 +211,8 @@ .bracket_double #match_3_2 {transform: translate(709px, 504px);} .bracket_double #match_3_1 {transform: translate(709px, 694px);} - .bracket_double #match_4_2 {transform: translate(1006px, 301px);} - .bracket_double #match_4_1 {transform: translate(1006px, 599px);} + .bracket_double #match_4_1 {transform: translate(1006px, 301px);} + .bracket_double #match_4_2 {transform: translate(1006px, 599px);} .bracket_double #match_5_1 {transform: translate(1302px, 567px);} @@ -375,6 +375,16 @@ L + + + + W + W + W + L + + + W L @@ -386,16 +396,6 @@ - - - - - W - W - W - L - -