implement the rest of the castling rules

Now only the parts that pertain to being in check are left.