refactor king_attacked, made generic square_attacked