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