Example #1
0
        public override bool IsValidMove(Vector2D toPosition)
        {
            bool validBishop       = MovementValidation.IsValidBishopMovement(BoardPosition, toPosition);
            bool pathNotObstructed = MovementValidation.IsPathNotObstructed(BoardPosition, toPosition);

            return(validBishop && pathNotObstructed);
        }
Example #2
0
        public override bool IsValidMove(Vector2D toPosition)
        {
            bool isValidRook     = MovementValidation.IsValidRookMovement(BoardPosition, toPosition);
            bool isValidBishop   = MovementValidation.IsValidBishopMovement(BoardPosition, toPosition);
            bool isNotObstructed = MovementValidation.IsPathNotObstructed(BoardPosition, toPosition);

            return((isValidRook || isValidBishop) && isNotObstructed);
        }
Example #3
0
        public override bool IsValidMove(Vector2D toPosition)
        {
            bool isValid = false;

            var pieceAtToPosition = ChessGame.ChessBoard.Board[toPosition.Y, toPosition.X];

            if ((MovementValidation.IsValidBishopMovement(BoardPosition, toPosition) ||
                 MovementValidation.IsValidRookMovement(BoardPosition, toPosition)) &&
                !(pieceAtToPosition != null && pieceAtToPosition.GetType() == typeof(King)))
            {
                int xDiff = Math.Abs(BoardPosition.X - toPosition.X);
                int yDiff = Math.Abs(BoardPosition.Y - toPosition.Y);

                isValid = ((xDiff == 0 || xDiff == 1) && (yDiff == 0 || yDiff == 1));
            }

            return(isValid);
        }