-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
224 lines (198 loc) · 3.74 KB
/
types.d.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
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
declare namespace Game {
const enum Phase {
INITIALIZING = 'initializing',
CONNECTED = 'connected',
JOINED_LOBBY = 'joined_lobby',
PLAYING = 'playing',
}
const enum Type {
DUEL = '1v1',
FFA = 'ffa',
CUSTOM = 'custom',
}
interface State {
gamePhase: Game.Phase
gameType: Game.Type
replay_id: string
playerIndex: number | null
turn: number
usernames: string[] | null
scores: GeneralsIO.Score[] | null
won: boolean | null
}
}
declare namespace GeneralsIO {
interface QueueUpdate {
playerIndices: number[]
playerColors: number[]
lobbyIndex: number
isForcing: boolean
numPlayers: number
numForce: number[]
teams: number[]
usernames: string[]
options: {
chatRecordingDisabled?: boolean
game_speed?: number
}
}
interface GameStart {
playerIndex: number
replay_id: string
chat_room: string
team_chat_room: string
usernames: string[]
teams: number[]
game_type: Game.Type
}
interface GameUpdate {
turn: number
map_diff: number[]
cities_diff: number[]
generals: number[]
scores: Score[]
stars: number[]
}
interface GameLost {
killer: number
killer_name: string
replay_id: string
}
interface GameWon {
replay_id: string
}
interface ChatMessage {
username: string
playerIndex: number
text: string
}
interface StarsRanks {
duel?: number
ffa?: number
}
interface Score {
"total": number
"tiles": number
"i": number
"color": number
"dead": boolean
}
interface Attack {
start: number
end: number
is50?: boolean
}
interface Tile {
index: number
value: GeneralsIO.TILE
}
const enum TILE {
EMPTY = -1,
MOUNTAIN = -2,
FOG = -3,
FOG_OBSTACLE = -4, // Cities and Mountains show up as Obstacles in the fog of war.
OFF_LIMITS = -5
}
}
declare namespace RedisData {
declare namespace Command {
interface Join {
gameType: string
gameId?: string
}
interface Options {
customGameSpeed?: number
}
interface Any {
join?: Join
leave?: boolean
forceStart?: boolean
options?: Options
status?: boolean
}
}
interface Action {
interrupt: boolean
actions: Attack[]
}
interface Recommendation {
date: Date
recommender: string
confidence: number
priority: number
interrupt: boolean
actions: Attack[]
}
interface State {
connected?: string
disconnected?: string
game_start?: GeneralsIO.GameStart
game_lost?: GeneralsIO.GameLost
game_won?: GeneralsIO.GameWon
joined?: {
gameType: string
gameId?: string
}
left?: boolean
playing?: boolean
}
const enum CHANNEL {
COMMAND = 'command',
STATE = 'state',
GAME_UPDATE = 'gameUpdate',
ACTION = 'action',
RECOMMENDATION = 'recommendation',
DECONFLICT = 'deconflict',
TURN = 'turn',
DISCOVERY = 'discovery',
}
const enum KEY {
TURN = 'turn',
WIDTH = 'width',
HEIGHT = 'height',
SIZE = 'size',
TEAMS = 'teams',
SCORES = 'scores',
PLAYER_INDEX = 'playerIndex',
REPLAY_ID = 'replay_id',
USERNAMES = 'usernames',
CHAT_ROOM = 'chat_room',
ARMIES = 'armies',
TERRAIN = 'terrain',
CITIES = 'cities',
OWN_GENERAL = 'ownGeneral',
ENEMY_GENERAL = 'enemyGeneral',
OWN_TILES = 'ownTiles',
ENEMY_TILES = 'enemyTiles',
DISCOVERED_TILES = 'discoveredTiles',
}
const enum LIST {
SCORES = 'scores',
MAX_ARMY_ON_TILE = 'maxArmyOnTile',
MOVE_COUNT = 'moveCount',
REPLAYS = 'replays',
}
}
declare namespace Config {
interface Game {
GAME_SERVER_URL: string
GAME_WEBAPP_URL: string
MAX_TURNS: number
BOT_ID_PREFIX: string
userId: string
username: string
setUsername: boolean
customGameId: string
customGameSpeed: number
warCry: string[]
}
interface Redis {
HOST: string
PORT: number
USERNAME: string
PASSWORD: string
TLS: boolean
CHANNEL_PREFIX: string
EXPIRATION_TIME: number
}
}