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
//use crate::client::Client;
//use crate::error::ApiError;
//use crate::utils::ids_to_string;
//use std::collections::HashMap;
//
//const ENDPOINT_URL: &str = "/v2/pvp/seasons";
//
///// Information about a structured PvP season.
//#[derive(Debug, Deserialize, PartialEq)]
//pub struct Season {
// /// UUID of the season.
// id: String,
// /// Given name of the PvP season.
// name: String,
// /// Timestamp of when the season started.
// #[serde(rename = "start")]
// start_time: String,
// /// Timestamp of when the season ends.
// #[serde(rename = "end")]
// end_time: String,
// /// Whether or not the season is currently active.
// active: bool,
// /// A `Vec` of the divisions in the season.
// divisions: Vec<Division>,
// /// A `Vec` containing the leaderboard(s) of the season.
// leaderboards: HashMap<LeaderboardType, Leaderboard>,
//}
//
///// A division in a structured PvP season.
//#[derive(Debug, Deserialize, PartialEq)]
//pub struct Division {
// /// Name of the division.
// name: String,
// /// Flags applying to the division.
// #[serde(default)]
// flags: Vec<Flag>,
// /// Potential url to a large version of the division's icon.
// #[serde(rename = "large_icon")]
// large_icon_url: Option<String>,
// /// Potential url to a small version of the division's icon.
// #[serde(rename = "small_icon")]
// small_icon_url: Option<String>,
// /// Url to the pip icon used for the division.
// #[serde(rename = "pip_icon")]
// pip_icon_url: String,
// /// A `Vec` of tiers in the division, containing how many pips are required for each tier.
// /// Number of tiers in the `Vec` indicates how many tiers there are.
// tiers: Vec<Tier>,
//}
//
///// Flags that describe what can happen to a division.
//#[derive(Debug, Deserialize, PartialEq)]
//pub enum Flag {
// CanLosePoints,
// CanLoseTiers,
// Repeatable,
//}
//
//#[derive(Debug, Deserialize, PartialEq)]
//pub struct Tier {
// #[serde(alias = "rating")]
// points: u32,
//}
//
///// The different leaderboard types that can be returned from the API.
///// Legendary and Guild were used during season 1-4, then replaced by Ladder.
//#[derive(Debug, Deserialize, PartialEq, Hash, Eq)]
//pub enum LeaderboardType {
// #[serde(rename = "legendary")]
// Legendary(Leaderboard),
// #[serde(rename = "guild")]
// Guild(Leaderboard),
// #[serde(rename = "ladder")]
// Ladder(Leaderboard),
//}
//
///// Contains details on an SPvP leaderboard.
//#[derive(Debug, Deserialize, PartialEq, Hash, Eq)]
//pub struct Leaderboard {
// settings: Settings,
// scorings: Vec<Scoring>,
//}
//
//#[derive(Debug, Deserialize, PartialEq, Hash, Eq)]
//pub struct Settings {
// /// Name of something, that is supposedly always empty.
// #[serde(default)]
// name: String,
// /// Duration of something, that seems to always be null.
// #[serde(default)]
// duration: Option<u32>,
// /// A UUID that indicates the primary scoring component? XXX: Needs verification.
// scoring: String,
// /// Ranges of leaderboard ranks which gives out certain rewards, like titles.
// tiers: Vec<Tiers>,
//}
//
///// Reference to select player/guild scoring methods.
//#[derive(Debug, Deserialize, PartialEq, Hash, Eq)]
//pub struct Scoring {
// /// UUID for the scoring method.
// id: String,
// /// Type which the content is saved as.
// #[serde(rename = "type")]
// content_type: String,
// /// Description of the scoring method.
// description: String,
// /// Name of the scoring method, e.g "wins", "losses", or "skill_rating".
// #[serde(default)]
// name: String,
// /// How the scoring is ordered.
// ordering: String,
//}
//
///// Contains ranges of leaderboard ranks, where the first value is the lowest rank and the second
///// is the highest rank of the range.
//#[derive(Debug, Deserialize, PartialEq)]
//pub struct Tiers {
// range: Vec<f32>,
//}
////
//impl Season {
// /// Retrieves all available season ids.
// pub fn get_all_ids(client: &Client) -> Result<u32, ApiError> {
// client.request(ENDPOINT_URL)
// }
//
// /// Retrieves a certain season's information by its id.
// pub fn get_id(client: &Client, id: u32) -> Result<Season, ApiError> {
// let url = format!("{}?ids={}", ENDPOINT_URL, id);
// client.request(&url)
// }
//
// /// Retrives seasons' information by their ids.
// pub fn get_seasons_by_ids(client: &Client, ids: Vec<String>) -> Result<Vec<Season>, ApiError> {
// let url = format!("{}?ids={}", ENDPOINT_URL, ids_to_string(ids));
// client.request(&url)
// }
//
// /// Retrives all seasons.
// pub fn get_all_seasons(client: &Client) -> Result<Vec<Season>, ApiError> {
// let url = format!("{}?ids=all", ENDPOINT_URL);
// client.request(&url)
// }
//
// /// Returns the requested id of the hero.
// pub fn id(&self) -> &str {
// &self.id
// }
//
// /// Returns the name of the season.
// pub fn name(&self) -> &str {
// &self.name
// }
//}
//
//#[cfg(test)]
//mod tests {
// use crate::v2::pvp::seasons::*;
// use crate::client::Client;
//
// const JSON_SEASON: &str = r#"
// {
// "id": "44B85826-B5ED-4890-8C77-82DDF9F2CF2B",
// "name": "PvP League Season One",
// "start": "2015-12-01T20:00:00.000Z",
// "end": "2016-01-28T01:00:00.000Z",
// "active": false,
// "divisions": [
// {
// "name": "Division 5: Diamond",
// "flags": [
// "CanLosePoints",
// "CanLoseTiers"
// ],
// "large_icon": "https://render.guildwars2.com/file/B59BEBA950BA90083D409DE42BA8789F300F305D/1313338.png",
// "small_icon": "https://render.guildwars2.com/file/F40A6880FB80C53F39D32B021737256371BE26B6/1313344.png",
// "pip_icon": "https://render.guildwars2.com/file/F8E6757D23AA4495CDC9AE28E1B1FEB844BD2B1A/1313350.png",
// "tiers": [
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// }
// ]
// },
// {
// "name": "Division 6: Legendary",
// "flags": [
// "CanLosePoints",
// "CanLoseTiers",
// "Repeatable"
// ],
// "large_icon": "https://render.guildwars2.com/file/97E44C1BB3B7434639D470E9F25DD9C601ACEDD9/1313339.png",
// "small_icon": "https://render.guildwars2.com/file/540530F225A8B39990DBB165227A0624F10DFF9A/1313345.png",
// "pip_icon": "https://render.guildwars2.com/file/7BD522452275401F6C9EE2C29F08DAEC0C52F144/1313351.png",
// "tiers": [
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// }
// ]
// }
// ],
// "leaderboards": {
// "guild": {
// "settings": {
// "name": "",
// "duration": null,
// "scoring": "16F74226-5DDF-4FE7-ADC5-72A49DA30572",
// "tiers": [
// {
// "color": "\#E5E4E2",
// "type": "Rank",
// "name": "Platinum",
// "range": [
// 1,
// 1
// ]
// },
// {
// "color": "\#EAC117",
// "type": "Rank",
// "name": "Gold",
// "range": [
// 25,
// 2
// ]
// },
// {
// "color": "\#C0C0C0",
// "type": "Rank",
// "name": "Silver",
// "range": [
// 100,
// 26
// ]
// },
// {
// "color": "\#D2691E",
// "type": "Rank",
// "name": "Bronze",
// "range": [
// 250,
// 101
// ]
// },
// {
// "color": "\#C87533",
// "type": "Rank",
// "name": "Copper",
// "range": [
// 1000,
// 251
// ]
// }
// ]
// },
// "scorings": [
// {
// "id": "16F74226-5DDF-4FE7-ADC5-72A49DA30572",
// "type": "Integer",
// "description": "Team rating represents your team's skill level.",
// "name": "Skill Rating",
// "ordering": "MoreIsBetter"
// },
// {
// "id": "9A9CB2FD-7D73-4DFE-8FDD-A97A9C7C0B0C",
// "type": "Integer",
// "description": "",
// "name": "Wins",
// "ordering": "MoreIsBetter"
// },
// {
// "id": "9064DD25-2C75-48D6-88C9-7FAD18DC784D",
// "type": "Integer",
// "description": "",
// "name": "Losses",
// "ordering": "LessIsBetter"
// }
// ]
// },
// "legendary": {
// "settings": {
// "name": "",
// "duration": null,
// "scoring": "E6487336-4B5B-4BFA-9CFA-9FF232CAEF85",
// "tiers": [
// {
// "range": [
// 1,
// 0.95
// ]
// },
// {
// "range": [
// 0.95,
// 0.9
// ]
// },
// {
// "range": [
// 0.9,
// 0.75
// ]
// }
// ]
// },
// "scorings": [
// {
// "id": "E6487336-4B5B-4BFA-9CFA-9FF232CAEF85",
// "type": "Integer",
// "description": "Current prestige rank. Prestige rank can be gained or lost by winning or losing ranked matches in the legendary division.",
// "name": "Prestige",
// "ordering": "MoreIsBetter"
// }
// ]
// }
// }
// }"#;
//
// const JSON_DIVISION: &str = r#"
// {
// "name": "Division 5: Diamond",
// "flags": [
// "CanLosePoints",
// "CanLoseTiers"
// ],
// "large_icon": "https://render.guildwars2.com/file/B59BEBA950BA90083D409DE42BA8789F300F305D/1313338.png",
// "small_icon": "https://render.guildwars2.com/file/F40A6880FB80C53F39D32B021737256371BE26B6/1313344.png",
// "pip_icon": "https://render.guildwars2.com/file/F8E6757D23AA4495CDC9AE28E1B1FEB844BD2B1A/1313350.png",
// "tiers": [
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// },
// {
// "points": 5
// }
// ]
// }"#;
//
// const JSON_SCORING: &str = r#"
// {
// "id": "E6487336-4B5B-4BFA-9CFA-9FF232CAEF85",
// "type": "Integer",
// "description": "Current prestige rank. Prestige rank can be gained or lost by winning or losing ranked matches in the legendary division.",
// "name": "Prestige",
// "ordering": "MoreIsBetter"
// }"#;
//
// const JSON_SETTING: &str = r#"
// {
// "name": "",
// "duration": null,
// "scoring": "E6487336-4B5B-4BFA-9CFA-9FF232CAEF85",
// "tiers": [
// {
// "range": [
// 1,
// 0.95
// ]
// },
// {
// "range": [
// 0.95,
// 0.9
// ]
// },
// {
// "range": [
// 0.9,
// 0.75
// ]
// }
// ]
// }
// "#;
//
// #[test]
// fn create_division() {
// match serde_json::from_str::<Division>(JSON_DIVISION) {
// Ok(_) => assert!(true),
// Err(e) => panic!(e.to_string()),
// }
// }
//
// #[test]
// fn create_scoring() {
// match serde_json::from_str::<Scoring>(JSON_SCORING) {
// Ok(_) => assert!(true),
// Err(e) => panic!(e.to_string()),
// }
// }
//
// #[test]
// fn create_setting() {
// match serde_json::from_str::<Settings>(JSON_SETTING) {
// Ok(_) => assert!(true),
// Err(e) => panic!(e.to_string()),
// }
// }
//
// #[test]
// fn create_season() {
// match serde_json::from_str::<Season>(JSON_SEASON) {
// Ok(_) => assert!(true),
// Err(e) => panic!(e.to_string()),
// }
// }
//}
//