Skip to content

Commit d519937

Browse files
committed
Change offset to grace period of 2s from now
1 parent da5e9f9 commit d519937

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

internal/app/statemachine/change_gameevent.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,13 @@ func (s *StateMachine) isGoalValid(newState *state.State, gameEvent *state.GameE
269269
// 3. The team did not commit any non-stopping foul since the teams robots last touched the ball.
270270
var recentlyCommittedFouls []state.GameEvent_Type
271271
var gracePeriod = 2 * time.Second
272+
var now = s.timeProvider()
272273
for _, foul := range newState.TeamInfo(byTeam).Fouls {
273274
if foul.CausedByGameEvent != nil &&
274275
foul.Timestamp != nil &&
275276
gameEvent.GetPossibleGoal().LastTouchByTeam != nil &&
276277
isNonStoppingFoul(*foul.CausedByGameEvent.Type) &&
277-
// add some time offset: If a bot committed a foul by touching ball inside the penalty area and scores
278-
// a goal shortly afterwards, the foul would have been before lastTouchedByTeam
279-
foul.Timestamp.AsTime().Add(gracePeriod).After(microTimestampToTime(*gameEvent.GetPossibleGoal().LastTouchByTeam)) {
278+
foul.Timestamp.AsTime().After(now.Add(-gracePeriod)) {
280279
recentlyCommittedFouls = append(recentlyCommittedFouls, *foul.CausedByGameEvent.Type)
281280
}
282281
}

0 commit comments

Comments
 (0)