bw_web_api_rs/models/
map_stats.rs1use std::collections::HashMap;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize)]
5pub struct RaceStats {
6 pub total_games: u32,
7 pub total_global_games: u32,
8 pub total_global_wins: u32,
9 pub total_wins: u32,
10}
11
12#[derive(Debug, Serialize, Deserialize)]
13pub struct MapRaceStats {
14 #[serde(rename = "Protoss")]
15 pub protoss: RaceStats,
16 #[serde(rename = "Random")]
17 pub random: RaceStats,
18 #[serde(rename = "Terran")]
19 pub terran: RaceStats,
20 #[serde(rename = "Zerg")]
21 pub zerg: RaceStats,
22}
23
24#[derive(Debug, Serialize, Deserialize)]
25pub struct MapStatsByToon {
26 pub current_season: u32,
27 pub map_stat: HashMap<String, HashMap<String, HashMap<String, MapRaceStats>>>,
28}
29
30impl MapStatsByToon {
31 pub fn get_map_stats(&self, gamemode: &str, season: &str, map_hash: &str) -> Option<&MapRaceStats> {
32 self.map_stat
33 .get(gamemode)?
34 .get(season)?
35 .get(map_hash)
36 }
37}