def work(self): lat = self.gym['latitude'] lng = self.gym['longitude'] gym_id = self.gym['id'] dist = distance(self.position[0], self.position[1], lat, lng) log.info('[#] Видим GYM {} на удалении {}'.format(gym_id, format_dist(dist))) if dist > 10: log.info('[#] GYM дальше 10 метров, бежим...') position = (lat, lng, 0.0) if self.scanner.mode.walk > 0: self.stepper._walk_to(self.scanner.mode.walk, *position) else: self.api.set_position(*position) self.api.player_update(latitude=lat, longitude=lng) self.position = position response_dict = self.api.call() log.info('[#] Прибыли к GYM\'у') sleep(2) return response_dict return None
def _walk_to(self, speed, lat, lng, alt): dist = distance(i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng) steps = (dist + 0.0) / (speed + 0.0) # may be rational number intSteps = int(steps) residuum = steps - intSteps log.info('Бежим из ' + str((i2f(self.api._position_lat), i2f(self.api._position_lng))) + " в " + str(str((lat, lng))) + " по прямой. " + str(format_time(ceil(steps)))) if steps != 0: dLat = (lat - i2f(self.api._position_lat)) / steps dLng = (lng - i2f(self.api._position_lng)) / steps for i in range(intSteps): cLat = i2f( self.api._position_lat) + dLat + random_lat_long_delta() cLng = i2f( self.api._position_lng) + dLng + random_lat_long_delta() self.api.set_position(cLat, cLng, alt) self.ai.heartbeat() self._work_at_position(i2f(self.api._position_lat), i2f(self.api._position_lng), alt, seen_pokemon=True, seen_pokestop=False, seen_gym=False) sleep(2 * self.scanner.mode.is_human) self.api.set_position(lat, lng, alt) self.ai.heartbeat()
def work(self): lat = self.pokestop['latitude'] lng = self.pokestop['longitude'] pokestop_id = self.pokestop['id'] dist = distance(self.position[0], self.position[1], lat, lng) log.info('Видим покестоп {} на удалении {}'.format(pokestop_id, format_dist(dist))) if dist > 10: log.info('Покестоп дальше 10 метров, бежим...') position = (lat, lng, 0.0) if self.scanner.mode.walk > 0: self.stepper._walk_to(self.scanner.mode.walk, *position) else: self.api.set_position(*position) response_dict = self.api.player_update(latitude=lat, longitude=lng) self.position = position log.info('Прибыли к покестопу') action_delay(self.ai.delay_action_min, self.ai.delay_action_max) return response_dict return None
def _old_walk_to(self, speed, lat, lng, alt): dist = distance( i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng) steps = (dist + 0.0) / (speed + 0.0) # may be rational number intSteps = int(steps) residuum = steps - intSteps log.info('[#] Walking from ' + str((i2f(self.api._position_lat), i2f( self.api._position_lng))) + " to " + str(str((lat, lng))) + " for approx. " + str(format_time(ceil(steps)))) if steps != 0: dLat = (lat - i2f(self.api._position_lat)) / steps dLng = (lng - i2f(self.api._position_lng)) / steps for i in range(intSteps): cLat = i2f(self.api._position_lat) + \ dLat + random_lat_long_delta() cLng = i2f(self.api._position_lng) + \ dLng + random_lat_long_delta() self.api.set_position(cLat, cLng, alt) self.ai.heartbeat() sleep(1) # sleep one second plus a random delta self._work_at_position( i2f(self.api._position_lat), i2f(self.api._position_lng), alt, False) self.api.set_position(lat, lng, alt) self.ai.heartbeat() log.info("[#] Finished walking")
def _walk_to(self, speed, lat, lng, alt): dist = distance(i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng) steps = (dist + 0.0) / (speed + 0.0) # may be rational number intSteps = int(steps) residuum = steps - intSteps log.info('Бежим из ' + str((i2f(self.api._position_lat), i2f(self.api._position_lng))) + " в " + str(str((lat, lng))) + " на " + str(round(dist, 2)) + " по прямой. " + str(format_time(ceil(steps)))) if steps != 0: dLat = (lat - i2f(self.api._position_lat)) / steps dLng = (lng - i2f(self.api._position_lng)) / steps for i in range(intSteps): cLat = i2f( self.api._position_lat) + dLat + random_lat_long_delta() cLng = i2f( self.api._position_lng) + dLng + random_lat_long_delta() self.api.set_position(cLat, cLng, alt) self.ai.heartbeat() sleep(1) self.api.set_position(lat, lng, alt) self.ai.heartbeat()
def work(self): lat = self.pokestop['latitude'] lng = self.pokestop['longitude'] pokestop_id = self.pokestop['id'] dist = distance(self.position[0], self.position[1], lat, lng) log.info('Видим покестоп {} на удалении {}'.format( pokestop_id, format_dist(dist))) if dist > 10: log.info('Покестоп дальше 10 метров, бежим...') position = (lat, lng, 0.0) if self.scanner.mode.walk > 0: self.stepper._walk_to(self.scanner.mode.walk, *position) else: self.api.set_position(*position) self.api.player_update(latitude=lat, longitude=lng) self.position = position response_dict = self.api.call() log.info('Прибыли к покестопу') sleep(2) return response_dict return None
def _walk_to(self, walk_speed, dest_lat, dest_lng, alt): init_lat = self.api._position_lat init_lng = self.api._position_lng walk_distance = distance(init_lat, init_lng, dest_lat, dest_lng) walk_distance_total = max(1, walk_distance) walk_steps = (walk_distance + 0.0) / (walk_speed + 0.0) if walk_distance < walk_speed or int(walk_steps) <= 1: delta_lat = 0 delta_lng = 0 magnitude = 0 else: delta_lat = (dest_lat - init_lat) / int(walk_steps) delta_lng = (dest_lng - init_lng) / int(walk_steps) magnitude = self._pythagorean(delta_lat, delta_lng) log.info("Бежим из [{}, {}] в [{}, {}] на расстояние {}, со скоростью {}, ориентировочно за {}".format(init_lat, init_lng, dest_lat, dest_lng, round(walk_distance, 2), walk_speed, format_time(ceil(walk_steps)))) if (delta_lat == 0 and delta_lng == 0) or walk_distance < walk_speed: self.api.set_position(dest_lat, dest_lng, 0) return True while True: total_delta_step = walk_distance/int(walk_steps) total_delta_lat = (dest_lat - self.api._position_lat) total_delta_lng = (dest_lng - self.api._position_lng) magnitude = self._pythagorean(total_delta_lat, total_delta_lng) if distance(self.api._position_lat, self.api._position_lng, dest_lat, dest_lng) <= total_delta_step: self.api.set_position(dest_lat, dest_lng, alt) self.ai.heartbeat() break unit_lat = total_delta_lat / magnitude unit_lng = total_delta_lng / magnitude scaled_delta_lat = unit_lat * magnitude scaled_delta_lng = unit_lng * magnitude c_lat = init_lat + scaled_delta_lat + random_lat_long_delta() c_lng = init_lng + scaled_delta_lng + random_lat_long_delta() self.api.set_position(c_lat, c_lng, 0) self.ai.heartbeat() sleep(1)
def _work_at_position(self, lat, lng, alt, seen_pokemon=False, seen_pokestop=False, seen_gym=False, data=None): if data is not None: pokestop = self.session.query(Pokestop).get(data) cell = { 'forts': [ { 'id': pokestop.id, 'type': 1, 'latitude': pokestop.latitude, 'longitude': pokestop.longitude } ] } self.metrica.take_search({'pokestops': 1}) self.api.set_position(lat, lng, alt) self.ai.work_on_cell(cell, (lat, lng, alt), seen_pokemon=False, seen_pokestop=True, seen_gym=False) position = (lat, lng, alt) cellid = get_cell_ids(lat, lng) timestamp = [0, ] * len(cellid) map_cells = list() sleep(self.ai.delay_scan) response_dict = self.api.get_map_objects(latitude=f2i(lat), longitude=f2i(lng), since_timestamp_ms=timestamp, cell_id=cellid) self.search.search(lat, lng) if response_dict and 'status_code' in response_dict: if response_dict['status_code'] is 1: if 'responses' in response_dict: if 'GET_MAP_OBJECTS' in response_dict['responses']: if 'status' in response_dict['responses']['GET_MAP_OBJECTS']: if response_dict['responses']['GET_MAP_OBJECTS']['status'] is 1: map_cells = response_dict['responses']['GET_MAP_OBJECTS']['map_cells'] # Update current scanner location self.metrica.take_position(position) map_cells.sort(key=lambda x: distance(lat, lng, x['forts'][0]['latitude'], x['forts'][0]['longitude']) if 'forts' in x and x['forts'] != [] else 1e6) log.debug("Получена информация о карте в размере {0} ячеек".format(len(map_cells))) for cell in map_cells: self.metrica.take_search(parse_map_cell(cell, self.session)) else: log.warning("Получен неверный статус: {0}".format(response_dict['responses']['GET_MAP_OBJECTS']['status'])) else: log.warning("Получен неверный статус: {0}".format(response_dict['status_code'])) self.api.set_position(lat, lng, alt) for cell in map_cells: self.ai.work_on_cell(cell, position, seen_pokemon=seen_pokemon, seen_pokestop=seen_pokestop, seen_gym=seen_gym)
def generate_coords(latitude, longitude, step_size, distance_limit): coords = [{'lat': latitude, 'lng': longitude}] for coord in Spiral.generate_spiral(step_size, step_size): lat = latitude + coord[0] + random_lat_long_delta() lng = longitude + coord[1] + random_lat_long_delta() coords.append({'lat': lat, 'lng': lng}) if distance(latitude, longitude, lat, lng) > distance_limit: break return coords
def generate_coords(latitude, longitude, step_size, distance_limit): coords = [{'lat': latitude, 'lng': longitude}] for coord in Starline.generate_starline([latitude, longitude], step_size): lat = coord[0] + random.uniform(-step_size/6, step_size/6) lng = coord[1] + random.uniform(-step_size/6, step_size/6) coords.append({'lat': lat, 'lng': lng}) if distance(latitude, longitude, lat, lng) > distance_limit: break return coords
def _work_at_position(self, lat, lng, alt, seen_pokemon=False, seen_pokestop=False, seen_gym=False, data=None): position = (lat, lng, alt) cellid = get_cell_ids(lat, lng) timestamp = [0, ] * len(cellid) map_cells = list() self.api.get_map_objects(latitude=f2i(lat), longitude=f2i(lng), since_timestamp_ms=timestamp, cell_id=cellid) response_dict = self.api.call() sleep(0.2) self.search.search(lat, lng) if response_dict and 'status_code' in response_dict: if response_dict['status_code'] is 1: if 'responses' in response_dict: if 'GET_MAP_OBJECTS' in response_dict['responses']: if 'status' in response_dict['responses']['GET_MAP_OBJECTS']: if response_dict['responses']['GET_MAP_OBJECTS']['status'] is 1: map_cells = response_dict['responses']['GET_MAP_OBJECTS']['map_cells'] # Update current scanner location self.metrica.take_position(position) map_cells.sort(key=lambda x: distance(lat, lng, x['forts'][0]['latitude'], x['forts'][0]['longitude']) if 'forts' in x and x['forts'] != [] else 1e6) log.debug("Получена информация о карте в размере {0} ячеек".format(len(map_cells))) for cell in map_cells: self.metrica.take_search(parse_map_cell(cell, self.session)) else: log.warning("Получен неверный статус: {0}".format(response_dict['responses']['GET_MAP_OBJECTS']['status'])) else: log.warning("Получен неверный статус: {0}".format(response_dict['status_code'])) log.info("Ожидаем конца сканирования, и по ходу парсим данные") while not self.search.requests.empty(): if not self.search.response.empty(): cell = self.search.response.get() self.metrica.take_search(parse_map_cell(cell, self.session)) self.search.response.task_done() while not self.search.response.empty(): cell = self.search.response.get() self.metrica.take_search(parse_map_cell(cell, self.session)) self.search.response.task_done() self.api.set_position(lat, lng, alt) for cell in map_cells: self.ai.work_on_cell(cell, position, seen_pokemon=seen_pokemon, seen_pokestop=seen_pokestop, seen_gym=seen_gym)
def generate_coords(latitude, longitude, step_size, distance_limit): coords = [{'lat': latitude, 'lng': longitude}] for coord in Starline.generate_starline([latitude, longitude], step_size): lat = coord[0] + random.uniform(-step_size / 6, step_size / 6) lng = coord[1] + random.uniform(-step_size / 6, step_size / 6) coords.append({'lat': lat, 'lng': lng}) if distance(latitude, longitude, lat, lng) > distance_limit: break return coords
def generate_coords(latitude, longitude, step_size, distance_limit): coords = [{'lat': latitude, 'lng': longitude}] for coord in Spiral.generate_spiral(step_size, step_size): lat = latitude + coord[ 0] #+ random.uniform(-step_size/3, step_size/3) lng = longitude + coord[ 1] #+ random.uniform(-step_size/3, step_size/3) coords.append({'lat': lat, 'lng': lng}) if distance(latitude, longitude, lat, lng) > distance_limit: break return coords
def generate_coords(latitude, longitude, step_size, distance_limit): coords = [{'lat': latitude, 'lng': longitude}] step_limit = distance_limit/step_size*100 x = 0 y = 0 dx = 0 dy = -1 while True: if -step_limit / 2 < x <= step_limit / 2 and -step_limit / 2 < y <= step_limit / 2: lat = latitude + x * 0.8 * step_size + random_lat_long_delta() lng = longitude + y * step_size + random_lat_long_delta() coords.append({'lat': lat, 'lng': lng}) if distance(latitude, longitude, lat, lng) > distance_limit: break if x == y or x < 0 and x == -y or x > 0 and x == 1 - y: (dx, dy) = (-dy, dx) (x, y) = (x + dx, y + dy) return coords
def generate_coords(latitude, longitude, step_size, distance_limit): coords = [{'lat': latitude, 'lng': longitude}] step_limit = distance_limit / step_size * 100 x = 0 y = 0 dx = 0 dy = -1 while True: if -step_limit / 2 < x <= step_limit / 2 and -step_limit / 2 < y <= step_limit / 2: lat = latitude + x * 0.8 * step_size + random_lat_long_delta() lng = longitude + y * step_size + random_lat_long_delta() coords.append({'lat': lat, 'lng': lng}) if distance(latitude, longitude, lat, lng) > distance_limit: break if x == y or x < 0 and x == -y or x > 0 and x == 1 - y: (dx, dy) = (-dy, dx) (x, y) = (x + dx, y + dy) return coords
def _walk_to(self, speed, lat, lng, alt): dist = distance(i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng) steps = (dist + 0.0) / (speed + 0.0) # may be rational number intSteps = int(steps) residuum = steps - intSteps log.info('Бежим из ' + str((i2f(self.api._position_lat), i2f(self.api._position_lng))) + " в " + str(str((lat, lng))) + " на " + str(round(dist, 2)) + " по прямой. " + str(format_time(ceil(steps)))) if steps != 0: dLat = (lat - i2f(self.api._position_lat)) / steps dLng = (lng - i2f(self.api._position_lng)) / steps for i in range(intSteps): cLat = i2f(self.api._position_lat) + dLat + random_lat_long_delta() cLng = i2f(self.api._position_lng) + dLng + random_lat_long_delta() self.api.set_position(cLat, cLng, alt) self.ai.heartbeat() sleep(1) self.api.set_position(lat, lng, alt) self.ai.heartbeat()
def _walk_to(self, speed, lat, lng, alt): dist = distance(i2f(self.api._position_lat), i2f(self.api._position_lng), lat, lng) steps = (dist + 0.0) / (speed + 0.0) # may be rational number intSteps = int(steps) residuum = steps - intSteps log.info('Бежим из ' + str((i2f(self.api._position_lat), i2f(self.api._position_lng))) + " в " + str(str((lat, lng))) + " по прямой. " + str(format_time(ceil(steps)))) if steps != 0: dLat = (lat - i2f(self.api._position_lat)) / steps dLng = (lng - i2f(self.api._position_lng)) / steps for i in range(intSteps): cLat = i2f(self.api._position_lat) + dLat + random_lat_long_delta() cLng = i2f(self.api._position_lng) + dLng + random_lat_long_delta() self.api.set_position(cLat, cLng, alt) self.ai.heartbeat() self._work_at_position(i2f(self.api._position_lat), i2f(self.api._position_lng), alt, seen_pokemon=True, seen_pokestop=False, seen_gym=False) sleep(2*self.scanner.mode.is_human) self.api.set_position(lat, lng, alt) self.ai.heartbeat()
def work_on_cell(self, cell, position, seen_pokemon=False, seen_pokestop=False, seen_gym=False): self.position = position # # Искать ли покемонов на пути следования # if seen_pokemon: if self.scanner.mode.is_catch: if 'catchable_pokemons' in cell and len(cell['catchable_pokemons']) > 0: cell['catchable_pokemons'].sort(key=lambda x: distance(position[0], position[1], x['latitude'], x['longitude'])) for pokemon in cell['catchable_pokemons']: if self.catch_pokemon(pokemon) == PokemonCatch.NO_POKEBALLS: break if 'wild_pokemons' in cell and len(cell['wild_pokemons']) > 0: cell['wild_pokemons'].sort(key=lambda x: distance(position[0], position[1], x['latitude'], x['longitude'])) for pokemon in cell['wild_pokemons']: if self.catch_pokemon(pokemon) == PokemonCatch.NO_POKEBALLS: break # # Отвлекаться ли на покестопы # if seen_pokestop: if 'forts' in cell: # Only include those with a lat/long pokestops = [pokestop for pokestop in cell['forts'] if 'latitude' in pokestop and 'type' in pokestop] pokestops.sort(key=lambda x: distance(position[0], position[1], x['latitude'], x['longitude'])) if self.scanner.mode.is_farm: for pokestop in pokestops: pokestop_distance = round(distance(position[0], position[1], pokestop['latitude'], pokestop['longitude'])) if pokestop_distance > self.scanner.mode.step*150000: log.debug("Покестоп находится на большом растоянии ({0}), вернемся к нему позже.".format(pokestop_distance)) continue pokestop_id = str(pokestop['id']) if pokestop_id in self.seen_pokestop: if self.seen_pokestop[pokestop_id] + 350 > time.time(): continue worker = MoveToPokestop(pokestop, self) worker.work() worker = SeenPokestop(pokestop, self) hack_chain = worker.work() if hack_chain > 10: sleep(10) self.seen_pokestop[pokestop_id] = time.time() self.inventory.update() self.inventory.recycle() self.metrica.take_ping() if seen_gym: if 'forts' in cell: gyms = [gym for gym in cell['forts'] if 'gym_points' in gym] gyms.sort(key=lambda x: distance(position[0], position[1], x['latitude'], x['longitude'])) if self.scanner.mode.is_lookup or self.scanner.mode.is_defender: for gym in gyms: gym_distance = round(distance(position[0], position[1], gym['latitude'], gym['longitude'])) if gym_distance > self.scanner.mode.step*150000: log.debug("Gym находится на большом растоянии ({0}), вернемся к нему позже.".format(gym_distance)) continue gym_id = str(gym['id']) if self.scanner.mode.is_defender or self.scanner.mode.is_farm or self.scanner.mode.is_catch: if gym_id in self.seen_gym: if self.seen_gym[gym_id] + 350 > time.time(): continue worker = MoveToGym(gym, self) worker.work() worker = SeenGym(gym, self) hack_chain = worker.work() if hack_chain > 10: sleep(10) self.seen_gym[gym_id] = time.time() self.metrica.take_ping() self.metrica.take_ping()
def _work_at_position(self, lat, lng, alt, seen_pokemon=False, seen_pokestop=False, seen_gym=False, data=None): position = (lat, lng, alt) map_cells = [] map_cells_timestamp = time.time() if self.use_search: self.search.search(lat, lng) try: radius_array = [] if seen_pokemon: radius_array.append(190) if (seen_pokestop | seen_gym) & self.use_long_radius: radius_array.append(1000) for radius in radius_array: log.debug("Сканируем область в радиусе {} метров.".format(radius)) response_index = 0 sleep(self.ai.delay_scan) while response_index < 5: cellid = get_cell_ids(lat, lng, radius=radius) timestamp = [0, ] * len(cellid) self.api.set_position(lat, lng, 0) self.ai.heartbeat() response_dict = self.api.get_map_objects(latitude=lat, longitude=lng, since_timestamp_ms=timestamp, cell_id=cellid) if response_dict and 'status_code' in response_dict: if response_dict['status_code'] is 1: if 'responses' in response_dict: if 'GET_MAP_OBJECTS' in response_dict['responses']: if 'status' in response_dict['responses']['GET_MAP_OBJECTS']: if response_dict['responses']['GET_MAP_OBJECTS']['status'] is 1: map_cells.extend(response_dict['responses']['GET_MAP_OBJECTS']['map_cells']) log.debug('Response dictionary: \r\n{}'.format(pprint.PrettyPrinter(indent=4).pformat(response_dict['responses']['GET_MAP_OBJECTS']))) break response_index += 1 action_delay(self.ai.delay_scan, self.ai.delay_scan*2) except Exception as e: log.error("Ошибка в обработке дочернего потока: {}".format(e)) if self.use_search: log.info("Ожидаем конца сканирования, и по ходу парсим данные") while not self.search.requests.empty(): if not self.search.response.empty(): cell = self.search.response.get() self.metrica.take_search(parse_map_cell(cell, self.session)) self.search.response.task_done() while not self.search.response.empty(): cell = self.search.response.get() self.metrica.take_search(parse_map_cell(cell, self.session)) self.search.response.task_done() # Update current scanner location self.metrica.take_position(position) self.api.set_position(lat, lng, alt) map_cells.sort(key=lambda x: distance(lat, lng, x['forts'][0]['latitude'], x['forts'][0]['longitude']) if 'forts' in x and x['forts'] != [] else 1e6) log.debug("Получена информация о карте в размере {0} ячеек".format(len(map_cells))) for cell in map_cells: self.metrica.take_search(parse_map_cell(cell, self.session), timestamp=map_cells_timestamp) if self.use_work_on_cell: for cell in map_cells: self.ai.work_on_cell(cell, position, seen_pokemon=seen_pokemon, seen_pokestop=seen_pokestop, seen_gym=seen_gym)
def _pythagorean(lat, lng): return sqrt((lat ** 2) + (lng ** 2)) def get_google_polilyne(coords): return 'http://maps.googleapis.com/maps/api/staticmap?size=400x400&apikey={1}&path=enc:{0}'.format(encode_coords(coords), "AIzaSyA3OUM5s1t1mX3mqtSMNSToPD_uaTAdP3M") init_lat = 55.0467073568 init_lng = 73.3111072005 dest_lat = 55.0487228502 dest_lng = 73.3131540588 walk_speed = 4 walk_coords = [] walk_distance = distance(init_lat, init_lng, dest_lat, dest_lng) walk_distance_total = max(1, walk_distance) walk_steps = (walk_distance + 0.0) / (walk_speed + 0.0) if walk_distance < walk_speed or int(walk_steps) <= 1: delta_lat = 0 delta_lng = 0 magnitude = 0 else: delta_lat = (dest_lat - init_lat) / int(walk_steps) delta_lng = (dest_lng - init_lng) / int(walk_steps) magnitude = _pythagorean(delta_lat, delta_lng) print "Бежим из [{}, {}] в [{}, {}] на расстояние {}, со скоростью {}, в {} шагов".format(init_lat, init_lng, dest_lat, dest_lng, round(walk_distance, 2), walk_speed, round(walk_steps)) if (delta_lat == 0 and delta_lng == 0) or walk_distance < walk_speed:
def _work_at_position(self, lat, lng, alt, seen_pokemon=False, seen_pokestop=False, seen_gym=False, data=None): position = (lat, lng, alt) cellid = get_cell_ids(lat, lng) timestamp = [ 0, ] * len(cellid) map_cells = list() self.api.get_map_objects(latitude=f2i(lat), longitude=f2i(lng), since_timestamp_ms=timestamp, cell_id=cellid) response_dict = self.api.call() sleep(0.2) self.search.search(lat, lng) if response_dict and 'status_code' in response_dict: if response_dict['status_code'] is 1: if 'responses' in response_dict: if 'GET_MAP_OBJECTS' in response_dict['responses']: if 'status' in response_dict['responses'][ 'GET_MAP_OBJECTS']: if response_dict['responses']['GET_MAP_OBJECTS'][ 'status'] is 1: map_cells = response_dict['responses'][ 'GET_MAP_OBJECTS']['map_cells'] # Update current scanner location self.metrica.take_position(position) map_cells.sort(key=lambda x: distance( lat, lng, x['forts'][0]['latitude'], x['forts'][0]['longitude']) if 'forts' in x and x['forts'] != [] else 1e6) log.debug( "Получена информация о карте в размере {0} ячеек" .format(len(map_cells))) for cell in map_cells: self.metrica.take_search( parse_map_cell(cell, self.session)) else: log.warning( "Получен неверный статус: {0}".format( response_dict['responses'] ['GET_MAP_OBJECTS']['status'])) else: log.warning("Получен неверный статус: {0}".format( response_dict['status_code'])) log.info("Ожидаем конца сканирования, и по ходу парсим данные") while not self.search.requests.empty(): if not self.search.response.empty(): cell = self.search.response.get() self.metrica.take_search(parse_map_cell(cell, self.session)) self.search.response.task_done() while not self.search.response.empty(): cell = self.search.response.get() self.metrica.take_search(parse_map_cell(cell, self.session)) self.search.response.task_done() self.api.set_position(lat, lng, alt) for cell in map_cells: self.ai.work_on_cell(cell, position, seen_pokemon=seen_pokemon, seen_pokestop=seen_pokestop, seen_gym=seen_gym)