Castle out of check, legal?

Sort:
Kaon_497

Also if b8 is attacked black can castle queenside, or b2 if white. As others mentioned if rook is attacked you can still castle. You cannot castle even if the king or the rook are in correct squares if they have made a move previously. So if let's say king moves to f7 and returns to e8 it cannot castle later in the game.

Kaon_497

But if you have only moved the other rook like rook from a8 to c8 but you haven't moved the king and the other rook then the king can castle kingside. But if the king has moved you cannot castle anymore ever in any case.