generated from BattlesnakeOfficial/starter-snake-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
113 lines (100 loc) · 2.17 KB
/
types.ts
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
// API Types
// https://docs.battlesnake.com/api
/**
* @description An object containing cartesian coordinates
* */
export interface Coord {
x: number;
y: number;
}
export interface Battlesnake {
id: string;
name: string;
health: number;
/**
* @description Array of {@link Coord} representing this Battlesnake's location on the game board. This array is ordered from head to tail
* */
body: Coord[];
/**
* @description {@link Coord} for this Battlesnake's head. Equivalent to the first element of the body array
* @example {"x": 0, "y": 0}
* */
head: Coord;
length: number;
latency: string;
shout: string;
customizations: Customizations;
}
export interface Customizations {
/**
* @description Hex color code used to display this Battlesnake
* @example #888888
* */
color: string;
/**
* @description Displayed head of this Battlesnake
* */
head: string;
/**
* @description Displayed tail of this Battlesnake
* */
tail: string;
}
export interface Board {
/**
* @description The number of rows in the y-axis of the game board
* @example 11
* */
height: number;
width: number;
food: Coord[];
hazards: Coord[];
/**
* @description List of all Battlesnakes currently on the board (Including you if you haven't been eliminated)
* */
snakes: Battlesnake[];
}
export interface GameState {
game: Game;
turn: number;
board: Board;
you: Battlesnake;
}
export interface Game {
id: string;
ruleset: Ruleset;
map: string;
source: string;
timeout: number;
}
export interface Ruleset {
name: string;
version: string;
settings: RulesetSettings;
}
export interface RulesetSettings {
foodSpawnChance: number;
minimumFood: number;
hazardDamagePerTurn: number;
}
// Response Types
// https://docs.battlesnake.com/api
export interface InfoResponse {
apiversion: string;
author?: string;
color?: string;
head?: string;
tail?: string;
version?: string;
}
export interface MoveResponse {
move: Move;
shout?: string;
}
export enum Move {
Up = "up",
Down = "down",
Left = "left",
Right = "right"
}
export type SnakePositionMap = Record<string, Record<string, boolean>>;