bw_web_api_rs/models/
map_stats.rs1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
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(
32 &self,
33 gamemode: &str,
34 season: &str,
35 map_hash: &str,
36 ) -> Option<&MapRaceStats> {
37 self.map_stat.get(gamemode)?.get(season)?.get(map_hash)
38 }
39}