Misc changes

* Use Pair instead of KeyValuePair
* double -> var
* Butcher XML comments
* Change WinState default to Undefined and use it instead of the new GameOutcome
* Other changes
This commit is contained in:
Pavlos Touboulidis
2014-05-20 17:45:33 +03:00
parent fe1eb1f3e0
commit b8bbd55598
8 changed files with 74 additions and 134 deletions

View File

@@ -16,62 +16,30 @@ using OpenRA.Network;
namespace OpenRA
{
/// <summary>
/// Contains information about a finished game
/// </summary>
public class GameInformation
{
/// <summary>The map identifier.</summary>
public string MapUid;
/// <summary>The map title.</summary>
public string MapTitle;
/// <summary>Game start timestamp.</summary>
public DateTime StartTimeUtc;
/// <summary>Game end timestamp (when the recoding stopped).</summary>
// Game end timestamp (when the recoding stopped).
public DateTime EndTimeUtc;
/// <summary>
/// Gets the game's duration, from the time the game started until the
/// replay recording stopped.
/// </summary>
/// <value>The game's duration.</value>
// Gets the game's duration, from the time the game started until the
// replay recording stopped.
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
/// <summary>
/// Gets the list of players.
/// </summary>
/// <value>The players.</value>
public IList<Player> Players { get; private set; }
/// <summary>
/// Gets the map preview, using <see cref="Game.modData.MapCache"/> and the <see cref="MapUid"/>.
/// </summary>
/// <value>The map preview.</value>
public MapPreview MapPreview { get { return Game.modData.MapCache[MapUid]; } }
/// <summary>
/// Gets the human players.
/// </summary>
/// <value>The human players.</value>
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
/// <summary>
/// Gets a value indicating whether this instance has just one human player.
/// </summary>
/// <value><c>true</c> if this instance has just one human player; otherwise, <c>false</c>.</value>
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }
Dictionary<OpenRA.Player, Player> playersByRuntime;
/// <summary>
/// Initializes a new instance of the class.
/// </summary>
public GameInformation()
{
Players = new List<Player>();
playersByRuntime = new Dictionary<OpenRA.Player, Player>();
}
/// <summary>
/// Deserialize the specified data into a new instance.
/// </summary>
/// <param name="data">Data.</param>
public static GameInformation Deserialize(string data)
{
try
@@ -104,9 +72,6 @@ namespace OpenRA
}
}
/// <summary>
/// Serialize this instance.
/// </summary>
public string Serialize()
{
var nodes = new List<MiniYamlNode>();
@@ -119,11 +84,7 @@ namespace OpenRA
return nodes.WriteToString();
}
/// <summary>
/// Adds the start-up player information.
/// </summary>
/// <param name="runtimePlayer">Runtime player.</param>
/// <param name="lobbyInfo">Lobby info.</param>
// Adds the player information at start-up.
public void AddPlayer(OpenRA.Player runtimePlayer, Session lobbyInfo)
{
if (runtimePlayer == null)
@@ -160,11 +121,7 @@ namespace OpenRA
Players.Add(player);
}
/// <summary>
/// Gets the player information for the specified runtime player instance.
/// </summary>
/// <returns>The player, or <c>null</c>.</returns>
/// <param name="runtimePlayer">Runtime player.</param>
// Gets the player information for the specified runtime player instance.
public Player GetPlayer(OpenRA.Player runtimePlayer)
{
Player player;
@@ -174,56 +131,37 @@ namespace OpenRA
return player;
}
/// <summary>Specifies whether the player was defeated, victorious, or there was no outcome defined.</summary>
public enum GameOutcome
{
/// <summary>Unknown outcome.</summary>
Undefined,
/// <summary>The player was defeated</summary>
Defeat,
/// <summary>The player was victorious</summary>
Victory
}
///<summary>
/// Information about a player
/// </summary>
public class Player
{
//
// Start-up information
//
/// <summary>The client index.</summary>
public int ClientIndex;
/// <summary>The player name, not guaranteed to be unique.</summary>
// The player name, not guaranteed to be unique.
public string Name;
/// <summary><c>true</c> if the player is a human player; otherwise, <c>false</c>.</summary>
public bool IsHuman;
/// <summary><c>true</c> if the player is a bot; otherwise, <c>false</c>.</summary>
public bool IsBot;
/// <summary>The faction name (aka Country).</summary>
// The faction name (aka Country)
public string FactionName;
/// <summary>The faction id (aka Country, aka Race).</summary>
// The faction id (aka Country, aka Race)
public string FactionId;
/// <summary>The color used by the player in the game.</summary>
public HSLColor Color;
/// <summary>The team id on start-up, or 0 if the player is not part of the team.</summary>
// The team id on start-up, or 0 if the player is not part of the team.
public int Team;
/// <summary>The index of the spawn point on the map, or 0 if the player is not part of the team.</summary>
public int SpawnPoint;
/// <summary><c>true</c> if the faction was chosen at random; otherwise, <c>false</c>.</summary>
// True if the faction was chosen at random; otherwise, false
public bool IsRandomFaction;
/// <summary><c>true</c> if the spawn point was chosen at random; otherwise, <c>false</c>.</summary>
// True if the spawn point was chosen at random; otherwise, false.</summary>
public bool IsRandomSpawnPoint;
//
// Information gathered at a later stage
//
/// <summary>The game outcome for this player.</summary>
public GameOutcome Outcome;
/// <summary>The time when this player won or lost the game.</summary>
// The game outcome for this player
public WinState Outcome;
// The time when this player won or lost the game
public DateTime OutcomeTimestampUtc;
}
}