-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.rs
609 lines (586 loc) · 12.9 KB
/
player.rs
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
use crate::models::global_enums::{Activity, Boss, Skill};
use crate::models::global_types::PlayerId;
use crate::models::snapshot::{Activities, Bosses, Computed, Skills};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
/// [Player Type](https://docs.wiseoldman.net/players-api/player-type-definitions#enum-player-type)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum PlayerType {
Unknown,
Regular,
Ironman,
Hardcore,
Ultimate,
}
/// [Player Build](https://docs.wiseoldman.net/players-api/player-type-definitions#enum-player-build)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum PlayerBuild {
Main,
F2p,
Lvl3,
Zerker,
Def1,
Hp10,
F2pLvl3,
}
/// [Player Status](https://docs.wiseoldman.net/players-api/player-type-definitions#enum-player-status)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum PlayerStatus {
Active,
Unranked,
Flagged,
Archived,
Banned,
}
/// [Country](https://docs.wiseoldman.net/players-api/player-type-definitions#enum-country)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Country {
AD,
AE,
AF,
AG,
AI,
AL,
AM,
AO,
AQ,
AR,
AS,
AT,
AU,
AW,
AX,
AZ,
BA,
BB,
BD,
BE,
BF,
BG,
BH,
BI,
BJ,
BL,
BM,
BN,
BO,
BQ,
BR,
BS,
BT,
BV,
BW,
BY,
BZ,
CA,
CC,
CD,
CF,
CG,
CH,
CI,
CK,
CL,
CM,
CN,
CO,
CR,
CU,
CV,
CW,
CX,
CY,
CZ,
DE,
DJ,
DK,
DM,
DO,
DZ,
EC,
EE,
EG,
EH,
ER,
ES,
ET,
FI,
FJ,
FK,
FM,
FO,
FR,
GA,
GB,
GD,
GE,
GF,
GG,
GH,
GI,
GL,
GM,
GN,
GP,
GQ,
GR,
GS,
GT,
GU,
GW,
GY,
HK,
HM,
HN,
HR,
HT,
HU,
ID,
IE,
IL,
IM,
IN,
IO,
IQ,
IR,
IS,
IT,
JE,
JM,
JO,
JP,
KE,
KG,
KH,
KI,
KM,
KN,
KP,
KR,
KW,
KY,
KZ,
LA,
LB,
LC,
LI,
LK,
LR,
LS,
LT,
LU,
LV,
LY,
MA,
MC,
MD,
ME,
MF,
MG,
MH,
MK,
ML,
MM,
MN,
MO,
MP,
MQ,
MR,
MS,
MT,
MU,
MV,
MW,
MX,
MY,
MZ,
NA,
NC,
NE,
NF,
NG,
NI,
NL,
NO,
NP,
NR,
NU,
NZ,
OM,
PA,
PE,
PF,
PG,
PH,
PK,
PL,
PM,
PN,
PR,
PS,
PT,
PW,
PY,
QA,
RE,
RO,
RS,
RU,
RW,
SA,
SB,
SC,
SD,
SE,
SG,
SH,
SI,
SJ,
SK,
SL,
SM,
SN,
SO,
SR,
SS,
ST,
SV,
SX,
SY,
SZ,
TC,
TD,
TF,
TG,
TH,
TJ,
TK,
TL,
TM,
TN,
TO,
TR,
TT,
TV,
TW,
TZ,
UA,
UG,
UM,
US,
UY,
UZ,
VA,
VC,
VE,
VG,
VI,
VN,
VU,
WF,
WS,
YE,
YT,
ZA,
ZM,
ZW,
}
/// [Achievement Measure](https://docs.wiseoldman.net/players-api/player-type-definitions#enum-achievement-measure)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum AchievementMeasure {
Levels,
Experience,
Kills,
Score,
Value,
}
/// [SnapShot Data Values](https://docs.wiseoldman.net/players-api/player-type-definitions#object-snapshot-data-values)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SnapShotData {
pub skills: Skills,
pub bosses: Bosses,
pub activities: Activities,
pub computed: Computed,
}
/// [SnapShot](https://docs.wiseoldman.net/players-api/player-type-definitions#object-snapshot)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SnapShot {
id: i64,
player_id: i64,
created_at: DateTime<Utc>,
imported_at: Option<DateTime<Utc>>,
data: SnapShotData,
}
/// [Player](https://docs.wiseoldman.net/players-api/player-type-definitions#object-player)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Player {
pub id: PlayerId,
pub username: String,
pub display_name: String,
#[serde(rename = "type")]
pub player_type: PlayerType,
pub build: PlayerBuild,
pub country: Option<Country>,
pub status: PlayerStatus,
pub patron: bool,
pub exp: i64,
pub ehp: f64,
pub ehb: f64,
pub ttm: f64,
pub tt200m: f64,
pub registered_at: String,
pub updated_at: Option<DateTime<Utc>>,
pub last_changed_at: Option<DateTime<Utc>>,
pub last_imported_at: Option<DateTime<Utc>>,
}
/// [Player Details](https://docs.wiseoldman.net/players-api/player-type-definitions#object-player-details)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlayerDetails {
pub id: PlayerId,
pub username: String,
pub display_name: String,
#[serde(rename = "type")]
pub player_type: PlayerType,
pub build: PlayerBuild,
pub country: Option<Country>,
pub status: PlayerStatus,
pub patron: bool,
pub exp: i64,
pub ehp: f64,
pub ehb: f64,
pub ttm: f64,
pub tt200m: f64,
pub registered_at: String,
pub updated_at: Option<DateTime<Utc>>,
pub last_changed_at: Option<DateTime<Utc>>,
pub last_imported_at: Option<DateTime<Utc>>,
pub combat_level: i64,
pub archive: Option<PlayerArchive>,
pub latest_snapshot: Option<SnapShot>,
}
/// [Achievement](https://docs.wiseoldman.net/players-api/player-type-definitions#object-achievement)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Achievement {
player_id: i64,
name: String,
metric: String,
measure: AchievementMeasure,
threshold: i64,
created_at: DateTime<Utc>,
accuracy: Option<i64>,
}
/// [Achievement Progress](https://docs.wiseoldman.net/players-api/player-type-definitions#object-achievement-progress)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AchievementProgress {
player_id: PlayerId,
name: String,
metric: String,
measure: AchievementMeasure,
threshold: i64,
created_at: Option<DateTime<Utc>>,
accuracy: Option<i64>,
current_value: i64,
absolute_progress: f64,
relative_progress: f64,
}
/// [Player Archive](https://docs.wiseoldman.net/players-api/player-type-definitions#object-player-archive)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlayerArchive {
pub player_id: PlayerId,
pub previous_username: String,
pub archive_username: String,
pub restored_username: Option<String>,
pub created_at: DateTime<Utc>,
pub restored_at: Option<DateTime<Utc>>,
/// [Player Archive With Player](https://docs.wiseoldman.net/players-api/player-type-definitions#object-player-archive-with-player)
pub player: Option<Player>,
}
/// Same as [Player] but has changed to signify if the player was changed with assertion
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssertPlayerType {
pub player: Player,
pub changed: bool,
}
/// Represents a player's gains
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlayerGain {
pub starts_at: Option<DateTime<Utc>>,
pub ends_at: Option<DateTime<Utc>>,
pub data: PlayerGainData,
}
/// The data of the player's gains
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlayerGainData {
pub skills: SkillGains,
pub bosses: BossGains,
pub activities: ActivityGains,
}
/// The gains of a player's skills
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SkillGains {
pub overall: SkillGain,
pub attack: SkillGain,
pub defence: SkillGain,
pub strength: SkillGain,
pub hitpoints: SkillGain,
pub ranged: SkillGain,
pub prayer: SkillGain,
pub magic: SkillGain,
pub cooking: SkillGain,
pub woodcutting: SkillGain,
pub fletching: SkillGain,
pub fishing: SkillGain,
pub firemaking: SkillGain,
pub crafting: SkillGain,
pub smithing: SkillGain,
pub mining: SkillGain,
pub herblore: SkillGain,
pub agility: SkillGain,
pub thieving: SkillGain,
pub slayer: SkillGain,
pub farming: SkillGain,
pub runecrafting: SkillGain,
pub hunter: SkillGain,
pub construction: SkillGain,
}
/// The gains of a player's skill
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SkillGain {
pub metric: Skill,
pub experience: GainProgress,
pub ehp: GainProgress,
pub rank: GainProgress,
pub level: GainProgress,
}
/// The gains of a player's bosses
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct BossGains {
pub abyssal_sire: BossGain,
pub alchemical_hydra: BossGain,
pub artio: BossGain,
pub barrows_chests: BossGain,
pub bryophyta: BossGain,
pub callisto: BossGain,
pub calvarion: BossGain,
pub cerberus: BossGain,
pub chambers_of_xeric: BossGain,
pub chambers_of_xeric_challenge_mode: BossGain,
pub chaos_elemental: BossGain,
pub chaos_fanatic: BossGain,
pub commander_zilyana: BossGain,
pub corporeal_beast: BossGain,
pub crazy_archaeologist: BossGain,
pub dagannoth_prime: BossGain,
pub dagannoth_rex: BossGain,
pub dagannoth_supreme: BossGain,
pub deranged_archaeologist: BossGain,
pub duke_sucellus: BossGain,
pub general_graardor: BossGain,
pub giant_mole: BossGain,
pub grotesque_guardians: BossGain,
pub hespori: BossGain,
pub kalphite_queen: BossGain,
pub king_black_dragon: BossGain,
pub kraken: BossGain,
pub kreearra: BossGain,
pub kril_tsutsaroth: BossGain,
pub mimic: BossGain,
pub nex: BossGain,
pub nightmare: BossGain,
pub phosanis_nightmare: BossGain,
pub obor: BossGain,
pub phantom_muspah: BossGain,
pub sarachnis: BossGain,
pub scorpia: BossGain,
pub scurrius: BossGain,
pub skotizo: BossGain,
pub spindel: BossGain,
pub tempoross: BossGain,
pub the_gauntlet: BossGain,
pub the_corrupted_gauntlet: BossGain,
pub the_leviathan: BossGain,
pub the_whisperer: BossGain,
pub theatre_of_blood: BossGain,
pub theatre_of_blood_hard_mode: BossGain,
pub thermonuclear_smoke_devil: BossGain,
pub tombs_of_amascut: BossGain,
pub tombs_of_amascut_expert: BossGain,
pub tzkal_zuk: BossGain,
pub tztok_jad: BossGain,
pub vardorvis: BossGain,
pub venenatis: BossGain,
pub vetion: BossGain,
pub vorkath: BossGain,
pub wintertodt: BossGain,
pub zalcano: BossGain,
pub zulrah: BossGain,
}
/// The gains of a player's boss
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BossGain {
pub metric: Boss,
pub ehb: GainProgress,
pub rank: GainProgress,
pub kills: GainProgress,
}
/// The gains of a player's activities
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ActivityGains {
pub league_points: Option<ActivityGain>,
pub bounty_hunter_hunter: Option<ActivityGain>,
pub bounty_hunter_rogue: Option<ActivityGain>,
pub clue_scrolls_all: Option<ActivityGain>,
pub clue_scrolls_beginner: Option<ActivityGain>,
pub clue_scrolls_easy: Option<ActivityGain>,
pub clue_scrolls_medium: Option<ActivityGain>,
pub clue_scrolls_hard: Option<ActivityGain>,
pub clue_scrolls_elite: Option<ActivityGain>,
pub clue_scrolls_master: Option<ActivityGain>,
pub last_man_standing: Option<ActivityGain>,
pub pvp_arena: Option<ActivityGain>,
pub soul_wars_zeal: Option<ActivityGain>,
pub guardians_of_the_rift: Option<ActivityGain>,
}
/// The gains of a player's activity
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ActivityGain {
pub metric: Activity,
pub score: GainProgress,
pub rank: GainProgress,
}
/// Each metrics gain progress.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GainProgress {
pub gained: f64,
pub start: f64,
pub end: f64,
}
/// [Timeline Datapoint](https://docs.wiseoldman.net/players-api/player-type-definitions#object-timeline-datapoint)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TimelineDatapoint {
pub value: f64,
pub rank: i64,
pub date: DateTime<Utc>,
}