Example #1
0
File: Player.cs Project: ggreig/OXO
        /// <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;
        }
Example #2
0
 /// <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)
 {
 }
Example #3
0
File: Path.cs Project: ggreig/OXO
 /// <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);
     }
 }