@@ -65,11 +65,13 @@ type GameEvent struct {
65
65
Details GameEventDetails `json:"details"`
66
66
}
67
67
68
+ // String converts the game event into a string
68
69
func (e GameEvent ) String () string {
69
70
b , _ := json .Marshal (& e )
70
71
return string (b )
71
72
}
72
73
74
+ // AllGameEvents returns a list of all known game events
73
75
func AllGameEvents () []GameEventType {
74
76
return []GameEventType {
75
77
GameEventBallLeftFieldTouchLine ,
@@ -198,7 +200,7 @@ func (e GameEvent) IsSecondary() bool {
198
200
return false
199
201
}
200
202
201
- // IsSkipped checks if the game event is was continued ( not stopped) based on the decision of a team
203
+ // IsSkipped checks if the game event is a skipped one (one for which the game was not stopped based on the decision of a team)
202
204
func (e GameEvent ) IsSkipped () bool {
203
205
switch e .Type {
204
206
case GameEventBotPushedBotSkipped ,
@@ -218,6 +220,7 @@ func (e GameEvent) IsContinueGame() bool {
218
220
return false
219
221
}
220
222
223
+ // ToProto converts the internal game event into a protobuf game event
221
224
func (e GameEvent ) ToProto () * refproto.GameEvent {
222
225
protoEvent := new (refproto.GameEvent )
223
226
switch e .Type {
@@ -351,6 +354,7 @@ type GameEventDetails struct {
351
354
TooManyRobots * refproto.GameEvent_TooManyRobots `json:"tooManyRobots,omitempty"`
352
355
}
353
356
357
+ // EventType returns the internal game event type of game event details
354
358
func (d GameEventDetails ) EventType () GameEventType {
355
359
if d .BallLeftFieldTouchLine != nil {
356
360
return GameEventBallLeftFieldTouchLine
@@ -472,7 +476,8 @@ func (d GameEventDetails) EventType() GameEventType {
472
476
return GameEventNone
473
477
}
474
478
475
- func (d GameEventDetails ) Description () string {
479
+ // String converts the game event details to a string
480
+ func (d GameEventDetails ) String () string {
476
481
if d .BallLeftFieldTouchLine != nil {
477
482
if d .BallLeftFieldTouchLine .ByBot != nil {
478
483
return fmt .Sprintf ("By bot %v" , * d .BallLeftFieldTouchLine .ByBot )
@@ -680,7 +685,8 @@ func (d GameEventDetails) Description() string {
680
685
return ""
681
686
}
682
687
683
- func NewGameEventDetails (event refproto.GameEvent ) (d GameEventDetails ) {
688
+ // GameEventDetailsFromProto converts a protobuf game event into internal details
689
+ func GameEventDetailsFromProto (event refproto.GameEvent ) (d GameEventDetails ) {
684
690
d .BallLeftFieldTouchLine = event .GetBallLeftFieldTouchLine ()
685
691
d .BallLeftFieldGoalLine = event .GetBallLeftFieldGoalLine ()
686
692
d .AimlessKick = event .GetAimlessKick ()
0 commit comments