mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Centralize some match-type-dependent logic.
This commit is contained in:
@@ -104,6 +104,15 @@ func (match *Match) CapitalizedType() string {
|
||||
return strings.ToUpper(match.Type[0:1]) + match.Type[1:]
|
||||
}
|
||||
|
||||
func (match *Match) TypePrefix() string {
|
||||
if match.Type == "practice" {
|
||||
return "P"
|
||||
} else if match.Type == "qualification" {
|
||||
return "Q"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (match *Match) TbaCode() string {
|
||||
if match.Type == "qualification" {
|
||||
return fmt.Sprintf("qm%s", match.DisplayName)
|
||||
@@ -113,3 +122,23 @@ func (match *Match) TbaCode() string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Returns true if the match is of a type that allows substitution of teams.
|
||||
func (match *Match) ShouldAllowSubstitution() bool {
|
||||
return match.Type != "qualification"
|
||||
}
|
||||
|
||||
// Returns true if the red and yellow cards should be updated as a result of the match.
|
||||
func (match *Match) ShouldUpdateCards() bool {
|
||||
return match.Type == "qualification" || match.Type == "elimination"
|
||||
}
|
||||
|
||||
// Returns true if the rankings should be updated as a result of the match.
|
||||
func (match *Match) ShouldUpdateRankings() bool {
|
||||
return match.Type == "qualification"
|
||||
}
|
||||
|
||||
// Returns true if the elimination match set should be updated as a result of the match.
|
||||
func (match *Match) ShouldUpdateEliminationMatches() bool {
|
||||
return match.Type == "elimination"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user