public void PutPiece_PlayerSquare_False()
        {
            var square = new CheckersSquare(3, 2);
            square.PutPiece(new CheckersPiece(CheckersPlayer.PlayerOne));

            Assert.IsFalse(square.PutPiece(new CheckersPiece(CheckersPlayer.PlayerOne)));
        }
Example #2
0
        /// <summary>
        /// Reset the board to initial state (player one and two with pieces in start positions).
        /// </summary>
        public void Reset()
        {
            PlayerOnePieces = new List <CheckersPiece> ();
            PlayerTwoPieces = new List <CheckersPiece> ();

            for (int c = 0; c < Size; c++)
            {
                for (int r = 0; r < Size; r++)
                {
                    var square = new CheckersSquare(c, r);

                    if (square.State == CheckersSquareState.Free)
                    {
                        if (r < 3)
                        {
                            var piece = new CheckersPiece(CheckersPlayer.PlayerOne);
                            PlayerOnePieces.Add(piece);
                            square.PutPiece(piece);
                        }
                        else if (r >= Size - 3)
                        {
                            var piece = new CheckersPiece(CheckersPlayer.PlayerTwo);
                            PlayerTwoPieces.Add(piece);
                            square.PutPiece(piece);
                        }
                    }

                    m_squares[c, r] = square;
                }
            }
        }
        public void PutPiece_NoPlayableSquare_Exception()
        {
            var square = new CheckersSquare(0, 0);

            ExceptionAssert.IsThrowing(new ArgumentException("Attempt to put a piece in a not playable square."), () =>
            {
                square.PutPiece(new CheckersPiece(CheckersPlayer.PlayerOne));
            });
        }
Example #4
0
        /// <summary>
        /// Reset the board to initial state (player one and two with pieces in start positions).
        /// </summary>
        public void Reset()
        {
            // Creates the two lists of pieces por player one and two.ß
            PlayerOnePieces = new List <CheckersPiece>();
            PlayerTwoPieces = new List <CheckersPiece>();

            for (int c = 0; c < Size; c++)
            {
                for (int r = 0; r < Size; r++)
                {
                    // For each combinatino of collumn and row of the board
                    // Is create a new CheckersSquare.
                    var square = new CheckersSquare(c, r);

                    // If the sqaure is free.
                    if (square.State == CheckersSquareState.Free)
                    {
                        // If the actual line index is lower than 3,
                        // then is a square for player one.
                        if (r < 3)
                        {
                            var piece = new CheckersPiece(CheckersPlayer.PlayerOne);
                            PlayerOnePieces.Add(piece);
                            square.PutPiece(piece);
                        }
                        /// fi the actual line index is bigger than max lines index -3,
                        /// then it is a square for player two.
                        else if (r >= Size - 3)
                        {
                            var piece = new CheckersPiece(CheckersPlayer.PlayerTwo);
                            PlayerTwoPieces.Add(piece);
                            square.PutPiece(piece);
                        }
                    }

                    m_squares[c, r] = square;
                }
            }
        }
Example #5
0
        /// <summary>
        /// Reset the board to initial state (player one and two with pieces in start positions).
        /// </summary>
        public void Reset()
        {
            PlayerOnePieces = new List<CheckersPiece>();
            PlayerTwoPieces = new List<CheckersPiece>();

            for (int c = 0; c < Size; c++)
            {
                for (int r = 0; r < Size; r++)
                {
                    var square = new CheckersSquare(c, r);

                    if (square.State == CheckersSquareState.Free)
                    {
                        if (r < 3)
                        {
                            var piece = new CheckersPiece(CheckersPlayer.PlayerOne);
                            PlayerOnePieces.Add(piece);
                            square.PutPiece(piece);
                        }
                        else if (r >= Size - 3)
                        {
                            var piece = new CheckersPiece(CheckersPlayer.PlayerTwo);
                            PlayerTwoPieces.Add(piece);
                            square.PutPiece(piece);
                        }
                    }

                    m_squares[c, r] = square;
                }
            }
        }