Refactor playoff match generation logic to only generate the minimum number of matches needed in each iteration.

This commit is contained in:
Patrick Fairbank
2022-07-31 17:21:33 -07:00
parent 38518b0dd4
commit 1ab1b42d49
4 changed files with 160 additions and 328 deletions

View File

@@ -92,7 +92,7 @@ func TestAllianceSelection(t *testing.T) {
}
matches, err := web.arena.Database.GetMatchesByType("elimination")
assert.Nil(t, err)
assert.Equal(t, 6, len(matches))
assert.Equal(t, 2, len(matches))
}
func TestAllianceSelectionErrors(t *testing.T) {

View File

@@ -436,12 +436,14 @@ func (web *Web) commitMatchScore(match *model.Match, matchResult *model.MatchRes
}
if match.ShouldUpdateEliminationMatches() {
if err = tournament.UpdateAlliance(web.arena.Database, [3]int{match.Red1, match.Red2, match.Red3},
match.ElimRedAlliance); err != nil {
if err = tournament.UpdateAlliance(
web.arena.Database, [3]int{match.Red1, match.Red2, match.Red3}, match.ElimRedAlliance,
); err != nil {
return err
}
if err = tournament.UpdateAlliance(web.arena.Database, [3]int{match.Blue1, match.Blue2, match.Blue3},
match.ElimBlueAlliance); err != nil {
if err = tournament.UpdateAlliance(
web.arena.Database, [3]int{match.Blue1, match.Blue2, match.Blue3}, match.ElimBlueAlliance,
); err != nil {
return err
}