private void updateCastlingAvailabilities(final Position pos,
            final Piece movingPiece) {
        /*
         * We are doing our move at the moment, so we have to figure out whether
         * we affect the castling availability and whether it is for king - or
         * queenside
         */
        final ChessColor pieceColor = movingPiece.getColor();
        final PieceType pieceType = movingPiece.getType();
        /*
         * First check for the king. In this case both sides have to be disabled
         * if they are not already
         */
        if (PieceType.KING.equals(pieceType)) {
            // Disable kingside if this is still available
            this.disableCastlingAvailability(pos,
                    pos.isCastlingAvailable(true, pieceColor), true, pieceColor);

            // Disable queenside if this is still available
            this.disableCastlingAvailability(pos,
                    pos.isCastlingAvailable(false, pieceColor), false,
                    pieceColor);
            // Here we return just to save the checks for rook PieceType
        }
        /*
         * If it was no king, maybe we got a rook. In this case the question is
         * whether the rook is on the king - or queenside
         */
        else if (PieceType.ROOK.equals(pieceType)) {
            final ChessCoord movingPieceCoord = movingPiece.getCoord();
            final int neededRank = ChessRules.baseRank(pieceColor);
            /*
             * We need to check whether one of the side's castling has to be
             * disabled. We therefore first check whether the rook is actually
             * at the side's starting position and the castling of the side is
             * still available.
             */
            // First check kingside
            final boolean disableKingside = movingPieceCoord.getFile() == pos
                    .getCastlingRookFile(true, pieceColor)
                    && movingPieceCoord.getRank() == neededRank
                    && pos.isCastlingAvailable(true, pieceColor);
            disableCastlingAvailability(pos, disableKingside, true, pieceColor);

            // Now check queenside
            final boolean disableQueenside = movingPieceCoord.getFile() == pos
                    .getCastlingRookFile(false, pieceColor)
                    && movingPieceCoord.getRank() == neededRank
                    && pos.isCastlingAvailable(false, pieceColor);
            disableCastlingAvailability(pos, disableQueenside, false,
                    pieceColor);
        }
    }