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 Player
|
|
|
|
|
{
|
|
|
|
|
public string SteamId, Name, Activity;
|
|
|
|
|
public string? Team;
|
|
|
|
|
public int? ObserverSlot;
|
|
|
|
|
public PlayerState? State;
|
|
|
|
|
public PlayerMatchStats? MatchStats;
|
2024-01-15 20:39:38 +01:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{GetType()}\n" +
|
|
|
|
|
$"\t{Name} {SteamId} {Activity} {Team}\n" +
|
|
|
|
|
$"\t{State}\n" +
|
|
|
|
|
$"\t{MatchStats}\n";
|
|
|
|
|
}
|
2024-01-15 21:49:09 +01:00
|
|
|
|
|
|
|
|
|
internal static Player? ParseFromJObject(JObject jsonObject)
|
|
|
|
|
{
|
|
|
|
|
return new Player()
|
|
|
|
|
{
|
|
|
|
|
SteamId = jsonObject.SelectToken("player.steamid")!.Value<string>()!,
|
|
|
|
|
Name = jsonObject.SelectToken("player.name")!.Value<string>()!,
|
|
|
|
|
Team = jsonObject.SelectToken("player.team")!.Value<string>()!,
|
|
|
|
|
Activity = jsonObject.SelectToken("player.activity")!.Value<string>()!,
|
|
|
|
|
State = PlayerState.ParseFromJObject(jsonObject),
|
|
|
|
|
MatchStats = PlayerMatchStats.ParseFromJObject(jsonObject)
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-01-15 20:04:37 +01:00
|
|
|
|
}
|