コード例 #1
0
def spin_pokestop_update_inventory(api, fort, step_location, account):
    time.sleep(random.uniform(0.8, 1.8))  # Do not let Niantic throttle
    spin_response = spin_pokestop_request(api, fort, step_location, account)
    time.sleep(random.uniform(2, 4))  # Do not let Niantic throttle
    if not spin_response:
        return False

    # Check for reCaptcha
    captcha_url = spin_response['responses']['CHECK_CHALLENGE'][
        'challenge_url']
    if len(captcha_url) > 1:
        log.debug('Account encountered a reCaptcha.')
        return False

    spin_result = spin_response['responses']['FORT_SEARCH']['result']
    if spin_result is 1:
        awards = get_awarded_items(
            spin_response['responses']['FORT_SEARCH']['items_awarded'])
        log.info('Got {} items ({} balls) from Pokestop.'.format(
            awards['total'], awards['balls']))
        return True
    elif spin_result is 2:
        log.debug('Pokestop was not in range to spin.')
    elif spin_result is 3:
        log.debug('Failed to spin Pokestop. Has recently been spun.')
    elif spin_result is 4:
        log.debug('Failed to spin Pokestop. Inventory is full.')
    elif spin_result is 5:
        log.debug('Maximum number of Pokestops spun for this day.')
    else:
        log.debug('Failed to spin a Pokestop. Unknown result %d.', spin_result)
    return False
コード例 #2
0
def gxp_spin_stops(forts, pgacc, step_location):
    for f in forts:
        if f.type == 1 and pokestop_spinnable(f, step_location):
            time.sleep(random.uniform(0.8, 1.8))
            response = spin_pokestop_request(pgacc, f, step_location)
            time.sleep(random.uniform(2, 4))  # Don't let Niantic throttle.

            # Check for reCaptcha.
            if pgacc.has_captcha():
                log.debug('Account encountered a reCaptcha.')
                return

            spin_result = response['FORT_SEARCH'].result
            if spin_result is 1:
                awards = parse_awarded_items(
                    response['FORT_SEARCH'].items_awarded)
                log.info('GXP: Got {} items ({} balls) from Pokestop.'.format(
                    awards['total'], awards['balls']))
                cleanup_inventory(pgacc)
                return True
            elif spin_result is 2:
                log.debug('GXP: Pokestop was not in range to spin.')
            elif spin_result is 3:
                log.debug(
                    'GXP: Failed to spin Pokestop. Has recently been spun.')
            elif spin_result is 4:
                log.debug('GXP: Failed to spin Pokestop. Inventory is full.')
                cleanup_inventory(pgacc)
            elif spin_result is 5:
                log.debug(
                    'GXP: Maximum number of Pokestops spun for this day.')
            else:
                log.debug('GXP: Failed to spin a Pokestop. Unknown result %d.',
                          spin_result)
コード例 #3
0
ファイル: gainxp.py プロジェクト: SkOODaT/RocketMap
def cleanup_inventory(pgacc):
    drop_stats = {}
    # Just need to make room for at least one more item
    if pgacc.inventory_total >= 350:
        drop_items(pgacc, ITEM_POTION, drop_stats)
        drop_items(pgacc, ITEM_SUPER_POTION, drop_stats)
        drop_items(pgacc, ITEM_HYPER_POTION, drop_stats)
        drop_items(pgacc, ITEM_MAX_POTION, drop_stats)
        drop_items(pgacc, ITEM_REVIVE, drop_stats)
        drop_items(pgacc, ITEM_MAX_REVIVE, drop_stats)
        drop_items(pgacc, ITEM_BLUK_BERRY, drop_stats)
        drop_items(pgacc, ITEM_NANAB_BERRY, drop_stats)
        drop_items(pgacc, ITEM_WEPAR_BERRY, drop_stats)
        drop_items(pgacc, ITEM_PINAP_BERRY, drop_stats)
        drop_items(pgacc, ITEM_RAZZ_BERRY, drop_stats)

        # Throw away balls if necessary
        if pgacc.inventory_total >= 350:
            need_to_drop = pgacc.inventory_total - 350 + DROP_BALLS
            items_dropped = drop_items(pgacc, ITEM_POKE_BALL, drop_stats, need_to_drop)
            if items_dropped < need_to_drop:
                need_to_drop -= items_dropped
                items_dropped = drop_items(pgacc, ITEM_GREAT_BALL, drop_stats, need_to_drop)
                if items_dropped < need_to_drop:
                    need_to_drop -= items_dropped
                    drop_items(pgacc, ITEM_ULTRA_BALL, drop_stats, need_to_drop)

        # Log what was dropped
        drops = []
        for item_id in sorted(drop_stats):
            dropped = drop_stats[item_id]
            drops.append(u"{} {}s".format(dropped, ITEM_NAMES[item_id]))
        log.info(u"GXP: Items dropped: {}".format(u", ".join(drops)))
コード例 #4
0
def is_ditto(args, api, p, account):
    pokemon_id = p['pokemon_data']['pokemon_id']
    pokemon_name = get_pokemon_name(pokemon_id)
    captured_pokemon_name = pokemon_name
    log.info(
        u'{} may be a Ditto. Triggering catch logic!'.format(pokemon_name))

    # Encounter Pokemon.
    time.sleep(args.encounter_delay)
    encounter_pokemon_request(api, account, p['encounter_id'],
                              p['spawn_point_id'],
                              [p['latitude'], p['longitude']])

    # Now try to catch it.
    got_ditto = False
    catch_result = catch(api, p['encounter_id'], p['spawn_point_id'], account)
    if catch_result['catch_status'] == 'success':
        if int(catch_result['pid']) == DITTO_POKEDEX_ID:
            logmsg = u'Successfully caught a Ditto disguised as {}! Needed {} attempts.'
            captured_pokemon_name = get_pokemon_name(DITTO_POKEDEX_ID)
            got_ditto = True
        else:
            logmsg = u'Successfully caught a regular {} after {} attempts.'
        log.info(logmsg.format(pokemon_name, catch_result['attempts']))
        # Release the Pokemon in any case
        time.sleep(random.uniform(7, 10))
        if release(api, catch_result['capture_id'], account):
            log.info(
                u'Successfully released {}.'.format(captured_pokemon_name))
    else:
        log.info("Failed catching {}: {} Attempts: {}".format(
            pokemon_name, catch_result['reason'], catch_result['attempts']))
    return got_ditto
コード例 #5
0
def is_ditto(args, pgacc, p):
    pokemon_id = p.pokemon_data.pokemon_id
    pokemon_name = get_pokemon_name(pokemon_id)
    log.info(
        u'{} may be a Ditto. Triggering catch logic!'.format(pokemon_name))

    # Encounter Pokemon.
    time.sleep(args.encounter_delay)
    encounter_pokemon_request(pgacc, p.encounter_id, p.spawn_point_id,
                              [p.latitude, p.longitude])

    # Now try to catch it.
    got_ditto = False
    catch_result = catch(pgacc, p.encounter_id, p.spawn_point_id)
    if catch_result['catch_status'] == 'success':
        if int(catch_result['pid']) == DITTO_POKEDEX_ID:
            logmsg = u'GXP: Successfully caught a Ditto disguised as {}! Needed {} attempts.'
            captured_pokemon_name = get_pokemon_name(DITTO_POKEDEX_ID)
            got_ditto = True
        else:
            logmsg = u'GXP: Successfully caught a regular {} after {} attempts.'
        log.info(logmsg.format(pokemon_name, catch_result['attempts']))
    else:
        log.info("GXP: Failed catching {}: {} Attempts: {}".format(
            pokemon_name, catch_result['reason'], catch_result['attempts']))
    return got_ditto
コード例 #6
0
def cleanup_inventory(api, account):
    inventory = account.get('inventory', {})
    drop_stats = {}
    # Just need to make room for more items
    if inventory['total'] >= 350:
        drop_items(api, account, ITEM_POTION, drop_stats)
        drop_items(api, account, ITEM_SUPER_POTION, drop_stats)
        drop_items(api, account, ITEM_HYPER_POTION, drop_stats)
        drop_items(api, account, ITEM_MAX_POTION, drop_stats)
        drop_items(api, account, ITEM_REVIVE, drop_stats)
        drop_items(api, account, ITEM_MAX_REVIVE, drop_stats)
        drop_items(api, account, ITEM_BLUK_BERRY, drop_stats)
        drop_items(api, account, ITEM_NANAB_BERRY, drop_stats)
        drop_items(api, account, ITEM_WEPAR_BERRY, drop_stats)
        drop_items(api, account, ITEM_PINAP_BERRY, drop_stats)
        drop_items(api, account, ITEM_RAZZ_BERRY, drop_stats)

        # Throw away balls if necessary
        if inventory['total'] >= 350:
            need_to_drop = inventory['total'] - 350 + DROP_BALLS
            items_dropped = drop_items(api, account, ITEM_POKE_BALL,
                                       drop_stats, need_to_drop)
            if items_dropped < need_to_drop:
                need_to_drop -= items_dropped
                items_dropped = drop_items(api, account, ITEM_GREAT_BALL,
                                           drop_stats, need_to_drop)
                if items_dropped < need_to_drop:
                    need_to_drop -= items_dropped
                    drop_items(api, account, ITEM_ULTRA_BALL, drop_stats,
                               need_to_drop)

        # Log what was dropped
        drops = []
        for item_id in sorted(drop_stats):
            dropped = drop_stats[item_id]
            drops.append(u"{} {}s".format(dropped, ITEM_NAMES[item_id]))
        log.info(u"Items dropped: {}".format(u", ".join(drops)))
コード例 #7
0
ファイル: gainxp.py プロジェクト: SkOODaT/RocketMap
def lure_geofence(results, geofence_file, forbidden=False):
    geofence = []
    with open(geofence_file) as f:
        for line in f:
            if len(line.strip()) == 0 or line.startswith('#'):
                continue
            geofence.append(literal_eval(line.strip()))
        if forbidden:
            log.info('Loaded %d geofence-forbidden coordinates. ' +
                     'Applying...', len(geofence))
        else:
            log.info('Loaded %d geofence coordinates. Applying...',
                     len(geofence))
    log.info(geofence)
    p = Path(geofence)
    results_geofenced = []
    for g in range(len(results)):
        result_x, result_y, result_z = results[g]
        if p.contains_point([result_x, result_y]) ^ forbidden:
            results_geofenced.append((result_x, result_y, result_z))
    return results_geofenced