Skip to content

Commit 4535f3f

Browse files
committed
Update naming and documentation
1 parent df91731 commit 4535f3f

File tree

12 files changed

+279
-282
lines changed

12 files changed

+279
-282
lines changed

cmd/ssl-team-client/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var autoDetectAddress = flag.Bool("autoDetectHost", true, "Automatically detect
1818
var refBoxAddr = flag.String("address", "localhost:10008", "Address to connect to")
1919
var privateKeyLocation = flag.String("privateKey", "", "A private key to be used to sign messages")
2020
var teamName = flag.String("teamName", "Test Team", "The name of the team as it is sent by the referee")
21-
var teamColor = flag.String("teamColor", "", "The color of the team as it is sent by the referee")
21+
var teamColor = flag.String("teamColor", "", "The color of the team as it is sent by the referee (YELLOW or BLUE)")
2222

2323
var privateKey *rsa.PrivateKey
2424

@@ -62,9 +62,9 @@ func main() {
6262
c.sendDesiredKeeper(3)
6363

6464
for {
65-
c.SendAdvantageChoice(rcon.AdvantageResponse_CONTINUE)
65+
c.SendAdvantageChoice(rcon.AdvantageChoice_CONTINUE)
6666
time.Sleep(time.Millisecond * 1000)
67-
c.SendAdvantageChoice(rcon.AdvantageResponse_STOP)
67+
c.SendAdvantageChoice(rcon.AdvantageChoice_STOP)
6868
time.Sleep(time.Millisecond * 1000)
6969
}
7070
}
@@ -119,8 +119,8 @@ func (c *Client) sendDesiredKeeper(id int32) (accepted bool) {
119119
return c.sendRequest(&request)
120120
}
121121

122-
func (c *Client) SendAdvantageChoice(choice rcon.AdvantageResponse) {
123-
reply := rcon.TeamToController_AdvantageResponse{AdvantageResponse: choice}
122+
func (c *Client) SendAdvantageChoice(choice rcon.AdvantageChoice) {
123+
reply := rcon.TeamToController_AdvantageChoice{AdvantageChoice: choice}
124124
response := rcon.TeamToController{Msg: &reply}
125125
c.sendRequest(&response)
126126
}

internal/app/engine/process_botremoved.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func (e *Engine) processBotNumberPerTeam(team state.Team) {
4747
numBotsAllowed := *teamInfo.MaxAllowedBots + newCards
4848
if numBots > numBotsAllowed {
4949

50-
advantageResponse := e.gcState.TeamState[team.Opposite().String()].LastAdvantageResponse
51-
if *advantageResponse.Response == TeamAdvantageResponse_CONTINUE {
50+
advantageChoice := e.gcState.TeamState[team.Opposite().String()].AdvantageChoice
51+
if *advantageChoice.Choice == TeamAdvantageChoice_CONTINUE {
5252
return
5353
}
5454

internal/app/engine/process_team_advantage.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package engine
22

33
import "github.com/RoboCup-SSL/ssl-game-controller/internal/app/state"
44

5-
var defaultResponse = TeamAdvantageResponse_STOP
5+
var defaultChoice = TeamAdvantageChoice_STOP
66

7-
func (e *Engine) processTeamAdvantageResponse() {
7+
func (e *Engine) processTeamAdvantageChoice() {
88

99
for _, team := range state.BothTeams() {
10-
advantageResponse := e.gcState.TeamState[team.String()].LastAdvantageResponse
11-
if advantageResponse == nil {
12-
e.gcState.TeamState[team.String()].LastAdvantageResponse = &TeamAdvantageResponse{
13-
Response: &defaultResponse,
10+
advantageChoice := e.gcState.TeamState[team.String()].AdvantageChoice
11+
if advantageChoice == nil {
12+
e.gcState.TeamState[team.String()].AdvantageChoice = &TeamAdvantageChoice{
13+
Choice: &defaultChoice,
1414
}
1515
}
1616
}

internal/app/engine/process_tick.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (e *Engine) processTick() {
6060
e.noProgressDetector.process()
6161
e.ballPlacementCoordinator.process()
6262
e.processContinue()
63-
e.processTeamAdvantageResponse()
63+
e.processTeamAdvantageChoice()
6464
e.botNumberProcessor.processBotNumber()
6565
e.processPenalty()
6666
e.processProposals()

internal/app/engine/ssl_gc_engine.pb.go

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

internal/app/rcon/server_team.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (s *TeamServer) handleClientConnection(conn net.Conn) {
116116
connected := false
117117
teamState.Connected = &connected
118118
teamState.ConnectionVerified = &connected
119-
teamState.LastAdvantageResponse = nil
119+
teamState.AdvantageChoice = nil
120120
} else {
121121
log.Println("Team not connected: " + client.team.String())
122122
}
@@ -177,14 +177,14 @@ func (s *TeamServer) processRequest(teamClient TeamClient, request *TeamToContro
177177
return nil
178178
}
179179

180-
if x, ok := request.GetMsg().(*TeamToController_AdvantageResponse); ok {
181-
responseType := engine.TeamAdvantageResponse_STOP
182-
if x.AdvantageResponse == AdvantageResponse_CONTINUE {
183-
responseType = engine.TeamAdvantageResponse_CONTINUE
180+
if x, ok := request.GetMsg().(*TeamToController_AdvantageChoice); ok {
181+
responseType := engine.TeamAdvantageChoice_STOP
182+
if x.AdvantageChoice == AdvantageChoice_CONTINUE {
183+
responseType = engine.TeamAdvantageChoice_CONTINUE
184184
}
185185
s.gcEngine.UpdateGcState(func(gcState *engine.GcState) {
186-
gcState.TeamState[teamClient.team.String()].LastAdvantageResponse = &engine.TeamAdvantageResponse{
187-
Response: &responseType,
186+
gcState.TeamState[teamClient.team.String()].AdvantageChoice = &engine.TeamAdvantageChoice{
187+
Choice: &responseType,
188188
}
189189
})
190190
// exit early to avoid spamming the log

internal/app/rcon/ssl_gc_rcon_team.pb.go

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

proto/ssl_gc_engine.proto

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ message GcStateTeam {
3737
// true: The remote control for the team connected via TLS with a verified certificate
3838
optional bool remote_control_connection_verified = 4;
3939

40-
// the last advantage response of the team
41-
optional TeamAdvantageResponse last_advantage_response = 5;
40+
// the advantage choice of the team
41+
optional TeamAdvantageChoice advantage_choice = 5;
4242
}
4343

44-
// The response from a team regarding the advantage rule
45-
message TeamAdvantageResponse {
46-
// the response of the team
47-
optional AdvantageResponse response = 1;
44+
// The choice from a team regarding the advantage rule
45+
message TeamAdvantageChoice {
46+
// the choice of the team
47+
optional AdvantageChoice choice = 1;
4848

49-
// possible advantage responses
50-
enum AdvantageResponse {
49+
// possible advantage choices
50+
enum AdvantageChoice {
5151
// stop the game
5252
STOP = 0;
5353
// keep the match running

proto/ssl_gc_rcon_team.proto

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ message TeamToController {
2424
// request a new desired keeper id
2525
int32 desired_keeper = 2;
2626
// response to an advantage choice request
27-
AdvantageResponse advantage_response = 3;
27+
AdvantageChoice advantage_choice = 3;
2828
// request to substitute a robot at the next possibility
2929
bool substitute_bot = 4;
3030
// send a ping to the GC to test if the connection is still open.
@@ -33,14 +33,15 @@ message TeamToController {
3333
}
3434
}
3535

36-
enum AdvantageResponse {
37-
option allow_alias = true;
36+
// the current advantage choice of the team
37+
// the choice is valid until another choice is received
38+
// if the team disconnects, the choice is reset to its default (STOP)
39+
// teams may either send their current choice continuously or only on change
40+
enum AdvantageChoice {
3841
// stop the game
3942
STOP = 0;
40-
// continue the game a bit more
43+
// keep the game running
4144
CONTINUE = 1;
42-
// no choice -> will default to STOP
43-
UNDECIDED = 0;
4445
}
4546

4647
// wrapper for all messages from controller to a team's computer

0 commit comments

Comments
 (0)