@@ -91,7 +91,8 @@ func (e *Engine) nextActions() (actions []*ContinueAction) {
9191 }
9292 }
9393
94- if * e .currentState .Command .Type == state .Command_STOP {
94+ if * e .currentState .Command .Type == state .Command_STOP ||
95+ * e .currentState .Command .Type == state .Command_HALT {
9596 if e .currentState .StageTimeLeft .AsDuration () < 0 {
9697 actions = append (actions , createContinueAction (
9798 ContinueAction_NEXT_STAGE ,
@@ -121,7 +122,11 @@ func (e *Engine) nextActions() (actions []*ContinueAction) {
121122 * teamRequestingTimeout ,
122123 ContinueAction_READY_MANUAL ,
123124 ))
124- } else if e .ballPlacementRequired () {
125+ }
126+ }
127+
128+ if * e .currentState .Command .Type == state .Command_STOP {
129+ if e .ballPlacementRequired () {
125130 placingTeam := e .ballPlacementTeam ()
126131 if placingTeam .Known () {
127132 actions = append (actions , createContinueAction (
@@ -146,11 +151,16 @@ func (e *Engine) nextActions() (actions []*ContinueAction) {
146151 }
147152
148153 if * e .currentState .Command .Type == state .Command_HALT {
149- actions = append ( actions , createContinueAction (
154+ continueFromHalt := createContinueAction (
150155 ContinueAction_RESUME_FROM_HALT ,
151156 state .Team_UNKNOWN ,
152157 ContinueAction_READY_MANUAL ,
153- ))
158+ )
159+ if e .teamDoingBotSubstitution () {
160+ continueFromHalt .ContinuationIssues = append (continueFromHalt .ContinuationIssues ,
161+ "Robot substitution in progress" )
162+ }
163+ actions = append (actions , continueFromHalt )
154164 }
155165
156166 if * e .currentState .Command .Type != state .Command_HALT &&
@@ -168,7 +178,8 @@ func (e *Engine) nextActions() (actions []*ContinueAction) {
168178func (e * Engine ) teamRequestingBotSubstitution () * state.Team {
169179 var teams []state.Team
170180 for _ , team := range state .BothTeams () {
171- if e .currentState .TeamInfo (team ).RequestsBotSubstitutionSince != nil {
181+ if e .currentState .TeamInfo (team ).RequestsBotSubstitutionSince != nil &&
182+ ! * e .currentState .TeamInfo (team ).BotSubstitutionAllowed {
172183 teams = append (teams , team )
173184 }
174185 }
@@ -181,6 +192,15 @@ func (e *Engine) teamRequestingBotSubstitution() *state.Team {
181192 return nil
182193}
183194
195+ func (e * Engine ) teamDoingBotSubstitution () bool {
196+ for _ , team := range state .BothTeams () {
197+ if * e .currentState .TeamInfo (team ).BotSubstitutionAllowed {
198+ return true
199+ }
200+ }
201+ return false
202+ }
203+
184204func (e * Engine ) teamRequestingTimeout () * state.Team {
185205 requestBlue := e .currentState .TeamInfo (state .Team_BLUE ).RequestsTimeoutSince
186206 requestYellow := e .currentState .TeamInfo (state .Team_YELLOW ).RequestsTimeoutSince
0 commit comments