Skip to content

Commit 2e28073

Browse files
committed
Add a flag that indicates the remote-control that team can substitute robots
1 parent 8845bf1 commit 2e28073

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

internal/app/rcon/server_remotecontrol.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
198208
func (c *RemoteControlClient) findActiveRequestTypes() []RemoteControlRequestType {
199209
currentState := c.gcEngine.CurrentState()
200210
teamState := currentState.TeamState[c.team.String()]

internal/app/rcon/ssl_gc_rcon_remotecontrol.pb.go

Lines changed: 29 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ssl_gc_rcon_remotecontrol.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ message RemoteControlTeamState {
9191

9292
// list of due times for each active yellow card (in seconds)
9393
repeated float yellow_cards_due = 8;
94+
95+
// if true, team is allowed to substitute robots
96+
optional bool can_substitute_robot = 11;
9497
}
9598

9699
// All possible request types that the remote control can make

0 commit comments

Comments
 (0)