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
//! map-related information

use std::collections::HashMap;

use serde::{Serialize, Deserialize};

/// map information
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Map {
    /// current number of spectators
    pub current_spectators: u64,
    /// game mode
    pub mode: Mode,
    /// map name
    pub name: String,
    /// number of matches to win series
    pub num_matches_to_win_series: u64,
    /// map phase
    pub phase: Phase,
    /// current round number
    pub round: u64,
    /// who won which round and how
    #[serde(default)]
    pub round_wins: HashMap<u64, RoundWin>,
    /// number of souvenirs dropped so far this map (presumably)
    pub souvenirs_total: u64,
    /// counter-terrorist team info
    pub team_ct: Team,
    /// terrorist team info
    pub team_t: Team,
}

/// game mode
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Mode {
    /// competitive
    Competitive,
    /// casual
    Casual,
    /// deathmatch
    Deathmatch,
    /// the tutorial
    Training,
    /// demolition
    #[serde(rename = "gungametrbomb")]
    Demolition,
    /// arms race
    #[serde(rename = "gungameprogressive")]
    ArmsRace,
    /// wingman
    #[serde(rename = "scrimcomp2v2")]
    Wingman,
}

/// map phase
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Phase {
    /// warmup
    Warmup,
    /// in game
    Live,
    /// halftime
    Intermission,
    /// game over
    GameOver,
}

/// information about who won and how
/// ("ct_win_time", "t_win_bomb", "ct_win_elimination", "ct_win_defuse", etc)
/// (TODO actually parse)
pub type RoundWin = String;

/// team info
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Team {
    /// rounds won
    pub score: u64,
    /// rounds lost in a row
    pub consecutive_round_losses: u64,
    /// timeouts remaining
    pub timeouts_remaining: u64,
    /// matches won this series
    pub matches_won_this_series: u64,
    /// team name
    pub name: Option<String>,
    /// flag code (TODO find options)
    pub flag: Option<String>,
}