mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Remove game-specific scoring
This commit is contained in:
6
model/event_settings.go
Normal file → Executable file
6
model/event_settings.go
Normal file → Executable file
@@ -38,9 +38,6 @@ type EventSettings struct {
|
||||
PauseDurationSec int
|
||||
TeleopDurationSec int
|
||||
WarningRemainingDurationSec int
|
||||
Stage1Capacity int
|
||||
Stage2Capacity int
|
||||
Stage3Capacity int
|
||||
}
|
||||
|
||||
const eventSettingsId = 0
|
||||
@@ -64,9 +61,6 @@ func (database *Database) GetEventSettings() (*EventSettings, error) {
|
||||
eventSettings.PauseDurationSec = game.MatchTiming.PauseDurationSec
|
||||
eventSettings.TeleopDurationSec = game.MatchTiming.TeleopDurationSec
|
||||
eventSettings.WarningRemainingDurationSec = game.MatchTiming.WarningRemainingDurationSec
|
||||
eventSettings.Stage1Capacity = game.StageCapacities[game.Stage1]
|
||||
eventSettings.Stage2Capacity = game.StageCapacities[game.Stage2]
|
||||
eventSettings.Stage3Capacity = game.StageCapacities[game.Stage3]
|
||||
|
||||
err = database.eventSettingsMap.Insert(eventSettings)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,8 +16,7 @@ func TestEventSettingsReadWrite(t *testing.T) {
|
||||
assert.Equal(t, EventSettings{Id: 0, Name: "Untitled Event", NumElimAlliances: 8, SelectionRound2Order: "L",
|
||||
SelectionRound3Order: "", TBADownloadEnabled: true, ApTeamChannel: 157, ApAdminChannel: 0,
|
||||
ApAdminWpaKey: "1234Five", WarmupDurationSec: 0, AutoDurationSec: 15, PauseDurationSec: 2,
|
||||
TeleopDurationSec: 135, WarningRemainingDurationSec: 30, Stage1Capacity: 9, Stage2Capacity: 20,
|
||||
Stage3Capacity: 20}, *eventSettings)
|
||||
TeleopDurationSec: 135, WarningRemainingDurationSec: 30}, *eventSettings)
|
||||
|
||||
eventSettings.Name = "Chezy Champs"
|
||||
eventSettings.NumElimAlliances = 6
|
||||
|
||||
43
model/match_result.go
Normal file → Executable file
43
model/match_result.go
Normal file → Executable file
@@ -17,8 +17,6 @@ type MatchResult struct {
|
||||
MatchType string
|
||||
RedScore *game.Score
|
||||
BlueScore *game.Score
|
||||
RedCards map[string]string
|
||||
BlueCards map[string]string
|
||||
}
|
||||
|
||||
type MatchResultDb struct {
|
||||
@@ -28,8 +26,6 @@ type MatchResultDb struct {
|
||||
MatchType string
|
||||
RedScoreJson string
|
||||
BlueScoreJson string
|
||||
RedCardsJson string
|
||||
BlueCardsJson string
|
||||
}
|
||||
|
||||
// Returns a new match result object with empty slices instead of nil.
|
||||
@@ -37,8 +33,6 @@ func NewMatchResult() *MatchResult {
|
||||
matchResult := new(MatchResult)
|
||||
matchResult.RedScore = new(game.Score)
|
||||
matchResult.BlueScore = new(game.Score)
|
||||
matchResult.RedCards = make(map[string]string)
|
||||
matchResult.BlueCards = make(map[string]string)
|
||||
return matchResult
|
||||
}
|
||||
|
||||
@@ -95,30 +89,13 @@ func (database *Database) TruncateMatchResults() error {
|
||||
}
|
||||
|
||||
// Calculates and returns the summary fields used for ranking and display for the red alliance.
|
||||
func (matchResult *MatchResult) RedScoreSummary(teleopStarted bool) *game.ScoreSummary {
|
||||
return matchResult.RedScore.Summarize(matchResult.BlueScore.Fouls, teleopStarted)
|
||||
func (matchResult *MatchResult) RedScoreSummary() *game.ScoreSummary {
|
||||
return matchResult.RedScore.Summarize()
|
||||
}
|
||||
|
||||
// Calculates and returns the summary fields used for ranking and display for the blue alliance.
|
||||
func (matchResult *MatchResult) BlueScoreSummary(teleopStarted bool) *game.ScoreSummary {
|
||||
return matchResult.BlueScore.Summarize(matchResult.RedScore.Fouls, teleopStarted)
|
||||
}
|
||||
|
||||
// Checks the score for disqualifications or a tie and adjusts it appropriately.
|
||||
func (matchResult *MatchResult) CorrectEliminationScore() {
|
||||
matchResult.RedScore.ElimDq = false
|
||||
for _, card := range matchResult.RedCards {
|
||||
if card == "red" {
|
||||
matchResult.RedScore.ElimDq = true
|
||||
}
|
||||
}
|
||||
for _, card := range matchResult.BlueCards {
|
||||
if card == "red" {
|
||||
matchResult.BlueScore.ElimDq = true
|
||||
}
|
||||
}
|
||||
|
||||
// No elimination tiebreakers.
|
||||
func (matchResult *MatchResult) BlueScoreSummary() *game.ScoreSummary {
|
||||
return matchResult.BlueScore.Summarize()
|
||||
}
|
||||
|
||||
// Converts the nested struct MatchResult to the DB version that has JSON fields.
|
||||
@@ -131,12 +108,6 @@ func (matchResult *MatchResult) Serialize() (*MatchResultDb, error) {
|
||||
if err := serializeHelper(&matchResultDb.BlueScoreJson, matchResult.BlueScore); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := serializeHelper(&matchResultDb.RedCardsJson, matchResult.RedCards); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := serializeHelper(&matchResultDb.BlueCardsJson, matchResult.BlueCards); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &matchResultDb, nil
|
||||
}
|
||||
|
||||
@@ -150,11 +121,5 @@ func (matchResultDb *MatchResultDb) Deserialize() (*MatchResult, error) {
|
||||
if err := json.Unmarshal([]byte(matchResultDb.BlueScoreJson), &matchResult.BlueScore); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := json.Unmarshal([]byte(matchResultDb.RedCardsJson), &matchResult.RedCards); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := json.Unmarshal([]byte(matchResultDb.BlueCardsJson), &matchResult.BlueCards); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &matchResult, nil
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/Team254/cheesy-arena/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
@@ -26,7 +25,6 @@ func TestMatchResultCrud(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, matchResult, matchResult2)
|
||||
|
||||
matchResult.BlueScore.EndgameStatuses = [3]game.EndgameStatus{game.EndgameHang, game.EndgameNone, game.EndgamePark}
|
||||
db.SaveMatchResult(matchResult)
|
||||
matchResult2, err = db.GetMatchResultForMatch(254)
|
||||
assert.Nil(t, err)
|
||||
|
||||
@@ -16,7 +16,6 @@ type Team struct {
|
||||
RobotName string
|
||||
Accomplishments string
|
||||
WpaKey string
|
||||
YellowCard bool
|
||||
HasConnected bool
|
||||
FtaNotes string
|
||||
}
|
||||
|
||||
2
model/test_helpers.go
Normal file → Executable file
2
model/test_helpers.go
Normal file → Executable file
@@ -27,8 +27,6 @@ func BuildTestMatchResult(matchId int, playNumber int) *MatchResult {
|
||||
matchResult := &MatchResult{MatchId: matchId, PlayNumber: playNumber, MatchType: "qualification"}
|
||||
matchResult.RedScore = game.TestScore1()
|
||||
matchResult.BlueScore = game.TestScore2()
|
||||
matchResult.RedCards = map[string]string{"1868": "yellow"}
|
||||
matchResult.BlueCards = map[string]string{}
|
||||
return matchResult
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user