/// <summary> /// Initialises a new instance of the <see cref="Player" /> class. /// </summary> /// <param name="inName">Name of the player.</param> /// <param name="inSymbol">The symbol the player will be using, X or O.</param> protected Player(string inName, CellState inSymbol) { ParameterValidation.EnsureNotNull(inName, "inName"); ParameterValidation.EnsureNotNull(inSymbol, "inSymbol"); if (inSymbol == CellState.Empty) { throw new ArgumentException("Invalid value. A player must choose X or O.", "inSymbol"); } Name = inName; Symbol = inSymbol; }
/// <summary> /// Initialises a new instance of the <see cref="AutomaticPlayer"/> class. /// </summary> /// <param name="inName">Name of the player.</param> /// <param name="inSymbol">The symbol the player will be using, X or O.</param> internal AutomaticPlayer(string inName, CellState inSymbol) : base(inName, inSymbol) { }
/// <summary> /// Detects whether the specified symbol has won. /// </summary> /// <param name="inContender">The contender.</param> private void DetectAWinFor(CellState inContender) { if (myCells.Count(x => x.State == inContender) == Constant.GridDimension) { // The specified contender has won. PathCompleteEventArgs thePathCompletionData = new PathCompleteEventArgs { WinningSymbol = inContender }; OnPathComplete(thePathCompletionData); } }