@@ -4,15 +4,17 @@ import (
4
4
"time"
5
5
)
6
6
7
- // a team, one of Yellow or Blue
7
+ // Team is one of Yellow or Blue
8
8
type Team string
9
9
10
10
const (
11
+ // TeamYellow is the yellow team
11
12
TeamYellow Team = "Yellow"
12
- TeamBlue Team = "Blue"
13
+ // TeamBlue is the blue team
14
+ TeamBlue Team = "Blue"
13
15
)
14
16
15
- // return the other team
17
+ // Other returns the other team
16
18
// if the team is not Yellow or Blue, return the same team
17
19
func (t Team ) Other () Team {
18
20
if t == TeamYellow {
@@ -23,27 +25,41 @@ func (t Team) Other() Team {
23
25
return t
24
26
}
25
27
26
- // a stage of a match
28
+ // Stage represents the different stages of a game
27
29
type Stage string
28
30
29
31
const (
30
- StagePreGame Stage = "Pre-Game"
31
- StageFirstHalf Stage = "First Half"
32
- StageHalfTime Stage = "Half Time"
33
- StageSecondHalfPre Stage = "Pre-Second Half"
34
- StageSecondHalf Stage = "Second Half"
35
- StageOvertimeBreak Stage = "Overtime Break"
36
- StageOvertimeFirstHalfPre Stage = "Pre-Overtime First Half"
37
- StageOvertimeFirstHalf Stage = "Overtime First Half"
38
- StageOvertimeHalfTime Stage = "Overtime Half Time"
32
+ // StagePreGame before game has started
33
+ StagePreGame Stage = "Pre-Game"
34
+ // StageFirstHalf in first half
35
+ StageFirstHalf Stage = "First Half"
36
+ // StageHalfTime in half time
37
+ StageHalfTime Stage = "Half Time"
38
+ // StageSecondHalfPre before second half
39
+ StageSecondHalfPre Stage = "Pre-Second Half"
40
+ // StageSecondHalf in second half
41
+ StageSecondHalf Stage = "Second Half"
42
+ // StageOvertimeBreak in break to overtime
43
+ StageOvertimeBreak Stage = "Overtime Break"
44
+ // StageOvertimeFirstHalfPre before first overtime half
45
+ StageOvertimeFirstHalfPre Stage = "Pre-Overtime First Half"
46
+ // StageOvertimeFirstHalf in first overtime half
47
+ StageOvertimeFirstHalf Stage = "Overtime First Half"
48
+ // StageOvertimeHalfTime in overtime half time
49
+ StageOvertimeHalfTime Stage = "Overtime Half Time"
50
+ // StageOvertimeSecondHalfPre before second overtime half
39
51
StageOvertimeSecondHalfPre Stage = "Pre-Overtime Second Half"
40
- StageOvertimeSecondHalf Stage = "Overtime Second Half"
41
- StageShootoutBreak Stage = "Shootout Half Time"
42
- StageShootout Stage = "Shootout"
43
- StagePostGame Stage = "End of Game"
52
+ // StageOvertimeSecondHalf in second overtime half
53
+ StageOvertimeSecondHalf Stage = "Overtime Second Half"
54
+ // StageShootoutBreak in break to shootout
55
+ StageShootoutBreak Stage = "Shootout Break"
56
+ // StageShootout in Shootout
57
+ StageShootout Stage = "Shootout"
58
+ // StagePostGame after game ended
59
+ StagePostGame Stage = "End of Game"
44
60
)
45
61
46
- // all available stages, ordered
62
+ // Stages include all available stages, ordered
47
63
var Stages = []Stage {
48
64
StagePreGame ,
49
65
StageFirstHalf ,
@@ -61,20 +77,27 @@ var Stages = []Stage{
61
77
StagePostGame ,
62
78
}
63
79
64
- // a game state of a game
80
+ // GameState of a game
65
81
type GameState string
66
82
67
83
const (
68
- GameStateHalted GameState = "Halted"
69
- GameStateStopped GameState = "Stopped"
70
- GameStateRunning GameState = "Running"
71
- GameStatePreKickoff GameState = "Prepare Kickoff"
72
- GameStatePrePenalty GameState = "Prepare Penalty"
73
- GameStateTimeout GameState = "Timeout"
84
+ // GameStateHalted halted
85
+ GameStateHalted GameState = "Halted"
86
+ // GameStateStopped stopped
87
+ GameStateStopped GameState = "Stopped"
88
+ // GameStateRunning running
89
+ GameStateRunning GameState = "Running"
90
+ // GameStatePreKickoff kickoff
91
+ GameStatePreKickoff GameState = "Prepare Kickoff"
92
+ // GameStatePrePenalty penalty
93
+ GameStatePrePenalty GameState = "Prepare Penalty"
94
+ // GameStateTimeout timeout
95
+ GameStateTimeout GameState = "Timeout"
96
+ // GameStateBallPlacement ball placement
74
97
GameStateBallPlacement GameState = "Ball Placement"
75
98
)
76
99
77
- // team information
100
+ // TeamInfo about a team
78
101
type TeamInfo struct {
79
102
Name string `json:"name"`
80
103
Goals int `json:"goals"`
@@ -87,7 +110,7 @@ type TeamInfo struct {
87
110
OnPositiveHalf bool `json:"onPositiveHalf"`
88
111
}
89
112
90
- // the state of the game
113
+ // State of the game
91
114
type State struct {
92
115
Stage Stage `json:"stage"`
93
116
GameState GameState `json:"gameState"`
@@ -98,8 +121,8 @@ type State struct {
98
121
TeamState map [Team ]* TeamInfo `json:"teamState"`
99
122
}
100
123
101
- // create a new state, initialized for the start of a new game
102
- func NewRefBoxState (config Config ) (refBoxState * State ) {
124
+ // NewState creates a new state, initialized for the start of a new game
125
+ func NewState (config Config ) (refBoxState * State ) {
103
126
refBoxState = new (State )
104
127
refBoxState .Stage = StagePreGame
105
128
refBoxState .GameState = GameStateHalted
@@ -112,14 +135,14 @@ func NewRefBoxState(config Config) (refBoxState *State) {
112
135
refBoxState .TeamState = map [Team ]* TeamInfo {}
113
136
refBoxState .TeamState [TeamYellow ] = new (TeamInfo )
114
137
refBoxState .TeamState [TeamBlue ] = new (TeamInfo )
115
- * refBoxState .TeamState [TeamYellow ] = NewTeamInfo (config )
116
- * refBoxState .TeamState [TeamBlue ] = NewTeamInfo (config )
138
+ * refBoxState .TeamState [TeamYellow ] = newTeamInfo (config )
139
+ * refBoxState .TeamState [TeamBlue ] = newTeamInfo (config )
117
140
refBoxState .TeamState [TeamBlue ].OnPositiveHalf = ! refBoxState .TeamState [TeamYellow ].OnPositiveHalf
118
141
119
142
return
120
143
}
121
144
122
- func NewTeamInfo (config Config ) (t TeamInfo ) {
145
+ func newTeamInfo (config Config ) (t TeamInfo ) {
123
146
t .Name = ""
124
147
t .Goals = 0
125
148
t .Goalie = 0
0 commit comments