示例#1
0
    def snipe(self, pokemon):
        """Snipe a Pokemon by teleporting.

        Args:
            pokemon: Pokemon to snipe.
        """
        last_position = self.bot.position[0:2]
        self.bot.heartbeat()
        self._teleport_to(pokemon)
        catch_worker = PokemonCatchWorker(pokemon, self.bot)
        api_encounter_response = catch_worker.create_encounter_api_call()
        time.sleep(SNIPE_SLEEP_SEC)
        self._teleport_back(last_position)
        self.bot.api.set_position(last_position[0], last_position[1], 0)
        time.sleep(SNIPE_SLEEP_SEC)
        self.bot.heartbeat()
        catch_worker.work(api_encounter_response)
        self.add_caught(pokemon)
        return WorkerResult.SUCCESS
    def snipe(self, pokemon):
        """Snipe a Pokemon by teleporting.

        Args:
            pokemon: Pokemon to snipe.
        """
        last_position = self.bot.position[0:2]
        self.bot.heartbeat()
        self._teleport_to(pokemon)
        catch_worker = PokemonCatchWorker(pokemon, self.bot)
        api_encounter_response = catch_worker.create_encounter_api_call()
        time.sleep(SNIPE_SLEEP_SEC)
        self._teleport_back(last_position)
        self.bot.api.set_position(last_position[0], last_position[1], 0)
        time.sleep(SNIPE_SLEEP_SEC)
        self.bot.heartbeat()
        catch_worker.work(api_encounter_response)
        self.add_caught(pokemon)
        return WorkerResult.SUCCESS
示例#3
0
    def snipe(self, snipe_info):
        self.pokemon_caught.add(snipe_info.id)
        self.pokemon_wait_snipe.discard(snipe_info.id)

        last_position = self.bot.position[0:2]
        self.bot.heartbeat()

        self._teleport_to(snipe_info)
        pokemon = self.find_pokemon(snipe_info, True)

        if pokemon == None:
            self._teleport_back(last_position)
            return

        self._encountered(pokemon)
        catch_worker = PokemonCatchWorker(pokemon, self.bot, self.config)
        api_encounter_response = catch_worker.create_encounter_api_call()
        self._teleport_back(last_position)
        self.bot.heartbeat()
        catch_worker.work(api_encounter_response)
    def snipe(self, pokemon):
        last_position = self.bot.position[0:2]

        self.bot.heartbeat()

        logger.log('Teleporting to {} ({})'.format(pokemon['name'], format_dist(pokemon['dist'], self.unit)), 'green')
        self.bot.api.set_position(pokemon['latitude'], pokemon['longitude'], 0)

        logger.log('Encounter pokemon', 'green')
        catch_worker = PokemonCatchWorker(pokemon, self.bot)
        api_encounter_response = catch_worker.create_encounter_api_call()

        time.sleep(2)
        logger.log('Teleporting back to previous location..', 'green')
        self.bot.api.set_position(last_position[0], last_position[1], 0)
        time.sleep(2)
        self.bot.heartbeat()

        catch_worker.work(api_encounter_response)
        self.add_caught(pokemon)

        return WorkerResult.SUCCESS
示例#5
0
 def _teleport_back_and_catch(self, position_array, pokemon):
     catch_worker = PokemonCatchWorker(pokemon, self.bot)
     api_encounter_response = catch_worker.create_encounter_api_call()
     self._teleport_back(position_array)
     catch_worker.work(api_encounter_response)
示例#6
0
 def _catch(self, pokemon):
     catch_worker = PokemonCatchWorker(pokemon, self.bot)
     api_encounter_response = catch_worker.create_encounter_api_call()
     catch_worker.work(api_encounter_response)
示例#7
0
    def snipe(self, pokemon):
        # Backup position before anything
        last_position = self.bot.position[0:2]

        # Teleport, so that we can see nearby stuff
        # self.bot.heartbeat() was moved to thread, if you do want to call it, you need sleep 10s.
        self.bot.hb_locked = True
        self._teleport_to(pokemon)

        # Simulate kind of a lag after teleporting/moving to a long distance
        time.sleep(2)

        # If social is enabled and if no verification is needed, trust it. Otherwise, update IDs!
        verify = not pokemon.get('encounter_id') or not pokemon.get(
            'spawn_point_id')
        exists = not verify and self.bot.config.enable_social

        # If social is disabled, we will have to make sure the target still exists
        if verify:
            nearby_pokemons = []
            nearby_stuff = self.bot.get_meta_cell()

            # Sleep some time, so that we have accurate results (successfull cell data request)
            time.sleep(2)

            # Retrieve nearby pokemons for validation
            if 'wild_pokemons' in nearby_stuff:
                nearby_pokemons.extend(nearby_stuff['wild_pokemons'])
            if 'catchable_pokemons' in nearby_stuff:
                nearby_pokemons.extend(nearby_stuff['catchable_pokemons'])

            # Make sure the target still/really exists (TODO: validate expiration)
            for nearby_pokemon in nearby_pokemons:
                is_wild = 'pokemon_data' in nearby_pokemon
                nearby_pokemon_id = nearby_pokemon['pokemon_data'][
                    'pokemon_id'] if is_wild else nearby_pokemon['pokemon_id']

                if nearby_pokemon_id == pokemon['pokemon_id']:
                    exists = True

                    # Also, if the IDs arent valid, update them!
                    if not pokemon['encounter_id'] or not pokemon[
                            'spawn_point_id']:
                        pokemon['encounter_id'] = nearby_pokemon[
                            'encounter_id']
                        pokemon['spawn_point_id'] = nearby_pokemon[
                            'spawn_point_id']
                        pokemon['disappear_time'] = nearby_pokemon[
                            'last_modified_timestamp_ms'] if is_wild else nearby_pokemon[
                                'expiration_timestamp_ms']
                    break

        # If target exists, catch it, otherwise ignore
        if exists:
            self._encountered(pokemon)
            catch_worker = PokemonCatchWorker(pokemon, self.bot, self.config)
            api_encounter_response = catch_worker.create_encounter_api_call()
            time.sleep(self.config.get('snipe_sleep_sec', 2))
            self._teleport_back(last_position)
            self.bot.api.set_position(last_position[0], last_position[1],
                                      self.alt, False)
            time.sleep(self.config.get('snipe_sleep_sec', 2))
            catch_worker.work(api_encounter_response)
        else:
            self._emit_failure('{} doesnt exist anymore. Skipping...'.format(
                pokemon['name']))
            time.sleep(self.config.get('snipe_sleep_sec', 2))
            self._teleport_back(last_position)
            self.bot.api.set_position(last_position[0], last_position[1],
                                      self.alt, False)
            time.sleep(self.config.get('snipe_sleep_sec', 2))

        self.inspect(pokemon)
        self.bot.hb_locked = False
        return WorkerResult.SUCCESS
    def snipe(self, pokemon):
        # Backup position before anything
        last_position = self.bot.position[0:2]

        # Teleport, so that we can see nearby stuff
        # self.bot.heartbeat() was moved to thread, if you do want to call it, you need sleep 10s.
        self.bot.hb_locked = True
        self._teleport_to(pokemon)

        # Simulate kind of a lag after teleporting/moving to a long distance
        time.sleep(2)

        # If social is enabled, trust it
        exists = self.bot.config.enable_social
        verify = not self.bot.config.enable_social

        # If social is disabled, we will have to make sure the target still exists
        if verify:
            nearby_pokemons = []
            nearby_stuff = self.bot.get_meta_cell()

            # Sleep some time, so that we have accurate results (successfull cell data request)
            time.sleep(2)

            # Retrieve nearby pokemons for validation
            if 'wild_pokemons' in nearby_stuff:
                nearby_pokemons.extend(nearby_stuff['wild_pokemons'])
            if 'catchable_pokemons' in nearby_stuff:
                nearby_pokemons.extend(nearby_stuff['catchable_pokemons'])

            # Make sure the target still/really exists (TODO: validate expiration)
            for nearby_pokemon in nearby_pokemons:
                is_wild = 'pokemon_data' in nearby_pokemon
                nearby_pokemon_id = nearby_pokemon['pokemon_data']['pokemon_id'] if is_wild else nearby_pokemon['pokemon_id']

                if nearby_pokemon_id == pokemon['pokemon_id']:
                    exists = True

                    # Also, if the IDs arent valid, update them!
                    if not pokemon['encounter_id'] or not pokemon['spawnpoint_id']:
                        pokemon['encounter_id'] = nearby_pokemon['encounter_id']
                        pokemon['spawn_point_id'] = nearby_pokemon['spawn_point_id']
                        pokemon['disappear_time'] = nearby_pokemon['last_modified_timestamp_ms'] if is_wild else nearby_pokemon['expiration_timestamp_ms']
                    break

        # If target exists, catch it, otherwise ignore
        if exists:
            self._encountered(pokemon)
            catch_worker = PokemonCatchWorker(pokemon, self.bot, self.config)
            api_encounter_response = catch_worker.create_encounter_api_call()
            time.sleep(self.config.get('snipe_sleep_sec', 2))
            self._teleport_back(last_position)
            self.bot.api.set_position(last_position[0], last_position[1], self.alt, False)
            time.sleep(self.config.get('snipe_sleep_sec', 2))
            catch_worker.work(api_encounter_response)
        else:
            self._emit_failure('{} doesnt exist anymore. Skipping...'.format(pokemon['name']))
            time.sleep(self.config.get('snipe_sleep_sec', 2))
            self._teleport_back(last_position)
            self.bot.api.set_position(last_position[0], last_position[1], self.alt, False)
            time.sleep(self.config.get('snipe_sleep_sec', 2))

        self.inspect(pokemon)
        self.bot.hb_locked = False
        return WorkerResult.SUCCESS