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