diff --git a/GameState/CS2GameState.cs b/GameState/CS2GameState.cs index 3ed34a9..6797d1d 100644 --- a/GameState/CS2GameState.cs +++ b/GameState/CS2GameState.cs @@ -8,12 +8,14 @@ public struct CS2GameState public int Timestamp; public Map? Map; public Player? Player; + public Round? Round; public override string ToString() { return $"{GetType()}\n" + $"\tTime: {Timestamp}\tSteamId: {ProviderSteamId}\n" + $"\t{Map}\n" + + $"\t{Round}\n" + $"\t{Player}\n"; } @@ -24,7 +26,8 @@ public struct CS2GameState ProviderSteamId = jsonObject.SelectToken("provider.steamid")!.Value()!, Timestamp = jsonObject.SelectToken("provider.timestamp")!.Value(), Map = GameState.Map.ParseFromJObject(jsonObject), - Player = GameState.Player.ParseFromJObject(jsonObject) + Player = GameState.Player.ParseFromJObject(jsonObject), + Round = GameState.Round.ParseFromJObject(jsonObject) }; } diff --git a/GameState/Round.cs b/GameState/Round.cs new file mode 100644 index 0000000..4ff8ee1 --- /dev/null +++ b/GameState/Round.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json.Linq; + +namespace CS2GSI.GameState; + +public struct Round +{ + public string Phase, WinnerTeam, BombStatus; + + public override string ToString() + { + return $"{GetType()}\n" + + $"\t{Phase} {WinnerTeam} {BombStatus}\n"; + } + + internal static Round? ParseFromJObject(JObject jsonObject) + { + return new Round() + { + Phase = jsonObject.SelectToken("round.phase")!.Value()!, + WinnerTeam = jsonObject.SelectToken("round.win_team")!.Value()!, + BombStatus = jsonObject.SelectToken("round.bomb")!.Value()! + }; + } +} \ No newline at end of file