Example #1
0
    def navigate(self, map_cells):
        # type: (List[Cell]) -> None
        try:
            camp_site = self.camping_sites[self.pointer]

            lat, lng = camp_site
            position = (lat, lng, 0.0)

            unit = self.config.distance_unit  # Unit to use when printing formatted distance
            dist = floor(distance(self.stepper.current_lat, self.stepper.current_lng, lat, lng))

            # Given the random delta we add to the
            if dist > 0:
                logger.log(
                    "[#] Moving to camping position at {},{} at distance {}".format(lat, lng, format_dist(dist, unit)))
                self.stepper.walk_to(*position)
                self.stepper.snap_to(*position)
            else:
                # fire any events on these cells
                logger.log("[#] Camping on {},{}".format(lat, lng))
                position_map_cells = self.bot.mapper.get_cells(lat, lng)
                self.bot.work_on_cells(position_map_cells)

            sleep(5)

        except KeyError:
            logger.log("[#] No campsite location found", color="red")
Example #2
0
    def navigate(self, map_cells):
        # type: (List[Cell]) -> List([Destination])

        for cell in map_cells:
            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.stepper.current_lat, self.stepper.current_lng, x.latitude, x.longitude))

            for fort in pokestops:

                response_dict = self.api_wrapper.fort_details(
                    fort_id=fort.fort_id,
                    latitude=fort.latitude,
                    longitude=fort.longitude
                ).call()

                if response_dict is None:
                    fort_name = fort.fort_id
                else:
                    fort_name = response_dict["fort"].fort_name

                if isinstance(fort_name, bytes):
                    fort_name = fort_name.decode()

                yield Destination(fort.latitude, fort.longitude, 0.0, name="PokeStop \"{}\"".format(fort_name))

                self.api_wrapper.player_update(latitude=fort.latitude, longitude=fort.longitude)
                sleep(2)
    def navigate(self, map_cells):
        # type: (List[Cell]) -> List[Direction]
        try:
            camp_site = self.camping_sites[self.pointer]

            lat, lng = camp_site
            position = (lat, lng, 0.0)

            yield Destination(*position, name="Camping position at {},{}".format(lat, lng), exact_location=True)

            sleep(5)

        except IndexError:
            logger.log("[#] No campsite location found", color="red")
Example #4
0
def _do_evolve(bot, name):
    if bot.config.evolve_pokemon:
        bot.api_wrapper.get_player().get_inventory()
        response_dict = bot.api_wrapper.call()
        pokemon_list = response_dict['pokemon']
        base_pokemon = _get_base_pokemon(bot, name)
        base_name = base_pokemon['name']
        pokemon_id = base_pokemon['id']
        num_evolve = base_pokemon['requirements']
        pokemon_candies = bot.candies.get(int(pokemon_id), 0)
        evolve_list = [str.lower(str(x)) for x in bot.config.evolve_filter]
        if base_name.lower() in evolve_list or 'all' in evolve_list:
            if num_evolve is None:
                _log('Can\'t evolve {}'.format(base_name), color='yellow')
                return

            pokemon_evolve = [pokemon for pokemon in pokemon_list if pokemon.pokemon_id is pokemon_id]
            if pokemon_evolve is None:
                return
            pokemon_evolve.sort(key=lambda p: p.combat_power, reverse=True)

            num_evolved = 0
            for pokemon in pokemon_evolve:
                if num_evolve > pokemon_candies:
                    break
                bot.api_wrapper.evolve_pokemon(pokemon_id=pokemon.unique_id)
                response = bot.api_wrapper.call()
                if response['evolution'].success:
                    pokemon_candies -= (num_evolve - 1)
                    num_evolved += 1
                    evolved_id = response['evolution'].get_pokemon().pokemon_id
                    _log('Evolved {} into {}'.format(base_name, bot.pokemon_list[evolved_id - 1]['Name']))

                    manager.fire_with_context('pokemon_evolved', bot, pokemon=pokemon, evolution=evolved_id)

                    sleep(2)
                else:
                    _log('Evolving {} failed'.format(base_name), color='red')
                    break

            if num_evolve > pokemon_candies:
                _log('Not enough candies for {} to evolve'.format(base_name), color='yellow')
            elif len(pokemon_evolve) > num_evolved:
                _log('Stopped evolving due to error', color='red')
            else:
                _log('Evolved {} {}(s)'.format(num_evolved, base_name))
Example #5
0
    def navigate(self, map_cells):
        # type: (List[Cell]) -> None
        try:
            camp_site = self.camping_sites[self.pointer]

            lat, lng = camp_site
            position = (lat, lng, 0.0)

            yield Destination(*position,
                              name="camping position at {},{}".format(
                                  lat, lng),
                              exact_location=True)

            sleep(5)

        except KeyError:
            logger.log("[#] No campsite location found", color="red")
Example #6
0
def incubate_eggs(bot, coords=None):

    if coords is None:
        return

    if bot.config.incubation_fill:

        inventory = bot.update_player_and_inventory()

        # Hatch any eggs that need to be hatched
        bot.api_wrapper.get_hatched_eggs().call()
        sleep(3)

        eggs = [egg for egg in inventory["eggs"] if egg.egg_incubator_id == ""]
        incubators = [incu for incu in inventory["egg_incubators"] if incu.pokemon_id == 0 and (
            bot.config.incubation_use_all or incu.item_id == 901)]

        in_use_count = len(inventory["egg_incubators"]) - len(incubators)

        # order eggs by distance longest -> shortest
        eggs_by_distance = sorted(eggs, key=lambda x: x.total_distance, reverse=True)

        for egg_distance in bot.config.incubation_priority:
            try:
                egg_restriction = int(bot.config.incubation_restrict[egg_distance])
            except KeyError:
                egg_restriction = None

            for egg in eggs_by_distance:
                if len(incubators) == 0:
                    log("No more free incubators ({}/{} in use)".format(in_use_count, len(inventory["egg_incubators"])), "yellow")
                    return

                if egg_restriction is None:
                    incubator = incubators.pop()
                    bot.fire("incubate_egg", incubator=incubator, egg=egg)
                    in_use_count += 1
                else:
                    for incubator in incubators:
                        if incubator.item_id == egg_restriction:
                            bot.fire("incubate_egg", incubator=incubator, egg=egg)
                            in_use_count += 1
                            incubators.remove(incubator)
                            break
Example #7
0
    def navigate(self, map_cells):
        # type: (List[Cell]) -> None

        for cell in map_cells:
            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.stepper.current_lat, self.stepper.
                                       current_lng, x.latitude, x.longitude))

            for fort in pokestops:

                response_dict = self.api_wrapper.fort_details(
                    fort_id=fort.fort_id,
                    latitude=fort.latitude,
                    longitude=fort.longitude).call()

                if response_dict is None:
                    fort_name = fort.fort_id
                else:
                    fort_name = response_dict["fort"].fort_name

                yield Destination(fort.latitude,
                                  fort.longitude,
                                  0.0,
                                  name="PokeStop \"{}\"".format(fort_name))

                self.api_wrapper.player_update(latitude=fort.latitude,
                                               longitude=fort.longitude)
                sleep(2)