from math import pi, sin, cos, atan2, sqrt class Location(): def __init__(self, latitude, longitude): self.latitude = latitude self.longitude = longitude def distance(self, other): R = 6371e3 d_lat = (self.latitude - other.latitude) * pi/180 d_lon = (self.longitude - other.longitude) * pi/180 a = sin(d_lat/2) * sin(d_lat/2) +\ sin(d_lon/2) * sin(d_lon/2) * cos(self.latitude) * cos(other.latitude) c = 2 * atan2(sqrt(a), sqrt(1-a)) d = R * c / 1000 return d def get_cooldown(self, other): distance = self.distance(other) if distance <= 2: return 1 elif distance <= 5: return 2 elif distance <= 7: return 5 elif distance <= 10: return 7 elif distance <= 12: return 8 elif distance <= 18: return 10 elif distance <= 26: return 15 elif distance <= 42: return 19 elif distance <= 65: return 22 elif distance <= 81: return 25 elif distance <= 100: return 35 elif distance <= 220: return 40 elif distance <= 250: return 45 elif distance <= 350: return 51 elif distance <= 375: return 54 elif distance <= 460: return 62 elif distance <= 500: return 65 elif distance <= 565: return 69 elif distance <= 700: return 78 elif distance <= 800: return 84 elif distance <= 900: return 92 elif distance <= 1000: return 99 elif distance <= 1100: return 107 elif distance <= 1200: return 114 elif distance <= 1300: return 117 else: return 120