You also can't castle if your King moves through a square that is under attack. In this diagram, the white Bishop is attacking the square to the left of the black King, so Black can't castle in that direction. Black can, of course, still castle to the right.


