Refactor to merge Match.Status and Match.Winner fields into one.

This commit is contained in:
Patrick Fairbank
2020-03-29 00:04:15 -07:00
parent 14c9815980
commit df9c5dfbd9
20 changed files with 134 additions and 125 deletions

View File

@@ -33,12 +33,20 @@ type Match struct {
Blue2IsSurrogate bool
Blue3 int
Blue3IsSurrogate bool
Status string
StartedAt time.Time
ScoreCommittedAt time.Time
Winner string
Status MatchStatus
}
type MatchStatus string
const (
RedWonMatch MatchStatus = "R"
BlueWonMatch MatchStatus = "B"
TieMatch MatchStatus = "T"
MatchNotPlayed MatchStatus = ""
)
var ElimRoundNames = map[int]string{1: "F", 2: "SF", 4: "QF", 8: "EF"}
func (database *Database) CreateMatch(match *Match) error {
@@ -96,6 +104,10 @@ func (database *Database) GetMatchesByType(matchType string) ([]Match, error) {
return matches, err
}
func (match *Match) IsComplete() bool {
return match.Status != MatchNotPlayed
}
func (match *Match) CapitalizedType() string {
if match.Type == "" {
return ""