Set display name when pushing double-elimination matches to TBA.

This commit is contained in:
Patrick Fairbank
2022-09-11 12:59:07 -07:00
parent d7c3b9df6c
commit 3d566f4866

View File

@@ -15,6 +15,7 @@ import (
"io/ioutil"
"net/http"
"strconv"
"strings"
)
const (
@@ -38,6 +39,7 @@ type TbaMatch struct {
Alliances map[string]*TbaAlliance `json:"alliances"`
TimeString string `json:"time_string"`
TimeUtc string `json:"time_utc"`
DisplayName string `json:"display_name"`
}
type TbaAlliance struct {
@@ -331,8 +333,14 @@ func (client *TbaClient) PublishMatches(database *model.Database) error {
alliances["blue"] = createTbaAlliance([3]int{match.Blue1, match.Blue2, match.Blue3},
[3]bool{match.Blue1IsSurrogate, match.Blue2IsSurrogate, match.Blue3IsSurrogate}, blueScore)
tbaMatches[i] = TbaMatch{"qm", 0, matchNumber, alliances, match.Time.Local().Format("3:04 PM"),
match.Time.UTC().Format("2006-01-02T15:04:05")}
tbaMatches[i] = TbaMatch{
CompLevel: "qm",
SetNumber: 0,
MatchNumber: matchNumber,
Alliances: alliances,
TimeString: match.Time.Local().Format("3:04 PM"),
TimeUtc: match.Time.UTC().Format("2006-01-02T15:04:05"),
}
if match.Type == "elimination" {
setElimMatchKey(&tbaMatches[i], &match, eventSettings.ElimType)
}
@@ -553,5 +561,8 @@ func setElimMatchKey(tbaMatch *TbaMatch, match *model.Match, elimType string) {
tbaMatch.SetNumber = tbaKey.setNumber
}
tbaMatch.MatchNumber = match.ElimInstance
if !strings.HasPrefix(match.DisplayName, "F") {
tbaMatch.DisplayName = "Match " + match.DisplayName
}
}
}