2020-03-18 22:42:36 -07:00
|
|
|
// Copyright 2020 Team 254. All Rights Reserved.
|
2017-08-05 20:48:17 -07:00
|
|
|
// Author: pat@patfairbank.com (Patrick Fairbank)
|
|
|
|
|
//
|
|
|
|
|
// Model representing the instantaneous score of a match.
|
|
|
|
|
|
|
|
|
|
package game
|
|
|
|
|
|
|
|
|
|
type Score struct {
|
2020-04-14 19:38:14 -05:00
|
|
|
AutoPoints int
|
|
|
|
|
TeleopPoints int
|
|
|
|
|
EndgamePoints int
|
2017-08-05 20:48:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ScoreSummary struct {
|
2020-04-14 19:38:14 -05:00
|
|
|
AutoPoints int
|
|
|
|
|
TeleopPoints int
|
|
|
|
|
EndgamePoints int
|
|
|
|
|
Score int
|
2020-03-18 22:42:36 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-05 20:48:17 -07:00
|
|
|
// Calculates and returns the summary fields used for ranking and display.
|
2020-04-14 19:38:14 -05:00
|
|
|
func (score *Score) Summarize() *ScoreSummary {
|
2017-08-05 20:48:17 -07:00
|
|
|
summary := new(ScoreSummary)
|
|
|
|
|
|
2020-04-14 19:38:14 -05:00
|
|
|
summary.AutoPoints = score.AutoPoints
|
|
|
|
|
summary.TeleopPoints = score.TeleopPoints
|
|
|
|
|
summary.EndgamePoints = score.EndgamePoints
|
|
|
|
|
summary.Score = summary.AutoPoints + summary.TeleopPoints + summary.EndgamePoints
|
2017-08-05 20:48:17 -07:00
|
|
|
|
|
|
|
|
return summary
|
|
|
|
|
}
|
2017-09-02 22:50:28 -07:00
|
|
|
|
2020-03-18 22:42:36 -07:00
|
|
|
// Returns true if and only if all fields of the two scores are equal.
|
2017-09-02 22:50:28 -07:00
|
|
|
func (score *Score) Equals(other *Score) bool {
|
2020-04-14 19:38:14 -05:00
|
|
|
if score.AutoPoints != other.AutoPoints ||
|
|
|
|
|
score.TeleopPoints != other.TeleopPoints ||
|
|
|
|
|
score.EndgamePoints != other.EndgamePoints {
|
2017-09-02 22:50:28 -07:00
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
}
|