-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_events.go
53 lines (40 loc) · 878 Bytes
/
game_events.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
package core
import "github.com/libp2p/go-libp2p-core/peer"
type Coord struct {
X, Y int
}
func EqualCoord(a, b Coord) bool {
return a.X == b.X && a.Y == b.Y
}
type PlayerStarts struct {
Players map[peer.ID]Coord // map from player's SnakeID to its start coordinates
}
type NewFood struct {
FoodID int
Pos Coord
}
type Direction int
const (
Up Direction = iota
Right
Down
Left
)
type PlayerMoves struct {
Moves map[peer.ID]Direction // map from player's SnakeID to direction of it's move
}
type PlayerDied struct {
SnakeID peer.ID // SnakeID of player who died
}
type FoodEaten struct {
FoodID int
}
type PushSegment struct {
SnakeID peer.ID
Pos Coord // coordinates of a cell to add to a snake
}
type Tick struct{}
type GameOver struct {
Successful bool // did game finish without errors or not
Winner int // SnakeID of winner player
}