-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgameState.go
57 lines (48 loc) · 1.52 KB
/
gameState.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"time"
)
// For simplicity on the 8bit side (using switch statement), using a single character for each key.
// DOUBLE CHECK that letter isn't already in use on the object!
// Double characters are used for the list objects
// The json is then converted to a \0 separated list of key/values when &raw=1 is passed in
// for further optimization
type Player struct {
Name string `json:"n"`
Alias int `json:"a"`
Scores []int `json:"s"`
// Internal
id string
isBot bool
lastPing time.Time
isLeaving bool
isPenalized bool
isViewing bool
isSmart bool
}
type GameState struct {
// External (JSON)
Name string `json:"n"` // Name of server - sent on first connect
Prompt string `json:"p"`
Round int `json:"r"`
RollsLeft int `json:"l"`
ActivePlayer int `json:"a"`
MoveTime int `json:"m"`
Viewing int `json:"v"`
Dice string `json:"d"`
KeepRoll string `json:"k"`
ValidScores []int `json:"c"`
Players []Player `json:"pl"`
// Internal
gameOver bool
startedStartCountdown bool
prevTotalHumansNotReady int
clientPlayer int
moveExpires time.Time
botBox []Player // if players join to replace the bots, bots go here until a player leaves
// Meta/Lobby related
table string
serverName string
registerLobby bool
hash string // `json:"z"` // external later
}