Skip to content

Commit 92a4372

Browse files
committed
[feature] Check if team in favor can place the ball
1 parent 6efdb57 commit 92a4372

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/app/controller/engine.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,13 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
540540
}
541541

542542
if e.State.GameState() != GameStateHalted && !event.IsContinued() {
543-
if e.State.PlacementPos != nil {
544-
e.SendCommand(CommandBallPlacement, e.State.GameEvent.ByTeam().Opposite())
543+
teamInFavor := e.State.GameEvent.ByTeam().Opposite()
544+
if e.State.PlacementPos == nil {
545+
e.SendCommand(CommandStop, "")
546+
} else if e.State.TeamState[teamInFavor].CanPlaceBall {
547+
e.SendCommand(CommandBallPlacement, teamInFavor)
548+
} else if e.State.TeamState[teamInFavor.Opposite()].CanPlaceBall {
549+
e.SendCommand(CommandBallPlacement, teamInFavor.Opposite())
545550
} else if e.State.GameState() != GameStateStopped {
546551
e.SendCommand(CommandStop, "")
547552
}

0 commit comments

Comments
 (0)