-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathmodels.go
78 lines (66 loc) · 1.91 KB
/
models.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
// API Objects
// https://docs.battlesnake.com/api
type Coord struct {
X int `json:"x"`
Y int `json:"y"`
}
type Battlesnake struct {
ID string `json:"id"`
Name string `json:"name"`
Health int `json:"health"`
Body []Coord `json:"body"`
Head Coord `json:"head"`
Length int `json:"length"`
Latency string `json:"latency"`
Shout string `json:"shout"`
Customizations Customizations `json:"customizations"`
}
type Customizations struct {
Color string `json:"color"`
Head string `json:"head"`
Tail string `json:"tail"`
}
type Board struct {
Height int `json:"height"`
Width int `json:"width"`
Food []Coord `json:"food"`
Hazards []Coord `json:"hazards"`
Snakes []Battlesnake `json:"snakes"`
}
type GameState struct {
Game Game `json:"game"`
Turn int `json:"turn"`
Board Board `json:"board"`
You Battlesnake `json:"you"`
}
type Game struct {
ID string `json:"id"`
Ruleset Ruleset `json:"ruleset"`
Map string `json:"map"`
Source string `json:"source"`
Timeout int `json:"timeout"`
}
type Ruleset struct {
Name string `json:"name"`
Version string `json:"version"`
Settings RulesetSettings `json:"settings"`
}
type RulesetSettings struct {
FoodSpawnChance int `json:"foodSpawnChance"`
MinimumFood int `json:"minimumFood"`
HazardDamagePerTurn int `json:"hazardDamagePerTurn"`
}
// Response Objects
// https://docs.battlesnake.com/api
type BattlesnakeInfoResponse struct {
APIVersion string `json:"apiversion"`
Author string `json:"author"`
Color string `json:"color"`
Head string `json:"head"`
Tail string `json:"tail"`
}
type BattlesnakeMoveResponse struct {
Move string `json:"move"`
Shout string `json:"shout"`
}