Ejemplo n.º 1
0
 private bool isNormalMove(IMove move)
 {
     if (move.Distance() == DistanceEnum.OneKnightJump)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
 public override bool IsAllowedMove(IMove move)
 {
     if (move.Distance() == DistanceEnum.OneSquare)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
 private bool isNormalMove(IMove move)
 {
     if (move.Direction() == MoveDirection.Verticaly &&
         move.SenseVertical() == pawnForwardSense &&
         move.Distance() == DistanceEnum.OneSquare)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
 public override bool IsAllowedCapture(IMove move)
 {
     if (move.Direction() == MoveDirection.Diagonally &&
         move.SenseVertical() == pawnForwardSense &&
         move.Distance() == DistanceEnum.OneSquare)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 private bool isLongFirsrMove(IMove move)
 {
     if (move.Direction() == MoveDirection.Verticaly &&
         move.SenseVertical() == pawnForwardSense &&
         move.Distance() == DistanceEnum.TwoSquares &&
         Moved == false)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
        public List <IMove> Castling(IMove move, IBoard board)
        {
            if (move.Distance() == DistanceEnum.TwoSquares &&
                move.Direction() == MoveDirection.Horizontally &&
                !Moved)
            {
                Position rookPosition;
                int      castlingDirection = move.SenseHorizontal();
                if (castlingDirection == 1)
                {
                    rookPosition = new Position(7, currentPosition.y);
                }
                else
                {
                    rookPosition = new Position(0, currentPosition.y);
                }


                IPiece rock = board.GetFigureAt(rookPosition);
                if (rock != null)
                {
                    if (rock.Type == PiecesTypesEnum.Rock &&
                        !rock.Moved &&
                        !board.AreAnyPiecesBetwen(currentPosition, rock.currentPosition) &&
                        !board.IsCheck(color) &&
                        !board.IsFieldAttacked(new Position(currentPosition.x + castlingDirection, currentPosition.y), color) &&
                        !board.IsFieldAttacked(new Position(currentPosition.x + 2 * castlingDirection, currentPosition.y), color) &&
                        !board.IsFieldAttacked(move.Destination, color))
                    {
                        List <IMove> result = new List <IMove>();
                        result.Add(move);
                        result.Add(new Move(rookPosition, new Position(currentPosition.x + castlingDirection, currentPosition.y)));
                        return(result);
                    }
                }
            }
            return(null);
        }