Files
cheesy-arena-lite/game/score.go

43 lines
1.0 KiB
Go
Raw Normal View History

2020-03-18 22:42:36 -07:00
// Copyright 2020 Team 254. All Rights Reserved.
// 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
}
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
}
// Calculates and returns the summary fields used for ranking and display.
2020-04-14 19:38:14 -05:00
func (score *Score) Summarize() *ScoreSummary {
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
return summary
}
2020-03-18 22:42:36 -07:00
// Returns true if and only if all fields of the two scores are equal.
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 {
return false
}
return true
}