Skip to content

Commit 574feff

Browse files
committed
[doc] Add documentation to UI protocol
1 parent bfb182e commit 574feff

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

internal/app/controller/uiProtocol.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ import (
55
"time"
66
)
77

8+
// UiProtocolType represents the type of a protocol entry
89
type UiProtocolType string
910

1011
const (
11-
UiProtocolCommand UiProtocolType = "command"
12-
UiProtocolStage UiProtocolType = "stage"
13-
UiProtocolCard UiProtocolType = "card"
14-
UiProtocolTime UiProtocolType = "time"
15-
UiProtocolGameEvent UiProtocolType = "gameEvent"
12+
// UiProtocolCommand represents an issued referee command
13+
UiProtocolCommand UiProtocolType = "command"
14+
// UiProtocolStage represents a changed stage
15+
UiProtocolStage UiProtocolType = "stage"
16+
// UiProtocolCard represents an issued card
17+
UiProtocolCard UiProtocolType = "card"
18+
// UiProtocolTime represents an elapsed time, like stage time or card time
19+
UiProtocolTime UiProtocolType = "time"
20+
// UiProtocolGameEvent represents an issued game event
21+
UiProtocolGameEvent UiProtocolType = "gameEvent"
22+
// UiProtocolGameEventIgnored represents a detected game event that was not issued
1623
UiProtocolGameEventIgnored UiProtocolType = "ignoredGameEvent"
17-
UiProtocolModify UiProtocolType = "modify"
24+
// UiProtocolModify represents a manual modification on the state
25+
UiProtocolModify UiProtocolType = "modify"
1826
)
1927

28+
// UiProtocolEntry represents a single protocol entry as should be displayed in the UI table
2029
type UiProtocolEntry struct {
2130
Timestamp int64 `json:"timestamp"`
2231
StageTime time.Duration `json:"stageTime"`
@@ -26,6 +35,7 @@ type UiProtocolEntry struct {
2635
Description string `json:"description"`
2736
}
2837

38+
// LogGameEvent adds a game event to the protocol
2939
func (e *Engine) LogGameEvent(event GameEvent) {
3040
entry := UiProtocolEntry{
3141
Timestamp: e.TimeProvider().UnixNano(),
@@ -38,6 +48,7 @@ func (e *Engine) LogGameEvent(event GameEvent) {
3848
e.UiProtocol = append(e.UiProtocol, entry)
3949
}
4050

51+
// LogIgnoredGameEvent adds an ignored game event to the protocol
4152
func (e *Engine) LogIgnoredGameEvent(event GameEvent) {
4253
entry := UiProtocolEntry{
4354
Timestamp: e.TimeProvider().UnixNano(),
@@ -50,6 +61,7 @@ func (e *Engine) LogIgnoredGameEvent(event GameEvent) {
5061
e.UiProtocol = append(e.UiProtocol, entry)
5162
}
5263

64+
// LogCommand adds a command to the protocol
5365
func (e *Engine) LogCommand() {
5466
entry := UiProtocolEntry{
5567
Timestamp: e.TimeProvider().UnixNano(),
@@ -61,6 +73,7 @@ func (e *Engine) LogCommand() {
6173
e.UiProtocol = append(e.UiProtocol, entry)
6274
}
6375

76+
// LogCard adds a card to the protocol
6477
func (e *Engine) LogCard(card *EventCard) {
6578
entry := UiProtocolEntry{
6679
Timestamp: e.TimeProvider().UnixNano(),
@@ -72,6 +85,7 @@ func (e *Engine) LogCard(card *EventCard) {
7285
e.UiProtocol = append(e.UiProtocol, entry)
7386
}
7487

88+
// LogTime adds a time event (like stage time ends or card time ends) to the protocol
7589
func (e *Engine) LogTime(description string, forTeam Team) {
7690
entry := UiProtocolEntry{
7791
Timestamp: e.TimeProvider().UnixNano(),
@@ -83,6 +97,7 @@ func (e *Engine) LogTime(description string, forTeam Team) {
8397
e.UiProtocol = append(e.UiProtocol, entry)
8498
}
8599

100+
// LogStage adds a stage change to the protocol
86101
func (e *Engine) LogStage(stage Stage) {
87102
entry := UiProtocolEntry{
88103
Timestamp: e.TimeProvider().UnixNano(),
@@ -93,6 +108,7 @@ func (e *Engine) LogStage(stage Stage) {
93108
e.UiProtocol = append(e.UiProtocol, entry)
94109
}
95110

111+
// LogModify adds a modification to the protocol
96112
func (e *Engine) LogModify(m EventModifyValue) {
97113
entry := UiProtocolEntry{
98114
Timestamp: e.TimeProvider().UnixNano(),

0 commit comments

Comments
 (0)