@@ -153,6 +153,7 @@ func (c *RemoteControlClient) replyWithState(reply *ControllerReply) {
153
153
activeRequests := c .findActiveRequestTypes ()
154
154
robotsOnField := c .gcEngine .TrackerState ().NumTeamRobots (* c .team )
155
155
timeoutTimeLeft := float32 (teamState .TimeoutTimeLeft .AsDuration ().Seconds ())
156
+ canSubstituteRobot := c .canSubstituteRobot ()
156
157
157
158
response := & ControllerToRemoteControl {
158
159
State : & RemoteControlTeamState {
@@ -166,6 +167,7 @@ func (c *RemoteControlClient) replyWithState(reply *ControllerReply) {
166
167
MaxRobots : teamState .MaxAllowedBots ,
167
168
RobotsOnField : & robotsOnField ,
168
169
YellowCardsDue : yellowCardsDue ,
170
+ CanSubstituteRobot : & canSubstituteRobot ,
169
171
},
170
172
ControllerReply : reply ,
171
173
}
@@ -195,6 +197,14 @@ func (c *RemoteControlClient) findYellowCardDueTimes() []float32 {
195
197
return yellowCardsDue
196
198
}
197
199
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
+
198
208
func (c * RemoteControlClient ) findActiveRequestTypes () []RemoteControlRequestType {
199
209
currentState := c .gcEngine .CurrentState ()
200
210
teamState := currentState .TeamState [c .team .String ()]
0 commit comments