Example #1
0
    def work_on_cell(self, cell, position):
        if 'catchable_pokemons' in cell:
            print '[#] Something rustles nearby!'
            for pokemon in cell['catchable_pokemons']:
                worker = PokemonCatchWorker(pokemon, self)
                worker.work()
        if 'wild_pokemons' in cell:
            for pokemon in cell['wild_pokemons']:
                worker = PokemonCatchWorker(pokemon, self)
                worker.work()
                
        # After [self.noballs = True] and first spining, check if 50 pokeballs was gathered, if so stop spining
        if self.noballs and self.ballstock[1] >= 50:
            print ('[#] Gathered 50/50 pokeballs, continue catching!')
            self.noballs = False
        elif self.noballs and self.ballstock[1] < 50:
            print ('[#] Gathered ' + str(self.ballstock[1]) + '/50 pokeballs, continue farming...') 
        
        if self.config.spinstop or self.noballs:
            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]

                # 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], fort['latitude'], fort['longitude']))
                for fort in cell['forts']:
                    worker = SeenFortWorker(fort, self)
                    hack_chain = worker.work()
                    if hack_chain > 10:
                        print('[-] Anti-ban resting....')
                        break
Example #2
0
 def work_on_cell(self, cell, position):
     if 'catchable_pokemons' in cell:
         print '[#] Something rustles nearby!'
         for pokemon in cell['catchable_pokemons']:
             worker = PokemonCatchWorker(pokemon, self)
             worker.work()
     if 'wild_pokemons' in cell:
         for pokemon in cell['wild_pokemons']:
             worker = PokemonCatchWorker(pokemon, self)
             worker.work()
     if self.config.spinstop:
         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]
             
             # 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], fort['latitude'], fort['longitude']))
             for fort in cell['forts']:
                 worker = SeenFortWorker(fort, self)
                 hack_chain = worker.work()
                 if hack_chain > 10:
                     print('need a rest')
                     break
    def work(self):
        encounter_id = self.pokemon['encounter_id']
        spawnpoint_id = self.pokemon['spawnpoint_id']
        player_latitude = self.pokemon['latitude']
        player_longitude = self.pokemon['longitude']

        dist = distance(self.position[0], self.position[1], player_latitude, player_longitude)

        print('[x] Found pokemon at distance {}m'.format(dist))
        if dist > 10:
            position = (player_latitude, player_longitude, 0.0)
            if self.config.walk > 0:
                self.api.walk(self.config.walk, *position,walking_hook=None)
                print('[x] Walked to Pokemon')
            else:
                self.api.set_position(*position)
                print('[x] Teleported to Pokemon')
            self.api.player_update(latitude=player_latitude,longitude=player_longitude)
            response_dict = self.api.call()
            time.sleep(1.2)

        self.api.encounter(encounter_id=encounter_id,spawnpoint_id=spawnpoint_id,player_latitude=player_latitude,player_longitude=player_longitude)
        response_dict = self.api.call()

        if response_dict and 'responses' in response_dict:
            if 'ENCOUNTER' in response_dict['responses']:
                if 'status' in response_dict['responses']['ENCOUNTER']:
                    if response_dict['responses']['ENCOUNTER']['status'] is 1:
                        cp=0
                        if 'wild_pokemon' in response_dict['responses']['ENCOUNTER']:
                            pokemon=response_dict['responses']['ENCOUNTER']['wild_pokemon']
                            if 'pokemon_data' in pokemon and 'cp' in pokemon['pokemon_data']:
                                cp=pokemon['pokemon_data']['cp']
                                pokemon_num=int(pokemon['pokemon_data']['pokemon_id'])-1
                                pokemon_name=self.pokemon_list[int(pokemon_num)]['Name']
                                print('[#] A Wild ' + str(pokemon_name) + ' appeared! [CP' + str(cp) + ']')
                        while(True):
                            id_list1 = self.count_pokemon_inventory()
                            
                            if self.ballstock[1] > 0:
                                #DEBUG - Hide
                                #print 'use Poke Ball'
                                pokeball = 1
                            else:
                                #DEBUG - Hide
                                #print 'no Poke Ball'
                                pokeball = 0
                                
                            if cp > 200 and self.ballstock[2] > 0:
                                #DEBUG - Hide
                                #print 'use Great Ball'
                                pokeball = 2
                                
                            if cp > 400 and self.ballstock[3] > 0:
                                #DEBUG - Hide
                                #print 'use Utra Ball'
                                pokeball = 3

                            if pokeball is 0:
                                print('[x] Out of pokeballs...')
                                # TODO: Begin searching for pokestops.
                                print('[x] Farming pokeballs...')
                                self.noballs = True
                                break
                            
                            print('[x] Using ' + self.item_list[str(pokeball)] + '...')
                            self.api.catch_pokemon(encounter_id = encounter_id,
                                pokeball = pokeball,
                                normalized_reticle_size = 1.950,
                                spawn_point_guid = spawnpoint_id,
                                hit_pokemon = 1,
                                spin_modifier = 1,
                                NormalizedHitPosition = 1)
                            response_dict = self.api.call()

                            #DEBUG - Hide
                            #print ('used ' + self.item_list[str(pokeball)] + '> [-1]')
                            self.ballstock[pokeball] -= 1 

                            if response_dict and \
                                'responses' in response_dict and \
                                'CATCH_POKEMON' in response_dict['responses'] and \
                                'status' in response_dict['responses']['CATCH_POKEMON']:
                                status = response_dict['responses']['CATCH_POKEMON']['status']
                                if status is 2:
                                    print('[-] Attempted to capture ' + str(pokemon_name) + ' - failed.. trying again!')
                                    time.sleep(1.25)
                                    continue
                                if status is 3:
                                    print('[x] Oh no! ' + str(pokemon_name) + ' vanished! :(')
                                if status is 1:
                                    if cp < self.config.cp:
                                        print('[x] Captured ' + str(pokemon_name) + '! [CP' + str(cp) + '] - exchanging for candy')
                                        id_list2 = self.count_pokemon_inventory()
                                        try:
                                            # Transfering Pokemon
                                            self.transfer_pokemon(list(Set(id_list2) - Set(id_list1))[0])
                                        except:
                                            print('[###] Your inventory is full! Please manually delete some items.')
                                            break
                                    else:
                                        print('[x] Captured ' + str(pokemon_name) + '! [CP' + str(cp) + ']')
                            break
        time.sleep(5)
    def work(self):
        encounter_id = self.pokemon["encounter_id"]
        spawnpoint_id = self.pokemon["spawnpoint_id"]
        player_latitude = self.pokemon["latitude"]
        player_longitude = self.pokemon["longitude"]

        dist = distance(self.position[0], self.position[1], player_latitude, player_longitude)

        print("[x] Found pokemon at distance {}m".format(dist))
        if dist > 10:
            position = (player_latitude, player_longitude, 0.0)
            if self.config.walk > 0:
                self.api.walk(self.config.walk, *position, walking_hook=None)
                print("[x] Walked to Pokemon")
            else:
                self.api.set_position(*position)
                print("[x] Teleported to Pokemon")
            self.api.player_update(latitude=player_latitude, longitude=player_longitude)
            response_dict = self.api.call()
            time.sleep(1.2)

        self.api.encounter(
            encounter_id=encounter_id,
            spawnpoint_id=spawnpoint_id,
            player_latitude=player_latitude,
            player_longitude=player_longitude,
        )
        response_dict = self.api.call()

        if response_dict and "responses" in response_dict:
            if "ENCOUNTER" in response_dict["responses"]:
                if "status" in response_dict["responses"]["ENCOUNTER"]:
                    if response_dict["responses"]["ENCOUNTER"]["status"] is 1:
                        cp = 0
                        if "wild_pokemon" in response_dict["responses"]["ENCOUNTER"]:
                            pokemon = response_dict["responses"]["ENCOUNTER"]["wild_pokemon"]
                            if "pokemon_data" in pokemon and "cp" in pokemon["pokemon_data"]:
                                cp = pokemon["pokemon_data"]["cp"]
                                pokemon_num = int(pokemon["pokemon_data"]["pokemon_id"]) - 1
                                pokemon_name = self.pokemon_list[int(pokemon_num)]["Name"]
                                print("[#] A Wild " + str(pokemon_name) + " appeared! [CP" + str(cp) + "]")
                        while True:
                            id_list1 = self.count_pokemon_inventory()

                            if self.ballstock[1] > 0:
                                # DEBUG - Hide
                                # print 'use Poke Ball'
                                pokeball = 1
                            else:
                                # DEBUG - Hide
                                # print 'no Poke Ball'
                                pokeball = 0

                            if cp > 200 and self.ballstock[2] > 0:
                                # DEBUG - Hide
                                # print 'use Great Ball'
                                pokeball = 2

                            if cp > 400 and self.ballstock[3] > 0:
                                # DEBUG - Hide
                                # print 'use Utra Ball'
                                pokeball = 3

                            if pokeball is 0:
                                print("[x] Out of pokeballs...")
                                # TODO: Begin searching for pokestops.
                                print("[x] Farming pokeballs...")
                                self.noballs = True
                                break

                            print("[x] Using " + self.item_list[str(pokeball)] + "...")
                            self.api.catch_pokemon(
                                encounter_id=encounter_id,
                                pokeball=pokeball,
                                normalized_reticle_size=1.950,
                                spawn_point_guid=spawnpoint_id,
                                hit_pokemon=1,
                                spin_modifier=1,
                                NormalizedHitPosition=1,
                            )
                            response_dict = self.api.call()

                            # DEBUG - Hide
                            # print ('used ' + self.item_list[str(pokeball)] + '> [-1]')
                            self.ballstock[pokeball] -= 1

                            if (
                                response_dict
                                and "responses" in response_dict
                                and "CATCH_POKEMON" in response_dict["responses"]
                                and "status" in response_dict["responses"]["CATCH_POKEMON"]
                            ):
                                status = response_dict["responses"]["CATCH_POKEMON"]["status"]
                                if status is 2:
                                    print("[-] Attempted to capture " + str(pokemon_name) + " - failed.. trying again!")
                                    time.sleep(1.25)
                                    continue
                                if status is 3:
                                    print("[x] Oh no! " + str(pokemon_name) + " vanished! :(")
                                if status is 1:

                                    if self.should_transfer(cp, str(pokemon_name)):

                                        print(
                                            "[x] Captured "
                                            + str(pokemon_name)
                                            + "! [CP"
                                            + str(cp)
                                            + "] - exchanging for candy"
                                        )
                                        id_list2 = self.count_pokemon_inventory()
                                        try:
                                            # Transfering Pokemon
                                            self.transfer_pokemon(list(Set(id_list2) - Set(id_list1))[0])
                                        except:
                                            print("[###] Your inventory is full! Please manually delete some items.")
                                            break
                                    else:
                                        print("[x] Captured " + str(pokemon_name) + "! [CP" + str(cp) + "]")
                            break
        time.sleep(5)
Example #5
0
    def work(self):
        lat = self.fort['latitude']
        lng = self.fort['longitude']
        fortID = self.fort['id']
        dist = distance(self.position[0], self.position[1], lat, lng)

        print('Found fort {} at distance {}m'.format(fortID, dist))
        if dist > 10:
            print('Need to move closer to Pokestop')
            position = (lat, lng, 0.0)
            if self.config.walk > 0:
                self.api.walk(self.config.walk, *position,walking_hook=self.walking_hook)
            else:
                self.api.set_position(*position)
            self.api.player_update(latitude=lat,longitude=lng)
            response_dict = self.api.call()
            print('Arrived at Pokestop')
            time.sleep(1.2)

        self.api.fort_details(fort_id=self.fort['id'], latitude=position[0], longitude=position[1])
        response_dict = self.api.call()
        fort_details = response_dict['responses']['FORT_DETAILS']
        print('Now at Pokestop: ' + fort_details['name'] + ' - Spinning...')
        time.sleep(2)
        self.api.fort_search(fort_id=self.fort['id'], fort_latitude=lat, fort_longitude=lng, player_latitude=f2i(position[0]), player_longitude=f2i(position[1]))
        response_dict = self.api.call()
        if 'responses' in response_dict and \
            'FORT_SEARCH' in response_dict['responses']:

            spin_details = response_dict['responses']['FORT_SEARCH']
            if spin_details['result'] == 1:
                print("- Loot: ")
                experience_awarded = spin_details.get('experience_awarded', False)
                if experience_awarded:
                    print("- " + str(experience_awarded) + " xp")

                items_awarded = spin_details.get('items_awarded', False)
                if items_awarded:
                    for item in items_awarded:
                        item_id = str(item['item_id'])
                        item_name = self.item_list[item_id]
                        print("- " + str(item['item_count']) + "x " + item_name)
                else:
                    print("- Nothing found.")

                pokestop_cooldown = spin_details.get('cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    print '- PokeStop on cooldown. Time left: %s seconds.' % str((pokestop_cooldown/1000) - seconds_since_epoch)

                if not items_awarded and not experience_awarded and not pokestop_cooldown:
                    message = (
                        'Stopped at Pokestop and did not find experience, items '
                        'or information about the stop cooldown. You are '
                        'probably softbanned. Try to play on your phone, '
                        'if pokemons always ran away and you find nothing in '
                        'PokeStops you are indeed softbanned. Please try again '
                        'in a few hours.'
                    )
                    raise RuntimeError(message)
            elif spin_details['result'] == 2:
                print("- Pokestop out of range")
            elif spin_details['result'] == 3:
                pokestop_cooldown = spin_details.get('cooldown_complete_timestamp_ms')
                if pokestop_cooldown:
                    seconds_since_epoch = time.time()
                    print '- PokeStop on cooldown. Time left: %s seconds.' % str((pokestop_cooldown/1000) - seconds_since_epoch)
            elif spin_details['result'] == 4:
                print("- Inventory is full!")

            if 'chain_hack_sequence_number' in response_dict['responses']['FORT_SEARCH']:
                time.sleep(2)
                return response_dict['responses']['FORT_SEARCH']['chain_hack_sequence_number']
            else:
                print('may search too often, lets have a rest')
                return 11
        time.sleep(8)
        return 0