Skip to content

Commit fa3b227

Browse files
committed
[bugfix] Always use the first game event as primary, except for penalty
1 parent 6a32746 commit fa3b227

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

internal/app/controller/gameEvent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ func (e GameEvent) IsSecondary() bool {
182182
GameEventUnsportingBehaviorMinor,
183183
GameEventUnsportingBehaviorMajor,
184184
GameEventMultipleFouls,
185+
GameEventMultiplePlacementFailures,
185186
GameEventBotCrashUniqueSkipped,
186187
GameEventBotPushedBotSkipped,
187188
GameEventPlacementFailedByTeamInFavor,

internal/app/controller/placementPos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"math"
77
)
88

9-
// BallPlacementPos determines the ball placement position based on the game event
9+
// BallPlacementPos determines the ball placement position based on the primary game event
1010
func (e *Engine) BallPlacementPos() *Location {
1111
event := e.State.PrimaryGameEvent()
1212
if event == nil {

internal/app/controller/state.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,16 @@ func (s State) BotSubstitutionIntend() Team {
394394
return TeamUnknown
395395
}
396396

397-
func (s State) PrimaryGameEvent() *GameEvent {
397+
func (s State) PrimaryGameEvent() (e *GameEvent) {
398+
e = nil
398399
for i := len(s.GameEvents) - 1; i >= 0; i-- {
399-
if !s.GameEvents[i].IsSecondary() {
400-
return s.GameEvents[i]
400+
e = s.GameEvents[i]
401+
if e.Type == GameEventMultipleCards {
402+
// only this event causes a penalty kick and must be prioritized.
403+
return
401404
}
402405
}
403-
return nil
406+
return
404407
}
405408

406409
func newTeamInfo() (t TeamInfo) {

0 commit comments

Comments
 (0)