Skip to content

Commit 23ed20b

Browse files
committed
[feature] Add bot substitution to team protocol
1 parent 03c76a2 commit 23ed20b

File tree

3 files changed

+72
-31
lines changed

3 files changed

+72
-31
lines changed

internal/app/controller/controller.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,20 @@ func (c *GameController) ProcessTeamRequests(teamName string, request refproto.T
170170
return nil
171171
}
172172

173-
if c.Engine.State.GameState() != GameStateStopped {
174-
return errors.New("Game is not stopped.")
175-
}
176-
177173
team := c.Engine.State.TeamByName(teamName)
178-
if team == "" {
174+
if team == TeamUnknown {
179175
return errors.New("Your team is not playing?!")
180176
}
181177

178+
if x, ok := request.GetRequest().(*refproto.TeamToControllerRequest_SubstituteBot); ok {
179+
log.Printf("Team %v updated bot substituation intend to %v", team, x.SubstituteBot)
180+
c.Engine.State.TeamState[team].BotSubstitutionIntend = x.SubstituteBot
181+
}
182+
183+
if c.Engine.State.GameState() != GameStateStopped {
184+
return errors.New("Game is not stopped.")
185+
}
186+
182187
if x, ok := request.GetRequest().(*refproto.TeamToControllerRequest_DesiredKeeper); ok {
183188
log.Printf("Changing goalie for team %v to %v", team, x.DesiredKeeper)
184189
c.Engine.State.TeamState[team].Goalie = int(x.DesiredKeeper)

pkg/refproto/ssl_game_controller_team.pb.go

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

pkg/refproto/ssl_game_controller_team.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ message TeamToControllerRequest {
2121
int32 desired_keeper = 2;
2222
// response to an advantage choice request
2323
AdvantageResponse advantage_response = 3;
24+
// request to substitute a robot at the next possibility
25+
bool substitute_bot = 4;
2426
}
2527

2628
enum AdvantageResponse {

0 commit comments

Comments
 (0)