Skip to content

Commit a3ee919

Browse files
committed
Correctly handle ball placement and continue procedure
1 parent 2d53892 commit a3ee919

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

internal/app/engine/process_continue.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const distanceToBallDuringPenalty = 1.0
1212

1313
func (e *Engine) processContinue() {
1414
if !(e.currentState.Command.IsPrepare() || *e.currentState.Command.Type == state.Command_STOP) ||
15-
e.gcState.TrackerStateGc.Ball == nil ||
16-
e.currentState.NextCommand == nil {
15+
e.gcState.TrackerStateGc.Ball == nil {
1716
e.gcState.ReadyToContinue = nil
1817
return
1918
}

internal/app/statemachine/change_gameevent.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ func (s *StateMachine) processChangeAddGameEvent(newState *state.State, change *
129129

130130
// ball placement succeeded
131131
if *gameEvent.Type == state.GameEvent_PLACEMENT_SUCCEEDED &&
132-
byTeam.Known() &&
133-
*newState.TeamInfo(byTeam).BallPlacementFailures > 0 {
134-
*newState.TeamInfo(byTeam).BallPlacementFailures--
135-
if byTeam == *newState.NextCommand.ForTeam && newState.GetAutoContinue() {
132+
byTeam.Known() {
133+
if *newState.TeamInfo(byTeam).BallPlacementFailures > 0 {
134+
*newState.TeamInfo(byTeam).BallPlacementFailures--
135+
}
136+
137+
if newState.GetAutoContinue() && newState.NextCommand != nil && byTeam == *newState.NextCommand.ForTeam {
136138
log.Printf("Placement succeeded by team %v, which is also in favor. Can continue.", byTeam)
137139
changes = append(changes, &Change{
138140
Change: &Change_Continue{

0 commit comments

Comments
 (0)