From dfb1a5b4572a882c3a634eb0e2052817e9f9c837 Mon Sep 17 00:00:00 2001 From: Nicolai Ommer Date: Thu, 18 Apr 2024 15:31:40 +0200 Subject: [PATCH] Fix: Give free kick to ball placing team --- internal/app/statemachine/change_gameevent.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/app/statemachine/change_gameevent.go b/internal/app/statemachine/change_gameevent.go index ec8b4468..017127d6 100644 --- a/internal/app/statemachine/change_gameevent.go +++ b/internal/app/statemachine/change_gameevent.go @@ -199,6 +199,16 @@ func (s *StateMachine) processChangeAddGameEvent(newState *state.State, change * if *newState.TeamInfo(byTeam).BallPlacementFailures > 0 { *newState.TeamInfo(byTeam).BallPlacementFailures-- } + + if *newState.Division == state.Division_DIV_A && + ballLeftField(newState) && + newState.NextCommand != nil && + *newState.NextCommand.Type == state.Command_DIRECT && + *newState.TeamInfo(byTeam.Opposite()).BallPlacementFailuresReached { + // In divA, if the ball left the field (no foul) and the other team has too many ball placement failures, + // and the team succeeded placement, the direct kick is given to the team that succeeded placement + newState.NextCommand = state.NewCommand(state.Command_DIRECT, byTeam) + } } // defender too close to kick point