Skip to content

Commit 6e10d6b

Browse files
committed
Fix free-kick ball placement pos after failed penalty kick
1 parent 6c68d55 commit 6e10d6b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

internal/app/statemachine/placementPos.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,18 @@ func (s *BallPlacementPosDeterminer) Location() *geom.Vector2 {
102102
case state.GameEvent_PLACEMENT_SUCCEEDED:
103103
return s.keepCurrentPlacementPos()
104104
case state.GameEvent_PENALTY_KICK_FAILED:
105+
forTeam := s.Event.GetPenaltyKickFailed().ByTeam.Opposite()
106+
sign := 1.0
107+
if !s.State.TeamInfo(forTeam).GetOnPositiveHalf() {
108+
sign = -1.0
109+
}
110+
y := 0.0
105111
if s.Event.GetPenaltyKickFailed().Location != nil {
106-
location := s.Event.GetPenaltyKickFailed().Location
107-
return s.ballPlacementLocationGoalLine(location)
112+
y = s.Event.GetPenaltyKickFailed().Location.GetY64()
108113
}
109-
return s.keepCurrentPlacementPos()
114+
// the location is not trustworthy, because when a timeout occurs, the ball may be on the other field half
115+
location := geom.NewVector2(sign*s.Geometry.FieldLength/2, y)
116+
return s.ballPlacementLocationGoalLine(location)
110117
case state.GameEvent_NO_PROGRESS_IN_GAME:
111118
return s.validateLocation(s.Event.GetNoProgressInGame().Location)
112119
case state.GameEvent_PLACEMENT_FAILED,

0 commit comments

Comments
 (0)