Exemplo n.º 1
0
    def pokemon(data):
        log.debug("Converting to pokemon: \n {}".format(data))
        # Get some stuff ahead of time (cause we are lazy)
        quick_id = check_for_none(int, data.get('move_1'), '?')
        charge_id = check_for_none(int, data.get('move_2'), '?')
        lat, lng = data['latitude'], data['longitude']
	weather_id = check_for_none(int, data.get('weather'), '?')

        # Generate all the non-manager specifi
        pkmn = {
            'type': "pokemon",
            'id': data['encounter_id'],
            'pkmn_id': int(data['pokemon_id']),
            'disappear_time': datetime.utcfromtimestamp(data['disappear_time']),
            'lat': float(data['latitude']),
            'lng': float(data['longitude']),
            'cp': check_for_none(int, data.get('cp'), '?'),
            'level': check_for_none(int, data.get('pokemon_level'), '?'),
            'iv': '?',
            'atk': check_for_none(int, data.get('individual_attack'), '?'),
            'def': check_for_none(int, data.get('individual_defense'), '?'),
            'sta': check_for_none(int, data.get('individual_stamina'), '?'),
            'quick_id': quick_id,
            'quick_damage': get_move_damage(quick_id),
            'quick_dps': get_move_dps(quick_id),
            'quick_duration': get_move_duration(quick_id),
            'quick_energy': get_move_energy(quick_id),
            'charge_id': charge_id,
            'charge_damage': get_move_damage(charge_id),
            'charge_dps': get_move_dps(charge_id),
            'charge_duration': get_move_duration(charge_id),
            'charge_energy': get_move_energy(charge_id),
            'height': check_for_none(float, data.get('height'), 'unkn'),
            'weight': check_for_none(float, data.get('weight'), 'unkn'),
            'gender': get_pokemon_gender(check_for_none(int, data.get('gender'), '?')),
            'form_id': check_for_none(int, data.get('form'), '?'),
            'size': 'unknown',
            'tiny_rat': '',
            'big_karp': '',
            'gmaps': get_gmaps_link(lat, lng),
            'applemaps': get_applemaps_link(lat, lng),
	    'weather': weather_id
        }
        if pkmn['atk'] != '?' or pkmn['def'] != '?' or pkmn['sta'] != '?':
            pkmn['iv'] = float(((pkmn['atk'] + pkmn['def'] + pkmn['sta']) * 100) / float(45))
        else:
            pkmn['atk'], pkmn['def'], pkmn['sta'] = '?', '?', '?'

        if pkmn['height'] != 'unkn' or pkmn['weight'] != 'unkn':
            pkmn['size'] = get_pokemon_size(pkmn['pkmn_id'], pkmn['height'], pkmn['weight'])
            pkmn['height'] = "{:.2f}".format(pkmn['height'])
            pkmn['weight'] = "{:.2f}".format(pkmn['weight'])

        if pkmn['pkmn_id'] == 19 and pkmn['size'] == 'tiny':
            pkmn['tiny_rat'] = 'tiny'

        if pkmn['pkmn_id'] == 129 and pkmn['size'] == 'big':
            pkmn['big_karp'] = 'big'

        return pkmn
Exemplo n.º 2
0
    def pokemon(data):
        log.debug("Converting to pokemon: \n {}".format(data))
        # Get some stuff ahead of time (cause we are lazy)
        quick_id = check_for_none(int, data.get('move_1'), '?')
        charge_id = check_for_none(int, data.get('move_2'), '?')
        lat, lng = data['latitude'], data['longitude']
        # Generate all the non-manager specifi
        pkmn = {
            'type': "pokemon",
            'id': data['encounter_id'],
            'pkmn_id': int(data['pokemon_id']),
            'disappear_time': datetime.utcfromtimestamp(data['disappear_time']),
            'lat': float(data['latitude']),
            'lng': float(data['longitude']),
            'cp': check_for_none(int, data.get('cp'), '?'),
            'level': check_for_none(int, data.get('pokemon_level'), '?'),
            'iv': '?',
            'atk': check_for_none(int, data.get('individual_attack'), '?'),
            'def': check_for_none(int, data.get('individual_defense'), '?'),
            'sta': check_for_none(int, data.get('individual_stamina'), '?'),
            'quick_id': quick_id,
            'quick_damage': get_move_damage(quick_id),
            'quick_dps': get_move_dps(quick_id),
            'quick_duration': get_move_duration(quick_id),
            'quick_energy': get_move_energy(quick_id),
            'charge_id': charge_id,
            'charge_damage': get_move_damage(charge_id),
            'charge_dps': get_move_dps(charge_id),
            'charge_duration': get_move_duration(charge_id),
            'charge_energy': get_move_energy(charge_id),
            'height': check_for_none(float, data.get('height'), 'unkn'),
            'weight': check_for_none(float, data.get('weight'), 'unkn'),
            'gender': get_pokemon_gender(check_for_none(int, data.get('gender'), '?')),
            'form_id': check_for_none(int, data.get('form'), '?'),
            'size': 'unknown',
            'tiny_rat': '',
            'big_karp': '',
            'gmaps': get_gmaps_link(lat, lng),
            'applemaps': get_applemaps_link(lat, lng)
        }
        if pkmn['atk'] != '?' or pkmn['def'] != '?' or pkmn['sta'] != '?':
            pkmn['iv'] = float(((pkmn['atk'] + pkmn['def'] + pkmn['sta']) * 100) / float(45))
        else:
            pkmn['atk'], pkmn['def'], pkmn['sta'] = '?', '?', '?'

        if pkmn['height'] != 'unkn' or pkmn['weight'] != 'unkn':
            pkmn['size'] = get_pokemon_size(pkmn['pkmn_id'], pkmn['height'], pkmn['weight'])
            pkmn['height'] = "{:.2f}".format(pkmn['height'])
            pkmn['weight'] = "{:.2f}".format(pkmn['weight'])

        if pkmn['pkmn_id'] == 19 and pkmn['size'] == 'tiny':
            pkmn['tiny_rat'] = 'tiny'

        if pkmn['pkmn_id'] == 129 and pkmn['size'] == 'big':
            pkmn['big_karp'] = 'big'

        return pkmn
Exemplo n.º 3
0
    def pokemon(data):
        log.debug("Converting to pokemon: \n {}".format(data))
        # Get some stuff ahead of time (cause we are lazy)
        quick_id = check_for_none(int, data.get('move_1'), '?')
        charge_id = check_for_none(int, data.get('move_2'), '?')
        lat, lng = data['latitude'], data['longitude']
        # Get the form from data and as it may be uint or string make sure is zero when string 'None'
        form_raw = data['form']
        if form_raw is None:
            form_raw = 0

        # Generate all the non-manager specifics
        pkmn = {
            'type':
            "pokemon",
            'id':
            data['encounter_id'],
            'pkmn_id':
            int(data['pokemon_id']),
            'disappear_time':
            datetime.utcfromtimestamp(data['disappear_time']),
            'lat':
            float(data['latitude']),
            'lng':
            float(data['longitude']),
            'iv':
            '?',
            'atk':
            check_for_none(int, data.get('individual_attack'), '?'),
            'def':
            check_for_none(int, data.get('individual_defense'), '?'),
            'sta':
            check_for_none(int, data.get('individual_stamina'), '?'),
            'quick_id':
            quick_id,
            'quick_damage':
            get_move_damage(quick_id),
            'quick_dps':
            get_move_dps(quick_id),
            'quick_duration':
            get_move_duration(quick_id),
            'quick_energy':
            get_move_energy(quick_id),
            'charge_id':
            charge_id,
            'charge_damage':
            get_move_damage(charge_id),
            'charge_dps':
            get_move_dps(charge_id),
            'charge_duration':
            get_move_duration(charge_id),
            'charge_energy':
            get_move_energy(charge_id),
            'height':
            check_for_none(float, data.get('height'), 'unkn'),
            'weight':
            check_for_none(float, data.get('weight'), 'unkn'),
            'gender':
            get_pokemon_gender(check_for_none(int, data.get('gender'), '?')),
            'size':
            'unknown',
            'previous_id':
            get_pkmn_name(int(data['previous_id'])),
            'gmaps':
            get_gmaps_link(lat, lng),
            'applemaps':
            get_applemaps_link(lat, lng),
            'form':
            get_form_name(int(form_raw))
        }
        if pkmn['atk'] != '?' or pkmn['def'] != '?' or pkmn['sta'] != '?':
            pkmn['iv'] = float(
                ((pkmn['atk'] + pkmn['def'] + pkmn['sta']) * 100) / float(45))
        else:
            pkmn['atk'], pkmn['def'], pkmn['sta'] = '?', '?', '?'

        if pkmn['height'] != 'unkn' or pkmn['weight'] != 'unkn':
            pkmn['size'] = get_pokemon_size(pkmn['pkmn_id'], pkmn['height'],
                                            pkmn['weight'])
            pkmn['height'] = "{:.2f}".format(pkmn['height'])
            pkmn['weight'] = "{:.2f}".format(pkmn['weight'])

        return pkmn
Exemplo n.º 4
0
    def pokemon(data):
        #log.info("Converting to pokemon: \n {}".format(data))
        # Get some stuff ahead of time (cause we are lazy)
        quick_id = check_for_none(int, data.get('move_1'), '?')
        charge_id = check_for_none(int, data.get('move_2'), '?')
        lat, lng = data['latitude'], data['longitude']
        # Generate all the non-manager specifi
        pkmn = {
            'type':
            "pokemon",
            'id':
            data['encounter_id'],
            'pkmn_id':
            int(data['pokemon_id']),
            'disappear_time':
            datetime.utcfromtimestamp(data['disappear_time']),
            'lat':
            float(data['latitude']),
            'lng':
            float(data['longitude']),
            'cp':
            check_for_none(int, data.get('cp'), '?'),
            'level':
            check_for_none(int, data.get('pokemon_level'), '?'),
            'iv':
            '?',
            'atk':
            check_for_none(int, data.get('individual_attack'), '?'),
            'def':
            check_for_none(int, data.get('individual_defense'), '?'),
            'sta':
            check_for_none(int, data.get('individual_stamina'), '?'),
            'quick_id':
            quick_id,
            'quick_damage':
            get_move_damage(quick_id),
            'quick_dps':
            get_move_dps(quick_id),
            'quick_duration':
            get_move_duration(quick_id),
            'quick_energy':
            get_move_energy(quick_id),
            'charge_id':
            charge_id,
            'charge_damage':
            get_move_damage(charge_id),
            'charge_dps':
            get_move_dps(charge_id),
            'charge_duration':
            get_move_duration(charge_id),
            'charge_energy':
            get_move_energy(charge_id),
            'height':
            check_for_none(float, data.get('height'), '?'),
            'weight':
            check_for_none(float, data.get('weight'), '?'),
            'gender':
            get_pokemon_gender(check_for_none(int, data.get('gender'), '?')),
            'size':
            '?',
            'tiny_rat':
            '',
            'big_karp':
            '',
            'gmaps':
            get_gmaps_link(lat, lng),
            'applemaps':
            get_applemaps_link(lat, lng),
            'allstats':
            '',
            'rating_attack':
            data.get('rating_attack'),
            'rating_defense':
            data.get('rating_defense'),
            'worker_level':
            check_for_none(int, data.get('worker_level'), '?'),
            'catch_prob_1':
            check_for_none(float, data.get('catch_prob_1'), '?'),
            'catch_prob_2':
            check_for_none(float, data.get('catch_prob_2'), '?'),
            'catch_prob_3':
            check_for_none(float, data.get('catch_prob_3'), '?'),
            'previous_id':
            check_for_none(int, data.get('previous_id'), ''),
        }
        if pkmn['atk'] != '?' or pkmn['def'] != '?' or pkmn['sta'] != '?':
            pkmn['iv'] = float(
                ((pkmn['atk'] + pkmn['def'] + pkmn['sta']) * 100) / float(45))
        else:
            pkmn['atk'], pkmn['def'], pkmn['sta'] = '?', '?', '?'

        if pkmn['atk'] != '?' and pkmn['def'] != '?' and pkmn['sta'] != '?':
            pkmn['allstats'] = ' (%.0f' % (pkmn['iv']) + '%' + '/%d/%d/%d)' % (
                pkmn['atk'], pkmn['def'], pkmn['sta'])

            if pkmn['cp'] != '?':
                pkmn['allstats'] = pkmn['allstats'][:-1] + '/CP %d)' % (
                    pkmn['cp'])

            if pkmn['level'] != '?':
                pkmn['allstats'] = pkmn['allstats'][:-1] + '/Lvl %d)' % (
                    pkmn['level'])

        pkmn['allstats'] += ' '

        if pkmn['height'] != '?' or pkmn['weight'] != '?':
            pkmn['size'] = get_pokemon_size(pkmn['pkmn_id'], pkmn['height'],
                                            pkmn['weight'])
            pkmn['height'] = "{:.2f}".format(pkmn['height'])
            pkmn['weight'] = "{:.2f}".format(pkmn['weight'])

        if pkmn['pkmn_id'] == 19 and pkmn['size'] == 'tiny':
            pkmn['tiny_rat'] = 'Tiny'

        if pkmn['pkmn_id'] == 129 and pkmn['size'] == 'big':
            pkmn['big_karp'] = 'Big'

        rating_attack = pkmn['rating_attack']
        pkmn['rating_attack'] = rating_attack.upper() if rating_attack else '-'
        rating_defense = pkmn['rating_defense']
        pkmn['rating_defense'] = rating_defense.upper(
        ) if rating_defense else '-'

        if pkmn['catch_prob_1'] > 0:
            pkmn['catch_prob_1'] = pkmn['catch_prob_1'] * 100
            pkmn['catch_prob_1'] = int(round(pkmn['catch_prob_1'], 2))
        else:
            pkmn['catch_prob_1'] = ''

        if pkmn['catch_prob_2'] > 0:
            pkmn['catch_prob_2'] = pkmn['catch_prob_2'] * 100
            pkmn['catch_prob_2'] = int(round(pkmn['catch_prob_2'], 2))
        else:
            pkmn['catch_prob_2'] = ''

        if pkmn['catch_prob_3'] > 0:
            pkmn['catch_prob_3'] = pkmn['catch_prob_3'] * 100
            pkmn['catch_prob_3'] = int(round(pkmn['catch_prob_3'], 2))
        else:
            pkmn['catch_prob_3'] = ''

        if pkmn['previous_id']:
            pkmn['previous_id'] = '(' + get_pkmn_name(int(
                pkmn['previous_id'])) + ')'

        return pkmn
Exemplo n.º 5
0
    def pokemon(data):
        log.debug("Converting to pokemon: \n {}".format(data))
        # Get some stuff ahead of time (cause we are lazy)
        quick_id = check_for_none(int, data.get('move_1'), '?')
        charge_id = check_for_none(int, data.get('move_2'), '?')
        lat, lng = data['latitude'], data['longitude']
        # Generate all the non-manager specifi
        pkmn = {
            'type':
            "pokemon",
            'id':
            data['encounter_id'],
            'pkmn_id':
            int(data['pokemon_id']),
            'disappear_time':
            datetime.utcfromtimestamp(data['disappear_time']),
            'lat':
            float(data['latitude']),
            'lng':
            float(data['longitude']),
            'iv':
            '?',
            'atk':
            check_for_none(int, data.get('individual_attack'), '?'),
            'def':
            check_for_none(int, data.get('individual_defense'), '?'),
            'sta':
            check_for_none(int, data.get('individual_stamina'), '?'),
            'quick_id':
            quick_id,
            'quick_damage':
            get_move_damage(quick_id),
            'quick_dps':
            get_move_dps(quick_id),
            'quick_duration':
            get_move_duration(quick_id),
            'quick_energy':
            get_move_energy(quick_id),
            'charge_id':
            charge_id,
            'charge_damage':
            get_move_damage(charge_id),
            'charge_dps':
            get_move_dps(charge_id),
            'charge_duration':
            get_move_duration(charge_id),
            'charge_energy':
            get_move_energy(charge_id),
            'height':
            check_for_none(float, data.get('height'), 'unkn'),
            'weight':
            check_for_none(float, data.get('weight'), 'unkn'),
            'gender':
            get_pokemon_gender(check_for_none(int, data.get('gender'), '?')),
            'size':
            'unknown',
            'gmaps':
            get_gmaps_link(lat, lng),
            'applemaps':
            get_applemaps_link(lat, lng),
            'cp':
            int(data['cp']),
            'cp_multiplier':
            str(data['cp_multiplier']),
            #'deeplink': config['DEEPLINK']+urllib.urlencode({'z': blowfishEncrypt(config['ENCRYPTION'], str(data['latitude'])[:11]+", "+str(data['longitude'])[:11])})
        }
        if pkmn['atk'] != '?' or pkmn['def'] != '?' or pkmn['sta'] != '?':
            pkmn['iv'] = float(
                ((pkmn['atk'] + pkmn['def'] + pkmn['sta']) * 100) / float(45))
        else:
            pkmn['atk'], pkmn['def'], pkmn['sta'] = '?', '?', '?'

        if pkmn['height'] != 'unkn' or pkmn['weight'] != 'unkn':
            pkmn['size'] = get_pokemon_size(pkmn['pkmn_id'], pkmn['height'],
                                            pkmn['weight'])
            pkmn['height'] = "{:.2f}".format(pkmn['height'])
            pkmn['weight'] = "{:.2f}".format(pkmn['weight'])

        return pkmn