cs2_gsi/model/round.rs
1//! Round and bomb-state nodes.
2
3use serde::{Deserialize, Serialize};
4
5/// Per-round state.
6#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
7pub struct Round {
8 /// Phase of the current round.
9 #[serde(default)]
10 pub phase: RoundPhase,
11 /// State of the bomb during the current round.
12 #[serde(default, rename = "bomb")]
13 pub bomb: BombRoundState,
14 /// Side that won the round (only set after the round ends).
15 #[serde(default, rename = "win_team")]
16 pub win_team: WinningTeam,
17}
18
19/// Phase of the active round.
20#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq, Hash)]
21#[serde(rename_all = "lowercase")]
22pub enum RoundPhase {
23 /// Buy-time / freezetime — players cannot move yet.
24 Freezetime,
25 /// Round is live.
26 Live,
27 /// Round ended, end-of-round delay active.
28 Over,
29 /// Unrecognized / not-yet-mapped phase.
30 #[serde(other)]
31 #[default]
32 Unknown,
33}
34
35/// Bomb state as reported via the `round.bomb` field. The richer per-bomb
36/// position info is in [`crate::model::bomb::Bomb`] under the root `bomb`.
37#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq, Hash)]
38#[serde(rename_all = "lowercase")]
39pub enum BombRoundState {
40 /// Bomb is being planted — defuse cycle has not yet started.
41 Planted,
42 /// Bomb was defused successfully.
43 Defused,
44 /// Bomb exploded.
45 Exploded,
46 /// No bomb event in the current round.
47 #[serde(other)]
48 #[default]
49 None,
50}
51
52/// Side that won the latest round.
53#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq, Hash)]
54#[serde(rename_all = "lowercase")]
55pub enum WinningTeam {
56 /// Counter-Terrorists.
57 Ct,
58 /// Terrorists.
59 T,
60 /// No winner yet (round still in progress).
61 #[serde(other)]
62 #[default]
63 None,
64}