def _work_on_forts(self, position, map_cells): forts = filtered_forts(position[0], position[1], sum([cell.get("forts", []) for cell in map_cells], [])) if forts: walk_worker = WalkTowardsFortWorker(forts[0], self) walk_worker.work() spinner_worker = SeenFortWorker(forts[0], self) spinner_worker.work()
def _work_on_forts(self, position, map_cells): # type: (Tuple[float, float], List[Cell]) -> None forts = filtered_forts(position[0], position[1], sum([cell.pokestops for cell in map_cells], [])) if forts: walk_worker = WalkTowardsFortWorker(forts[0], self) walk_worker.work() spinner_worker = SeenFortWorker(forts[0], self) spinner_worker.work()
def work_on_cell(self, cell, include_fort_on_path): # check if token session has expired self.check_session() self._remove_ignored_pokemon(cell) if (self.config.mode == "all" or self.config.mode == "poke") and 'catchable_pokemons' in cell and len(cell['catchable_pokemons']) > 0: logger.log('[#] Something rustles nearby!') # Sort all by distance from current pos- eventually this should # build graph & A* it cell['catchable_pokemons'].sort(key=lambda x: distance(self.position[0], self.position[1], x['latitude'], x['longitude'])) user_web_catchable = 'web/catchable-%s.json' % self.config.username for pokemon in cell['catchable_pokemons']: with open(user_web_catchable, 'w') as outfile: json.dump(pokemon, outfile) if self.catch_pokemon(pokemon) == PokemonCatchWorker.NO_POKEBALLS: break with open(user_web_catchable, 'w') as outfile: json.dump({}, outfile) if (self.config.mode == "all" or self.config.mode == "poke") and 'wild_pokemons' in cell and len(cell['wild_pokemons']) > 0: # Sort all by distance from current pos- eventually this should # build graph & A* it cell['wild_pokemons'].sort(key=lambda x: distance(self.position[0], self.position[1], x['latitude'], x['longitude'])) for pokemon in cell['wild_pokemons']: if self.catch_pokemon(pokemon) == PokemonCatchWorker.NO_POKEBALLS: break if include_fort_on_path: if 'forts' in cell: # Only include those with a lat/long forts = [fort for fort in cell['forts'] if 'latitude' in fort and 'type' in fort] # gyms = [gym for gym in cell['forts'] if 'gym_points' in gym] # Sort all by distance from current pos- eventually this should # build graph & A* it forts.sort(key=lambda x: distance(self.position[0], self.position[1], x['latitude'], x['longitude'])) for fort in forts: walk_worker = WalkTowardsFortWorker(fort, self) walk_worker.work() if self.config.mode == "all" or self.config.mode == "farm": spinner_worker = SeenFortWorker(fort, self) spinner_worker.work()
def work_on_cell(self, cell, include_fort_on_path): # type: (Cell, bool) -> None self.fire("pokemon_found", pokemon=cell.catchable_pokemon + cell.wild_pokemon) self._remove_ignored_pokemon(cell) if self.config.mode in ["all", "poke"]: pass if (self.config.mode == "all" or self.config.mode == "poke") and len(cell.catchable_pokemon) > 0: logger.log('[#] Something rustles nearby!') # Sort all by distance from current pos- eventually this should # build graph & A* it cell.catchable_pokemon.sort(key=lambda x: x.get("time_until_hidden_ms", 0)) for pokemon in cell.catchable_pokemon: if self.catch_pokemon(pokemon) == PokemonCatchWorker.NO_POKEBALLS: break if (self.config.mode == "all" or self.config.mode == "poke") and len(cell.wild_pokemon) > 0: # Sort all by distance from current pos- eventually this should # build graph & A* it # cell.wild_pokemon.sort(key=lambda x: distance(self.position[0], self.position[1], x['latitude'], x['longitude'])) cell.wild_pokemon.sort(key=lambda x: x.get("time_until_hidden_ms", 0)) for pokemon in cell.wild_pokemon: if self.catch_pokemon(pokemon) == PokemonCatchWorker.NO_POKEBALLS: break if include_fort_on_path: # Only include those with a lat/long pokestops = [pokestop for pokestop in cell.pokestops if pokestop.latitude is not None and pokestop.longitude is not None] # gyms = [gym for gym in cell['forts'] if 'gym_points' in gym] # Sort all by distance from current pos- eventually this should # build graph & A* it pokestops.sort(key=lambda x: distance(self.position[0], self.position[1], x.latitude, x.longitude)) for pokestop in pokestops: walk_worker = WalkTowardsFortWorker(pokestop, self) walk_worker.work() if self.config.mode == "all" or self.config.mode == "farm": spinner_worker = SeenFortWorker(pokestop, self) spinner_worker.work()