csgo_gsi_payload/
map.rs

1use serde::Deserialize;
2use std::collections::HashMap;
3
4#[derive(Deserialize, Debug, Clone)]
5pub struct TeamSubsection {
6    /// Score of this team.
7    pub score: u16,
8    /// Number of consecutive rounds losses of this team.
9    pub consecutive_round_losses: u16,
10    /// Number of timeouts remaining for this team.
11    pub timeouts_remaining: u16,
12    /// Number of matches won by this team, in this series.
13    ///
14    /// Used on _"Best of X"_ games.
15    pub matches_won_this_series: u16,
16    /// Name of this team.
17    pub name: Option<String>,
18}
19
20#[derive(Deserialize, Debug, Clone)]
21#[serde(rename_all = "lowercase")]
22pub enum Phase {
23    Live,
24    Warmup,
25    Intermission,
26    GameOver,
27}
28
29#[derive(Deserialize, Debug, Clone)]
30#[serde(rename_all = "lowercase")]
31pub enum Mode {
32    Competitive,
33    Casual,
34    Deathmatch,
35    #[serde(rename = "scrimcomp2v2")]
36    Wingman,
37    #[serde(rename = "gungameprogressive")]
38    GunGame,
39    #[serde(rename = "gungametrbomb")]
40    Demolition,
41    Training,
42}
43
44#[derive(Deserialize, Debug, Clone)]
45#[serde(rename_all = "snake_case")]
46pub enum RoundWinCondition {
47    /// When CTs win the round by eliminating all the Ts.
48    CtWinElimination,
49    /// When CTs win the round by defusing the bomb.
50    CtWinDefuse,
51    /// When CTs win the round by time.
52    CtWinTime,
53    /// When Ts win the round by eliminating all the CTs.
54    TWinElimination,
55    /// When Ts win the round by exploding the bomb.
56    TWinBomb,
57}
58
59#[derive(Deserialize, Debug, Clone)]
60pub struct Map {
61    /// Gamemode. See [`Mode`].
62    pub mode: Mode,
63    /// Name of the map.
64    pub name: String,
65    /// Current phase of the game. See [`Phase`].
66    pub phase: Phase,
67    /// Current round number.
68    pub round: u32,
69    /// Information about the Ts. See [`TeamSubsection`].
70    pub team_t: TeamSubsection,
71    /// Information about the CTs. See [`TeamSubsection`].
72    pub team_ct: TeamSubsection,
73    /// Number of matches to win the series.
74    ///
75    /// Used on _"Best of X"_ games.
76    pub num_matches_to_win_series: u16,
77    /// Number of spectators.
78    pub current_spectators: Option<u64>,
79    /// Number of souvenirs packages dropped during the game.
80    pub souvenirs_total: u64,
81    /// See [`RoundWinCondition`].
82    #[serde(default)]
83    pub round_wins: HashMap<u16, RoundWinCondition>, // QUESTION: `Option` instead of HashMap::Default() ?
84}