mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Copy foul list when populating descriptions, to avoid persisting them with the result.
This commit is contained in:
@@ -248,13 +248,15 @@ func getAudienceAllianceScoreFields(allianceScore *RealtimeScore, allianceScoreS
|
||||
|
||||
// Copy the description from the rules to the fouls so that they are available to the announcer.
|
||||
func populateFoulDescriptions(fouls []game.Foul) []game.Foul {
|
||||
for i := range fouls {
|
||||
foulsCopy := make([]game.Foul, len(fouls))
|
||||
copy(foulsCopy, fouls)
|
||||
for i := range foulsCopy {
|
||||
for _, rule := range game.Rules {
|
||||
if fouls[i].RuleNumber == rule.RuleNumber {
|
||||
fouls[i].Description = rule.Description
|
||||
if foulsCopy[i].RuleNumber == rule.RuleNumber {
|
||||
foulsCopy[i].Description = rule.Description
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return fouls
|
||||
return foulsCopy
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user