예제 #1
0
        public override bool IsValidMove(Vector2D toPosition)
        {
            bool isValidRook = MovementValidation.IsValidRookMovement(BoardPosition, toPosition);
            //if (toPosition.ToCoordinate() == "g1") Debugger.Break();
            bool isNotObstructed = MovementValidation.IsPathNotObstructed(BoardPosition, toPosition);

            return(isValidRook && isNotObstructed);
        }
예제 #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);
        }
예제 #3
0
파일: King.cs 프로젝트: kjbilliot/MonoChess
        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);
        }