Skip to content

Commit

Permalink
Major changes
Browse files Browse the repository at this point in the history
* Updated README.md
* Renamed GSIListener to GameStateListener
* Removed GameStateListener.HasRootNode()
* GameStateListener is no longer static
* GameStateListener defaults to http://localhost:<port>/ instead of
http://127.0.0.1:<port>/ to avoid permission issues
* Removed UacHelper class
* Added "CSGSI.Nodes" namespace
* Added "Node" classes
* Have not added documentation for most of the new features yet,
although they're relatively self-explanatory
* Release 1.1 is now available!

**this does not mean that I'm going to be pushing regular updates from
now on**
  • Loading branch information
rakijah committed Dec 16, 2015
1 parent c6679e4 commit 9549444
Show file tree
Hide file tree
Showing 20 changed files with 1,046 additions and 464 deletions.
4 changes: 3 additions & 1 deletion CSGSI.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSGSI", "CSGSI\CSGSI.csproj", "{8D55804C-2CF1-4A65-9C3E-8E41CD809535}"
EndProject
Global
Expand Down
15 changes: 12 additions & 3 deletions CSGSI/CSGSI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@
</ItemGroup>
<ItemGroup>
<Compile Include="GameState.cs" />
<Compile Include="GameStateNode.cs" />
<Compile Include="GSIListener.cs" />
<Compile Include="GameStateListener.cs" />
<Compile Include="Nodes\AllPlayersNode.cs" />
<Compile Include="Nodes\AuthNode.cs" />
<Compile Include="Nodes\MapNode.cs" />
<Compile Include="Nodes\MatchStatsNode.cs" />
<Compile Include="Nodes\NodeBase.cs" />
<Compile Include="Nodes\PlayerNode.cs" />
<Compile Include="Nodes\ProviderNode.cs" />
<Compile Include="Nodes\RoundNode.cs" />
<Compile Include="Nodes\PlayerStateNode.cs" />
<Compile Include="Nodes\WeaponNode.cs" />
<Compile Include="Nodes\WeaponsNode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UacHelper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
132 changes: 0 additions & 132 deletions CSGSI/GSIListener.cs

This file was deleted.

167 changes: 107 additions & 60 deletions CSGSI/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,140 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using CSGSI.Nodes;
namespace CSGSI
{
/// <summary>
/// This object represents the entire game state
/// </summary>
public class GameState
{
private JObject m_Data;
private JObject _Data;

private GameStateNode m_Provider;
private GameStateNode m_Map;
private GameStateNode m_Round;
private GameStateNode m_Player;
private GameStateNode m_Auth;
private GameStateNode m_Added;
private GameStateNode m_Previously;
private ProviderNode _Provider;
private MapNode _Map;
private RoundNode _Round;
private PlayerNode _Player;
private AllPlayersNode _AllPlayers;
private GameState _Previously;
private GameState _Added;
private AuthNode _Auth;

/// <summary>
/// The "provider" subnode
/// </summary>
public GameStateNode Provider { get { return m_Provider; } }
public ProviderNode Provider
{
get
{
if (_Provider == null)
{
_Provider = new ProviderNode(_Data["provider"]?.ToString() ?? "");
}

/// <summary>
/// The "map" subnode
/// </summary>
public GameStateNode Map { get { return m_Map; } }
return _Provider;
}
}
public MapNode Map
{
get
{
if (_Map == null)
{
_Map = new MapNode(_Data["map"]?.ToString() ?? "");
}

/// <summary>
/// The "round" subnode
/// </summary>
public GameStateNode Round { get { return m_Round; } }
return _Map;
}
}
public RoundNode Round
{
get
{
if (_Round == null)
{
_Round = new RoundNode(_Data["round"]?.ToString() ?? "");
}

/// <summary>
/// The "player" subnode
/// </summary>
public GameStateNode Player { get { return m_Player; } }
return _Round;
}
}
public PlayerNode Player
{
get
{
if (_Player == null)
{
_Player = new PlayerNode(_Data["player"]?.ToString() ?? "");
}

/// <summary>
/// The "auth" subnode
/// </summary>
public GameStateNode Auth { get { return m_Auth; } }
return _Player;
}
}
public AllPlayersNode AllPlayers
{
get
{
if (_AllPlayers == null)
{
_AllPlayers = new AllPlayersNode(_Data["allplayers"]?.ToString() ?? "");
}

/// <summary>
/// The "added" subnode
/// </summary>
public GameStateNode Added { get { return m_Added; } }
return _AllPlayers;
}
}
public GameState Previously
{
get
{
if (_Previously == null)
{
_Previously = new GameState(_Data["previously"]?.ToString() ?? "");
}

/// <summary>
/// The "previously" subnode
/// </summary>
public GameStateNode Previously { get { return m_Previously; } }
return _Previously;
}
}
public GameState Added
{
get
{
if (_Added == null)
{
_Added = new GameState(_Data["added"]?.ToString() ?? "");
}
return _Added;
}
}
public AuthNode Auth
{
get
{
if(_Auth == null)
{
_Auth = new AuthNode(_Data["auth"]?.ToString() ?? "");
}

return _Auth;
}
}

private string m_JSON;

/// <summary>
/// The JSON string that was used to generate this object
/// </summary>
public string JSON { get { return m_JSON; } }

public readonly string JSON;
/// <summary>
/// Initialises a new GameState object using a JSON string
/// </summary>
/// <param name="JSONstring"></param>
public GameState(string JSONstring)
{
m_JSON = JSONstring;
if(JSONstring.Equals(""))
{
JSONstring = "{}";
}

if (!JSONstring.Equals(""))
m_Data = JObject.Parse(JSONstring);

m_Provider = (HasRootNode("provider") ? new GameStateNode(m_Data["provider"]) : GameStateNode.Empty());
m_Map = (HasRootNode("map") ? new GameStateNode(m_Data["map"]) : GameStateNode.Empty());
m_Round = (HasRootNode("round") ? new GameStateNode(m_Data["round"]) : GameStateNode.Empty());
m_Player = (HasRootNode("player") ? new GameStateNode(m_Data["player"]) : GameStateNode.Empty());
m_Auth = (HasRootNode("auth") ? new GameStateNode(m_Data["auth"]) : GameStateNode.Empty());
m_Added = (HasRootNode("added") ? new GameStateNode(m_Data["added"]) : GameStateNode.Empty());
m_Previously = (HasRootNode("previously") ? new GameStateNode(m_Data["previously"]) : GameStateNode.Empty());
}

/// <summary>
/// Determines if the specified node exists in this GameState object
/// </summary>
/// <param name="rootnode"></param>
/// <returns>Returns true if the specified node exists, false otherwise</returns>
public bool HasRootNode(string rootnode)
{
return (m_Data != null && m_Data[rootnode] != null);
JSON = JSONstring;
_Data = JObject.Parse(JSONstring);
}
}
}
Loading

0 comments on commit 9549444

Please sign in to comment.