-
-
Notifications
You must be signed in to change notification settings - Fork 318
/
user.ts
241 lines (210 loc) · 4.78 KB
/
user.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import { Profile } from '~/session'
import { GameSource, GameStatus, ClockData, Opening } from './game'
export type GameFilter = 'all' | 'rated' | 'win' | 'loss' | 'draw' | 'bookmark' | 'me' | 'import' | 'playing'
export interface UserGamesCount {
readonly all: number
readonly rated: number
readonly ai: number
readonly draw: number
readonly drawH: number
readonly loss: number
readonly lossH: number
readonly win: number
readonly winH: number
readonly bookmark: number
readonly playing: number
readonly import: number
readonly me: number
readonly [index: string]: number
}
export interface UserFullProfile extends User {
readonly completionRate?: number
readonly nbFollowers: number
readonly nbFollowing: number
readonly playing: string
readonly count: UserGamesCount
readonly blocking?: boolean
readonly followable?: boolean
readonly following?: boolean
readonly followsYou?: boolean
readonly url: string
}
export interface Perf {
readonly rating: number
readonly rd: number
readonly prog: number
readonly games: number
readonly prov?: boolean
}
export interface LightUser {
readonly id: string
readonly name: string
readonly title?: string
readonly patron?: boolean
}
export interface BaseUser {
readonly id: string
readonly username: string
online?: boolean
readonly patron?: boolean
readonly title?: string
}
export interface User extends BaseUser {
readonly tosViolation?: boolean
readonly name?: string
readonly language: string
readonly rating?: number
readonly createdAt: Timestamp
readonly seenAt: Timestamp
readonly perfs: Perfs
readonly playTime?: PlayTime
readonly profile?: Profile
}
export interface SearchUser {
readonly id: string
readonly name: string
readonly online?: boolean
readonly patron?: boolean
readonly title?: string
}
export interface PlayTime {
readonly total: number
readonly tv: number
}
export type Perfs = {
readonly [pk: string]: Perf
}
export interface RankingUser extends BaseUser {
readonly perfs: Perfs
}
export type RankingKey = PerfKey | 'online'
export type Rankings = Record<RankingKey, ReadonlyArray<RankingUser>>
export interface UserGamePlayer {
readonly id?: string
readonly user?: LightUser
readonly name?: string
readonly aiLevel?: number
readonly rating?: number
readonly ratingDiff?: number
}
export interface UserGame {
readonly id: string
readonly rated: boolean
readonly variant: Variant
readonly speed: Speed
readonly perf: PerfKey
readonly timestamp: Timestamp
readonly turns: number
readonly status: GameStatus
readonly clock?: ClockData
readonly correspondence?: {
readonly daysPerTurn: number
}
readonly source?: GameSource
readonly players: {
readonly white: UserGamePlayer
readonly black: UserGamePlayer
}
readonly fen: string
readonly lastMove?: string
readonly opening?: Opening
readonly winner?: Color
readonly bookmarks: number
readonly bookmarked?: boolean
readonly analysed?: boolean
readonly tournament?: {
name: string
id: string
}
}
export interface UserGameWithDate extends UserGame {
date?: string
}
export type GraphPoint = [number, number, number, number]
interface StatCount {
all: number
rated: number
win: number
loss: number
draw: number
tour: number
berserk: number
opAvg: {avg: number, pop: number}
seconds: number
disconnects: number
}
interface StatGameAt {
at: string
gameId: string
}
interface StatPlayStreak {
nb: StatStreaks
time: StatStreaks
lastDate?: string
}
interface StatRatingAt {
int: number
at: string
gameId: string
}
interface StatResult {
opInt: number
opId: LightUser
at: string
gameId: string
}
interface StatResults {
results: StatResult[]
}
interface StatResultStreak {
win: StatStreaks
loss: StatStreaks
}
interface StatStreak {
v: number
from?: StatGameAt
to?: StatGameAt
}
interface StatStreaks {
cur: StatStreak
max: StatStreak
}
export interface Stats {
userId: unknown
perfType: unknown
highest?: StatRatingAt
lowest?: StatRatingAt
bestWins: StatResults
worstLosses: StatResults
count: StatCount
resultStreak: StatResultStreak
playStreak: StatPlayStreak
}
export interface PerfStats {
readonly user: LightUser
readonly perf: any
readonly rank: number
readonly percentile: number
readonly stat: Stats
readonly graph: ReadonlyArray<GraphPoint>
}
export type Relation = boolean
export interface Related {
readonly online: boolean
readonly perfs: Perfs
readonly patron: boolean
readonly user: string
readonly followable: boolean
relation: Relation
readonly title?: string
}
export interface Score {
readonly nbGames: number
readonly users: {
readonly [id: string]: number | undefined
}
}
export interface MiniUser {
crosstable: Score
perfs: Perfs
}