Пример #1
0
        public void Update_Board_Removes_Piece_From_Old_Position()
        {
            var pawn = Substitute.For <IChessPiece>();

            _chessBoard.Add(pawn, 0, 1, pawn.Color);
            _chessBoard.UpdateBoard(new Move(pawn, 0, 1, 0, 3));

            IChessPiece foundPiece;

            Assert.That(_chessBoard.TryGetPieceOn(0, 1, out foundPiece), Is.False);
            Assert.That(foundPiece, Is.Null);
        }
Пример #2
0
        /// <summary>
        /// Moves the piece.  Coordinates are only updated if the move is valid
        /// </summary>
        /// <param name="newXCoordinate">The x coordinate of the square being moved to</param>
        /// <param name="newYCoordinate">The y coordinate of the square being moved to</param>
        /// <returns>True when the move was valid</returns>
        public virtual bool Move(MovementType moveType, int newXCoordinate, int newYCoordinate)
        {
            Move move = new Move(this, XCoordinate, YCoordinate, newXCoordinate, newYCoordinate);

            if (_chessBoard.IsMoveValid(move))
            {
                XCoordinate = newXCoordinate;
                YCoordinate = newYCoordinate;
                _chessBoard.UpdateBoard(move);
                return(true);
            }

            return(false);
        }