PingPong/PingPong.GameEngine/GameState.cs

146 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using PingPong.GameEngine.Components;
namespace PingPong.GameEngine
{
public class GameState
{
#region Members
/// <summary>
/// The teams.
/// </summary>
private Lazy<List<Team>> teams;
/// <summary>
/// The type of the scoring.
/// </summary>
private Lazy<ScoringType> scoringType;
#endregion
#region Properties
/// <summary>
/// Gets the teams.
/// </summary>
/// <value>
/// The teams.
/// </value>
private List<Team> TeamList
{
get
{
return this.teams.Value;
}
}
/// <summary>
/// Gets the teams.
/// </summary>
/// <value>
/// The teams.
/// </value>
public IEnumerable<Team> Teams
{
get
{
return this.TeamList;
}
}
/// <summary>
/// Gets the type of the scoring.
/// </summary>
/// <value>
/// The type of the scoring.
/// </value>
public ScoringType ScoringType
{
get
{
return this.scoringType.Value;
}
}
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="PingPong.GameEngine.GameState"/> class.
/// </summary>
public GameState()
{
this.teams = new Lazy<List<Team>>(() => new List<Team>());
this.scoringType = new Lazy<ScoringType>(() => ScoringType.None);
}
#endregion
#region Methods
/// <summary>
/// Initialize the specified gameDefinition.
/// </summary>
/// <param name='gameDefinition'>
/// Game definition.
/// </param>
public GameState Initialize(GameDefinition gameDefinition)
{
if (gameDefinition == null)
{
throw new ArgumentNullException("gameDefinition");
}
//TODO: Add loading logic here.
return this;
}
/// <summary>
/// Adds the team.
/// </summary>
/// <returns>
/// The team.
/// </returns>
/// <param name='team'>
/// Team.
/// </param>
public GameState AddTeam(Team team)
{
if(team == null)
{
throw new ArgumentNullException("team");
}
this.TeamList.Add(team);
return this;
}
/// <summary>
/// Removes the team.
/// </summary>
/// <returns>
/// The team.
/// </returns>
/// <param name='team'>
/// Team.
/// </param>
public GameState RemoveTeam(Team team)
{
if (team == null)
{
throw new ArgumentNullException("team");
}
this.TeamList.Remove(team);
}
#endregion
}
}