Skip to content

Commit

Permalink
[feature] Publish proposed game events through referee message
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Sep 16, 2018
1 parent 9848a82 commit 54a2a53
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 96 deletions.
13 changes: 13 additions & 0 deletions internal/app/controller/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (p *Publisher) send() {
func (p *RefMessage) setState(state *State) (republish bool) {
p.referee.GameEvents = mapGameEvents(state.GameEvents)
p.referee.DesignatedPosition = mapLocation(state.PlacementPos)
p.referee.ProposedGameEvents = mapProposals(state.GameEventProposals)

*p.referee.PacketTimestamp = uint64(time.Now().UnixNano() / 1000)
*p.referee.Stage = mapStage(state.Stage)
Expand All @@ -117,6 +118,18 @@ func (p *RefMessage) setState(state *State) (republish bool) {
return
}

func mapProposals(proposals []*GameEventProposal) []*refproto.ProposedGameEvent {
mappedProposals := make([]*refproto.ProposedGameEvent, len(proposals))
for i, proposal := range proposals {
mappedProposals[i] = new(refproto.ProposedGameEvent)
mappedProposals[i].ProposerId = &proposal.ProposerId
mappedProposals[i].ValidUntil = new(uint64)
*mappedProposals[i].ValidUntil = uint64(proposal.ValidUntil.UnixNano() / 1000)
mappedProposals[i].GameEvent = proposal.GameEvent.ToProto()
}
return mappedProposals
}

func (p *RefMessage) sendCommands(state *State) {
newCommand := mapCommand(state.Command, state.CommandFor)

Expand Down
166 changes: 83 additions & 83 deletions pkg/refproto/ssl_referee.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions pkg/refproto/ssl_referee.proto
Original file line number Diff line number Diff line change
Expand Up @@ -164,31 +164,31 @@ message Referee {
optional Point designated_position = 9;

// Information about the direction of play.
// True, if the blue team will have it's goal on the positive x-axis of the ssl-vision coordinate system
// Obviously, the yellow team will play on the opposide half
// For compatibility, this field is optional
// True, if the blue team will have it's goal on the positive x-axis of the ssl-vision coordinate system.
// Obviously, the yellow team will play on the opposide half.
// For compatibility, this field is optional.
optional bool blue_team_on_positive_half = 10;

// The game event that caused the referee command
// deprecated in favor of current_game_event
// The game event that caused the referee command.
// deprecated in favor of current_game_event.
optional Game_Event game_event = 11 [deprecated = true];

// The command that will be issued after the current stoppage and ball placement to continue the game
// The command that will be issued after the current stoppage and ball placement to continue the game.
optional Command next_command = 12;

// all game events that were detected since the last RUNNING state
// will be cleared as soon as the game is continued
// All game events that were detected since the last RUNNING state.
// Will be cleared as soon as the game is continued.
repeated GameEvent game_events = 13;

// all non-finished proposed game events that may be processed next
// All non-finished proposed game events that may be processed next.
repeated ProposedGameEvent proposed_game_events = 14;
}

message ProposedGameEvent {
// the UNIX timestamp when the game event was proposed
required uint64 timestamp = 1;
// the identifier of the proposer
// The UNIX timestamp when the game event proposal will time out, in microseconds.
required uint64 valid_until = 1;
// The identifier of the proposer.
required string proposer_id = 2;
// the actual game event
// The proposed game event.
required GameEvent game_event = 3;
}

0 comments on commit 54a2a53

Please sign in to comment.