Implement bracket audience display for single-elimination.

This commit is contained in:
Patrick Fairbank
2022-08-20 17:25:17 -07:00
parent 5426d56de5
commit 996331d60c
5 changed files with 376 additions and 202 deletions

View File

@@ -266,15 +266,29 @@ func (web *Web) bracketSvgApiHandler(w http.ResponseWriter, r *http.Request) {
}
}
bracketType := "double"
numAlliances := web.arena.EventSettings.NumElimAlliances
if web.arena.EventSettings.ElimType == "single" {
if numAlliances > 8 {
bracketType = "16"
} else if numAlliances > 4 {
bracketType = "8"
} else if numAlliances > 2 {
bracketType = "4"
} else {
bracketType = "2"
}
}
template, err := web.parseFiles("templates/bracket.svg")
if err != nil {
handleWebErr(w, err)
return
}
data := struct {
*model.EventSettings
Matchups map[string]*allianceMatchup
}{web.arena.EventSettings, matchups}
BracketType string
Matchups map[string]*allianceMatchup
}{bracketType, matchups}
w.Header().Set("Content-Type", "image/svg+xml")
err = template.ExecuteTemplate(w, "bracket", data)
if err != nil {