@@ -380,17 +380,26 @@ func (e *Engine) updateNextCommand() {
380
380
if primaryEvent == nil {
381
381
return
382
382
}
383
+
383
384
if primaryEvent .Type == GameEventDefenderTooCloseToKickPoint {
384
385
e .State .NextCommand , e .State .NextCommandFor =
385
386
e .lastCommand ([]RefCommand {CommandIndirect , CommandDirect , CommandKickoff , CommandPenalty })
386
387
} else {
387
- command , forTeam , err := e .CommandForEvent (primaryEvent )
388
- if err != nil {
389
- log .Print ("Warn: " , err )
390
- return
388
+ lastCommand , lastCommandFor :=
389
+ e .lastCommand ([]RefCommand {CommandKickoff , CommandPenalty , CommandNormalStart })
390
+ if lastCommand .IsPrepare () {
391
+ // if the last command was a kickoff or penalty, restart with that
392
+ e .State .NextCommand = lastCommand
393
+ e .State .NextCommandFor = lastCommandFor
394
+ } else {
395
+ command , forTeam , err := e .CommandForEvent (primaryEvent )
396
+ if err != nil {
397
+ log .Print ("Warn: " , err )
398
+ return
399
+ }
400
+ e .State .NextCommand = command
401
+ e .State .NextCommandFor = forTeam
391
402
}
392
- e .State .NextCommand = command
393
- e .State .NextCommandFor = forTeam
394
403
}
395
404
}
396
405
@@ -752,7 +761,7 @@ func (e *Engine) processGameEvent(event *GameEvent) error {
752
761
} else if event .Type == GameEventDefenderTooCloseToKickPoint {
753
762
// stop the game and let bots move away from the ball first. The autoRef will continue the game afterwards
754
763
e .SendCommand (CommandStop , "" )
755
- } else if ! event .IsSkipped () && ! event .IsSecondary () {
764
+ } else if ! event .IsSkipped () && ! event .IsSecondary () && ! e . State . Command . IsPrepare () {
756
765
e .placeBall (event )
757
766
} else if e .State .AutoContinue && event .IsContinueGame () {
758
767
e .Continue ()
0 commit comments