csgo_gsi/update/
map.rs

1//! map-related information
2
3use std::collections::HashMap;
4
5use serde::{Serialize, Deserialize};
6
7/// map information
8#[derive(Clone, Debug, Deserialize, Serialize)]
9#[serde(deny_unknown_fields)]
10pub struct Map {
11    /// current number of spectators
12    pub current_spectators: u64,
13    /// game mode
14    pub mode: Mode,
15    /// map name
16    pub name: String,
17    /// number of matches to win series
18    pub num_matches_to_win_series: u64,
19    /// map phase
20    pub phase: Phase,
21    /// current round number
22    pub round: u64,
23    /// who won which round and how
24    #[serde(default)]
25    pub round_wins: HashMap<u64, RoundWin>,
26    /// number of souvenirs dropped so far this map (presumably)
27    pub souvenirs_total: u64,
28    /// counter-terrorist team info
29    pub team_ct: Team,
30    /// terrorist team info
31    pub team_t: Team,
32}
33
34/// game mode
35#[derive(Clone, Debug, Deserialize, Serialize)]
36#[serde(rename_all = "lowercase")]
37pub enum Mode {
38    /// competitive
39    Competitive,
40    /// casual
41    Casual,
42    /// deathmatch
43    Deathmatch,
44    /// the tutorial
45    Training,
46    /// demolition
47    #[serde(rename = "gungametrbomb")]
48    Demolition,
49    /// arms race
50    #[serde(rename = "gungameprogressive")]
51    ArmsRace,
52    /// wingman
53    #[serde(rename = "scrimcomp2v2")]
54    Wingman,
55}
56
57/// map phase
58#[derive(Clone, Debug, Deserialize, Serialize)]
59#[serde(rename_all = "lowercase")]
60pub enum Phase {
61    /// warmup
62    Warmup,
63    /// in game
64    Live,
65    /// halftime
66    Intermission,
67    /// game over
68    GameOver,
69}
70
71/// information about who won and how
72/// ("ct_win_time", "t_win_bomb", "ct_win_elimination", "ct_win_defuse", etc)
73/// (TODO actually parse)
74pub type RoundWin = String;
75
76/// team info
77#[derive(Clone, Debug, Deserialize, Serialize)]
78#[serde(deny_unknown_fields)]
79pub struct Team {
80    /// rounds won
81    pub score: u64,
82    /// rounds lost in a row
83    pub consecutive_round_losses: u64,
84    /// timeouts remaining
85    pub timeouts_remaining: u64,
86    /// matches won this series
87    pub matches_won_this_series: u64,
88    /// team name
89    pub name: Option<String>,
90    /// flag code (TODO find options)
91    pub flag: Option<String>,
92}