No Threat Permitted to the King on Completion by: Sandesh Dhulekar
You can't castle if your King or Rook is moved at any point earlier in the game. Also, there should not be any piece in between King and the Rook and if both the things are okay you can castle as long as there is no threat or check to the King after castling.