-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.d.ts
More file actions
279 lines (237 loc) · 6.03 KB
/
types.d.ts
File metadata and controls
279 lines (237 loc) · 6.03 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
import { Request } from 'express'
export interface Game {
/**
* A unique identifier for this Game.
* Example: "totally-unique-game-id"
*/
id: string
/**
* Information about the ruleset being used to run this game.
* Example: {"name": "standard", "version": "v1.2.3"}
*/
ruleset?: { name: string; version: string }
/**
* How much time your snake has to respond to
* requests for this Game in milliseconds (integer).
* Example: 500
*/
timeout: number
}
export interface Coordinates {
/**
* An x-coordinate on the board (integer).
* Example: 1
*/
x: number
/**
* An y-coordinate on the board (integer).
* Example: 1
*/
y: number
}
export interface Snake {
/**
* Unique identifier for this Battlesnake in the context of the current Game.
* Example: "totally-unique-snake-id"
*/
id: string
/**
* Name given to this Battlesnake by its author.
* Example: "Sneky McSnek Face"
*/
name: string
/**
* Health value (integer) of this Battlesnake, between 0 and 100 inclusively.
* Example: 54
*/
health: number
/** Array of coordinates representing this Battlesnake's location on the game board.
* This array is ordered from head to tail.
* Example: [{"x": 0, "y": 0}, ..., {"x": 2, "y": 0}] */
body: Coordinates[]
/**
* The previous response time of this Battlesnake, in milliseconds.
* "0" means the Battlesnake timed out and failed to respond.
* Example: "450"
*/
latency: string
/**
* Coordinates for this Battlesnake's head.
* Equivalent to the first element of the body array.
* Example: {"x": 0, "y": 0}
*/
head: Coordinates
/**
* Length of this Battlesnake from head to tail.
* Equivalent to the length (integer) of the body array.
* Example: 3
*/
length: number
/**
* Message shouted by this Battlesnake on the previous turn.
* Example: "why are we shouting??"
*/
shout: string
/**
* The squad that the Battlesnake belongs to.
* Used to identify squad members in Squad Mode games.
* Example: "1"
*/
squad: string
}
export interface Board {
/**
* Height of the game board (integer).
* Example: 11
*/
height: number
/**
* Width of the game board (integer).
* Example: 11
*/
width: number
/**
* Array of coordinates representing food locations on the game board.
* Example: [{"x": 5, "y": 5}, ..., {"x": 2, "y": 6}]
*/
food: Coordinates[]
/**
* Array of coordinates representing hazardous locations on the game board.
* These will only appear in some game modes.
* Example: [{"x": 0, "y": 0}, ..., {"x": 0, "y": 1}]
*/
harzards: Coordinates[]
/**
* Array of Battlesnake Objects representing all Battlesnakes
* remaining on the game board (including yourself if you haven't been eliminated).
* Example: [{"id": "snake-one", ...}, ...]
*/
snakes: Snake[]
}
type Heads =
| StandardHeads
| WinterClassic2019Heads
| StayHomeAndCodeHeads
| FallLeague2020Heads
type StandardHeads =
| 'default'
| 'beluga'
| 'bendr'
| 'dead'
| 'evil'
| 'fang'
| 'pixel'
| 'sand-worm'
| 'safe'
| 'shades'
| 'silly'
| 'smile'
| 'tongue'
type WinterClassic2019Heads =
| 'bwc-bonhomme'
| 'bwc-earmuffs'
| 'bwc-rudolph'
| 'bwc-scarf'
| 'bwc-ski'
| 'bwc-snow-worm'
| 'bwc-snowman'
type StayHomeAndCodeHeads =
| 'shac-caffeine'
| 'shac-gamer'
| 'shac-workout'
| 'shac-tiger-king'
type FallLeague2020Heads = 'bfl-jackolantern' | 'bfl-pumpkin'
type Tails =
| StandardTails
| WinterClassic2019Tails
| StayHomeAndCodeTails
| FallLeague202Tails
type StandardTails =
| 'default'
| 'block-bum'
| 'bolt'
| 'curled'
| 'fat-rattle'
| 'freckle'
| 'hook'
| 'pixel'
| 'round-bum'
| 'sharp'
| 'skinny'
| 'small-rattle'
type WinterClassic2019Tails =
| 'bwc-bonhomme'
| 'bwc-flake'
| 'bwc-ice-skate'
| 'bwc-present'
type StayHomeAndCodeTails =
| 'shac-coffee'
| 'shac-mouse'
| 'shac-weight'
| 'shac-tiger-tail'
type FallLeague202Tails = 'bfl-leaf'
export interface SnakeInfo {
/**
* Version of the Battlesnake API implemented by this Battlesnake.
* Example: "1"
*/
apiversion: string
/** Username of the author of this Battlesnake.
* If provided, this will be used to verify ownership.
* Example: "BattlesnakeOfficial" */
author?: string
/**
* Hex color code used to display this Battlesnake.
* Must start with "#" and be 7 characters long.
* Example: "#888888" */
color?: string
/**
* Displayed head of this Battlesnake.
* See battlesnake.io docs for head images.
* Example: "default"
*/
head?: Heads
/**
* Displayed tail of this Battlesnake.
* See battlesnake.io docs for tail images.
* Example: "default" */
tail?: Tails
/**
* A version number or tag for your snake.
*/
version?: string
}
export interface GameState {
/**
* Game Object describing the game being played.
*/
game: Game
/**
* Turn number (integer) of the game being played (0 for new games).
*/
turn: number
/**
* Board Object describing the initial state of the game board.
*/
board: Board
/**
* Battlesnake Object describing your Battlesnake.
*/
you: Battlesnake
}
export type Direction = 'up' | 'left' | 'down' | 'right'
export interface Move {
/**
* Your Battlesnake's move for this turn.
* Valid moves are up, down, left, or right.
* Example: "up"
*/
move: Direction
/**
* An optional message sent to all other Battlesnakes
* on the next turn. Must be 256 characters or less.
* Example: "I am moving up!"
*/
shout?: string
}
export type GameRequest = Request<{}, {}, GameState>