2024-01-15 21:49:09 +01:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace CS2GSI.GameState;
|
2024-01-15 20:04:37 +01:00
|
|
|
|
|
|
|
|
|
public struct Map
|
|
|
|
|
{
|
|
|
|
|
public string Mode, Name, Phase;
|
|
|
|
|
public int Round, NumMatchesToWinSeries;
|
|
|
|
|
public Team TeamCT, TeamT;
|
2024-01-15 20:39:38 +01:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{GetType()}\n" +
|
|
|
|
|
$"\t{Mode} {Name} {Round} Matches to Win Series: {NumMatchesToWinSeries}\n" +
|
|
|
|
|
$"\t{Phase}\n" +
|
|
|
|
|
$"\t{TeamCT}\n" +
|
|
|
|
|
$"\t{TeamT}\n";
|
|
|
|
|
}
|
2024-01-15 21:49:09 +01:00
|
|
|
|
|
|
|
|
|
internal static Map? ParseFromJObject(JObject jsonObject)
|
|
|
|
|
{
|
|
|
|
|
return jsonObject.SelectToken("map") is { } mapToken
|
|
|
|
|
? new Map()
|
|
|
|
|
{
|
|
|
|
|
Mode = jsonObject.SelectToken("map.mode")!.Value<string>()!,
|
|
|
|
|
Name = jsonObject.SelectToken("map.name")!.Value<string>()!,
|
|
|
|
|
Phase = jsonObject.SelectToken("map.phase")!.Value<string>()!,
|
|
|
|
|
Round = jsonObject.SelectToken("map.round")!.Value<int>(),
|
|
|
|
|
NumMatchesToWinSeries = jsonObject.SelectToken("map.num_matches_to_win_series")!.Value<int>(),
|
|
|
|
|
TeamCT = Team.ParseFromJObject(jsonObject, "ct"),
|
|
|
|
|
TeamT = Team.ParseFromJObject(jsonObject, "t")
|
|
|
|
|
}
|
|
|
|
|
: null;
|
|
|
|
|
}
|
2024-01-15 20:04:37 +01:00
|
|
|
|
}
|