csgo_gsi2/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    /// survival
45    Survival,
46    /// the tutorial
47    Training,
48    /// demolition
49    #[serde(rename = "gungametrbomb")]
50    Demolition,
51    /// arms race
52    #[serde(rename = "gungameprogressive")]
53    ArmsRace,
54    /// wingman
55    #[serde(rename = "scrimcomp2v2")]
56    Wingman,
57    /// custom
58    Custom,
59}
60
61/// map phase
62#[derive(Clone, Debug, Deserialize, Serialize)]
63#[serde(rename_all = "lowercase")]
64pub enum Phase {
65    /// warmup
66    Warmup,
67    /// in game
68    Live,
69    /// halftime
70    Intermission,
71    /// game over
72    GameOver,
73}
74
75/// information about who won and how
76/// ("ct_win_time", "t_win_bomb", "ct_win_elimination", "ct_win_defuse", etc)
77/// (TODO actually parse)
78pub type RoundWin = String;
79
80/// team info
81#[derive(Clone, Debug, Deserialize, Serialize)]
82#[serde(deny_unknown_fields)]
83pub struct Team {
84    /// rounds won
85    pub score: u64,
86    /// rounds lost in a row
87    pub consecutive_round_losses: u64,
88    /// timeouts remaining
89    pub timeouts_remaining: u64,
90    /// matches won this series
91    pub matches_won_this_series: u64,
92    /// team name
93    pub name: Option<String>,
94    /// flag code (TODO find options)
95    pub flag: Option<String>,
96}