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)]; }
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); }