Skip to content

Commit 6efdb57

Browse files
committed
[feature] Automatically send ball placement command
1 parent 4e48e6e commit 6efdb57

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/app/controller/engine.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,6 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
506506
return errors.Errorf("Incomplete game event: %v", event)
507507
}
508508

509-
if e.State.GameState() != GameStateStopped && e.State.GameState() != GameStateHalted && !event.IsContinued() {
510-
e.SendCommand(CommandStop, "")
511-
}
512-
513509
if event.IncrementsFoulCounter() {
514510
team := event.ByTeam()
515511
if team.Unknown() {
@@ -540,6 +536,15 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
540536
e.SendGameEventSecondary(*event)
541537
} else {
542538
e.SendGameEventPrimary(*event)
539+
e.State.PlacementPos = e.BallPlacementPos()
540+
}
541+
542+
if e.State.GameState() != GameStateHalted && !event.IsContinued() {
543+
if e.State.PlacementPos != nil {
544+
e.SendCommand(CommandBallPlacement, e.State.GameEvent.ByTeam().Opposite())
545+
} else if e.State.GameState() != GameStateStopped {
546+
e.SendCommand(CommandStop, "")
547+
}
543548
}
544549

545550
log.Printf("Processed game event %v", event)

0 commit comments

Comments
 (0)