예제 #1
0
파일: Castle.cs 프로젝트: Fabernaz/Chess
 public Castle(King king, Rook rook, Board board, CastleType type)
     : base(true,
            king,
            null,
            board[king.GetCastleStartingPosition()],
            board[king.GetCastleEndingPosition(type)],
            null)
 {
     _type  = type;
     _board = board;
     _rook  = rook;
     _rookStartingPosition = board[King.GetCastleRookStartingSquare(type)];
     _rookEndingPosition   = board[King.GetCastleRookEndingPosition(type)];
 }
예제 #2
0
        private bool IsCastleMove(King king, Square startingSquare, Square endingSquare, out CastleType?type)
        {
            type = null;

            if (startingSquare.Coordinate != king.GetCastleStartingPosition())
            {
                return(false);
            }

            if (endingSquare.Coordinate == king.GetCastleEndingPosition(CastleType.KingSide))
            {
                type = CastleType.KingSide;
                return(true);
            }
            else if (endingSquare.Coordinate == king.GetCastleEndingPosition(CastleType.QueenSide))
            {
                type = CastleType.QueenSide;
                return(true);
            }

            return(false);
        }