@@ -153,6 +153,7 @@ func (c *RemoteControlClient) replyWithState(reply *ControllerReply) {
153153 activeRequests := c .findActiveRequestTypes ()
154154 robotsOnField := c .gcEngine .TrackerState ().NumTeamRobots (* c .team )
155155 timeoutTimeLeft := float32 (teamState .TimeoutTimeLeft .AsDuration ().Seconds ())
156+ canSubstituteRobot := c .canSubstituteRobot ()
156157
157158 response := & ControllerToRemoteControl {
158159 State : & RemoteControlTeamState {
@@ -166,6 +167,7 @@ func (c *RemoteControlClient) replyWithState(reply *ControllerReply) {
166167 MaxRobots : teamState .MaxAllowedBots ,
167168 RobotsOnField : & robotsOnField ,
168169 YellowCardsDue : yellowCardsDue ,
170+ CanSubstituteRobot : & canSubstituteRobot ,
169171 },
170172 ControllerReply : reply ,
171173 }
@@ -195,6 +197,14 @@ func (c *RemoteControlClient) findYellowCardDueTimes() []float32 {
195197 return yellowCardsDue
196198}
197199
200+ func (c * RemoteControlClient ) canSubstituteRobot () bool {
201+ teamState := c .gcEngine .CurrentState ().TeamState [c .team .String ()]
202+ substitutionEvents := c .gcEngine .CurrentState ().FindGameEventsByTeam (state .GameEvent_BOT_SUBSTITUTION , * c .team )
203+ return len (substitutionEvents ) > 0 &&
204+ teamState .RequestsBotSubstitutionSince != nil &&
205+ c .gcEngine .CurrentState ().GameState .IsHalted ()
206+ }
207+
198208func (c * RemoteControlClient ) findActiveRequestTypes () []RemoteControlRequestType {
199209 currentState := c .gcEngine .CurrentState ()
200210 teamState := currentState .TeamState [c .team .String ()]
0 commit comments