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
def pokemon(data): log.debug("Converting to pokemon: \n {}".format(data)) # Check optional data move_1_id, move_2_id = data.get('move_1'), data.get('move_2') atk, def_, sta = data.get('individual_attack'), data.get( 'individual_defense'), data.get('individual_stamina') 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']), 'move_1_id': int(move_1_id) if move_1_id is not None else 'unkn', 'move_2_id': int(move_2_id) if move_2_id is not None else 'unkn', 'atk': int(atk) if atk is not None else 'unkn', 'def': int(def_) if def_ is not None else 'unkn', 'sta': int(sta) if sta is not None else 'unkn' } pkmn['gmaps'] = get_gmaps_link(pkmn['lat'], pkmn['lng']) if atk is None or def_ is None or sta is None: pkmn['iv'] = 'unkn' else: pkmn['iv'] = float(((atk + def_ + sta) * 100) / float(45)) return pkmn
def gym(data): log.debug("Converting to gym: \n {}".format(data)) gym = { 'type': "gym", 'id': data.get('gym_id', data.get('id')), "new_team_id": int(data.get('team_id', data.get('team'))), #"points": str(data.get('gym_points')), "guard_pkmn_id": data.get('guard_pokemon_id'), 'lat': float(data['latitude']), 'lng': float(data['longitude']), 'lat_5': "{:.5f}".format(float(data['latitude'])), 'lng_5': "{:.5f}".format(float(data['longitude'])), 'name': check_for_none(str, data.get('name'), 'unknown').strip(), 'description': check_for_none(str, data.get('description'), 'unknown').strip(), 'url': check_for_none(str, data.get('url'), 'unknown') } gym['gmaps'] = get_gmaps_link(gym['lat'], gym['lng']) gym['applemaps'] = get_applemaps_link(gym['lat'], gym['lng']) return gym
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
def raid(data): log.debug("Converting to raid: \n {}".format(data)) quick_id = check_for_none(int, data.get('move_1'), '?') charge_id = check_for_none(int, data.get('move_2'), '?') raid_end = None raid_begin = None if 'raid_begin' in data: raid_begin = datetime.utcfromtimestamp(data['raid_begin']) elif 'battle' in data: raid_begin = datetime.utcfromtimestamp(data['battle']) elif 'start' in data: raid_begin = datetime.utcfromtimestamp(data['start']) if 'raid_end' in data: # monocle raid_end = datetime.utcfromtimestamp(data['raid_end']) elif 'end' in data: # rocketmap raid_end = datetime.utcfromtimestamp(data['end']) if 'raid_seed' in data: # monocle sends a unique raid seed id_ = data.get('raid_seed') else: id_ = data.get('gym_id') # RM sends the gym id raid = { 'type': 'raid', 'id': id_, 'pkmn_id': check_for_none(int, data.get('pokemon_id'), 0), 'cp': check_for_none(int, data.get('cp'), '?'), '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), 'raid_level': check_for_none(int, data.get('level'), 0), 'raid_end': raid_end, 'raid_begin': raid_begin, 'lat': float(data['latitude']), 'lng': float(data['longitude']), 'gym_name': data.get('gym_name'), 'gym_url': data.get('gym_url'), 'team_id': check_for_none(int, data.get('team'), 0) } raid['gmaps'] = get_gmaps_link(raid['lat'], raid['lng']) raid['applemaps'] = get_applemaps_link(raid['lat'], raid['lng']) return raid
def raid(data): log.debug("Converting to raid: \n {}".format(data)) quick_id = check_for_none(int, data.get('move_1'), '?') charge_id = check_for_none(int, data.get('move_2'), '?') raid_end = None raid_begin = None if 'raid_begin' in data: raid_begin = datetime.utcfromtimestamp(data['raid_begin']) elif 'battle' in data: raid_begin = datetime.utcfromtimestamp(data['battle']) elif 'start' in data: raid_begin = datetime.utcfromtimestamp(data['start']) if 'raid_end' in data: # monocle raid_end = datetime.utcfromtimestamp(data['raid_end']) elif 'end' in data: # rocketmap raid_end = datetime.utcfromtimestamp(data['end']) if 'raid_seed' in data: # monocle sends a unique raid seed id_ = data.get('raid_seed') else: id_ = data.get('gym_id') # RM sends the gym id raid = { 'type': 'raid', 'id': id_, 'pkmn_id': check_for_none(int, data.get('pokemon_id'), 0), 'cp': check_for_none(int, data.get('cp'), '?'), '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), 'raid_level': check_for_none(int, data.get('level'), 0), 'raid_end': raid_end, 'raid_begin': raid_begin, 'lat': float(data['latitude']), 'lng': float(data['longitude']) } raid['gmaps'] = get_gmaps_link(raid['lat'], raid['lng']) raid['applemaps'] = get_applemaps_link(raid['lat'], raid['lng']) return raid
def gym(data): log.debug("Converting to gym: \n {}".format(data)) gym = { 'type': "gym", 'id': data.get('gym_id', data.get('id')), "team_id": int(data.get('team_id', data.get('team'))), "points": str(data.get('gym_points')), "guard_pkmn_id": data.get('guard_pokemon_id'), 'lat': float(data['latitude']), 'lng': float(data['longitude']) } gym['gmaps'] = get_gmaps_link(gym['lat'], gym['lng']) return gym
def gym_details(data): log.debug("Converting to gym-details: \n {}".format(data)) defenders = "" for pokemon in data.get('pokemon'): defenders += "[{0} CP: {1}/{2}] [Trainer: {3} Lv: {4}]\n".format( get_pkmn_name(pokemon['pokemon_id']), pokemon['cp_decayed'], pokemon['cp'], pokemon['trainer_name'], pokemon['trainer_level']) gym_details = { 'type': "gym", 'id': data.get('gym_id', data.get('id')), 'team_id': int(data.get('team_id', data.get('team'))), 'points': str(data.get('total_cp')), 'guard_pkmn_id': get_pkmn_name( check_for_none(int, data.get('guard_pokemon_id'), '?')), 'slots_available': check_for_none(int, data.get('slots_available'), '?'), 'is_in_battle': check_for_none(int, data.get('is_in_battle'), '?'), 'defenders': defenders, 'lat': float(data['latitude']), 'lng': float(data['longitude']), 'name': check_for_none(str, data.get('name'), '?'), 'description': check_for_none(str, data.get('description'), '?'), 'gurl': check_for_none(str, data.get('url'), '') } #log.warning(gym_details['guard_pkmn_id']) # log.warning("PARSED GYM INFORMATION: \n {}".format(gym_details)) gym_details['gmaps'] = get_gmaps_link(gym_details['lat'], gym_details['lng']) gym_details['applemaps'] = get_applemaps_link(gym_details['lat'], gym_details['lng']) if gym_details['is_in_battle'] == 1: gym_details['is_in_battle'] = '[IN BATTLE]' else: gym_details['is_in_battle'] = '' return gym_details
def pokestop(data): log.debug("Converting to pokestop: \n {}".format(data)) if data.get('lure_expiration') is None: log.debug("Un-lured pokestop... ignoring.") return None stop = { 'type': "pokestop", 'id': data['pokestop_id'], 'expire_time': datetime.utcfromtimestamp(data['lure_expiration']), 'lat': float(data['latitude']), 'lng': float(data['longitude']) } stop['gmaps'] = get_gmaps_link(stop['lat'], stop['lng']) return stop
def pokestop(data): log.debug("Converting to pokestop: \n {}".format(data)) if data.get('lure_expiration') is None: log.debug("Un-lured pokestop... ignoring.") return None stop = { 'type': "pokestop", 'id': data['pokestop_id'], 'expire_time': datetime.utcfromtimestamp(data['lure_expiration']), 'lat': float(data['latitude']), 'lng': float(data['longitude']) } stop['gmaps'] = get_gmaps_link(stop['lat'], stop['lng']) stop['applemaps'] = get_applemaps_link(stop['lat'], stop['lng']) return stop
def raid(data): log.debug("Converting to raid: \n {}".format(data)) raid = { 'type': "raid", 'id': data.get('gym_id'), 'pkmn_id': check_for_none(int, data.get('pokemon_id'), '?'), 'pkmn_cp': check_for_none(int, data.get('cp'), '?'), 'lat': float(data['latitude']), 'lng': float(data['longitude']), 'level': data.get('level'), 'spawn': datetime.utcfromtimestamp(data.get('spawn')), 'raid_start': datetime.utcfromtimestamp(data.get('start')), 'raid_end': datetime.utcfromtimestamp(data.get('end')), } raid['gmaps'] = get_gmaps_link(raid['lat'], raid['lng']) raid['applemaps'] = get_applemaps_link(raid['lat'], raid['lng']) return raid
def gym(data): log.debug("Converting to gym: \n {}".format(data)) gym = { 'type': "gym", 'id': data.get('gym_id', data.get('id')), "new_team_id": int(data.get('team_id', data.get('team'))), "points": str(data.get('gym_points')), "guard_pkmn_id": data.get('guard_pokemon_id'), 'lat': float(data['latitude']), 'lng': float(data['longitude']), 'name': check_for_none(str, data.get('name'), 'unknown'), 'description': check_for_none(str, data.get('description'), 'unknown'), 'url': check_for_none(str, data.get('url'), 'unknown') } gym['gmaps'] = get_gmaps_link(gym['lat'], gym['lng']) gym['applemaps'] = get_applemaps_link(gym['lat'], gym['lng']) return gym
def pokestop(data): log.debug("Converting to pokestop: \n {}".format(data)) if data.get('lure_expiration') is None: log.debug("Un-lured pokestop... ignoring.") return None stop = { 'type': "pokestop", 'id': data['pokestop_id'], 'expire_time': datetime.utcfromtimestamp(data['lure_expiration']), 'lat': float(data['latitude']), 'lng': float(data['longitude']), 'name': check_for_none(str, data.get('name'), '?'), 'description': check_for_none(str, data.get('description'), '?'), 'lurl': check_for_none(str, data.get('url'), ''), 'deployer': check_for_none(str, data.get('deployer'), '?') } stop['gmaps'] = get_gmaps_link(stop['lat'], stop['lng']) stop['applemaps'] = get_applemaps_link(stop['lat'], stop['lng']) return stop
def gym_details(data): log.debug("Converting to gym-details: \n {}".format(data)) defenders = "" for pokemon in data.get('pokemon'): defenders += "{0} (CP {1}) trained by {2} ({3})\n".format( get_pkmn_name(pokemon['pokemon_id']), pokemon['cp'], pokemon['trainer_name'], pokemon['trainer_level']) gym_details = { 'type': "gym", 'name': data.get('name', data.get('name')), 'id': data.get('gym_id', data.get('id')), 'team_id': int(data.get('team_id', data.get('team'))), 'defenders': defenders, 'lat': float(data['latitude']), 'lng': float(data['longitude']) } # log.warning("PARSED GYM INFORMATION: \n {}".format(gym_details)) gym_details['gmaps'] = get_gmaps_link(gym_details['lat'], gym_details['lng']) return gym_details
def egg(data): log.debug("Converting to egg: \n {}".format(data)) raid_end = None raid_begin = None if 'raid_begin' in data: raid_begin = datetime.utcfromtimestamp(data['raid_begin']) elif 'battle' in data: raid_begin = datetime.utcfromtimestamp(data['battle']) elif 'start' in data: raid_begin = datetime.utcfromtimestamp(data['start']) if 'raid_end' in data: # monocle raid_end = datetime.utcfromtimestamp(data['raid_end']) elif 'end' in data: # rocketmap raid_end = datetime.utcfromtimestamp(data['end']) if 'raid_seed' in data: # monocle sends a unique raid seed id_ = data.get('raid_seed') else: id_ = data.get('gym_id') # RM sends the gym id egg = { 'type': 'egg', 'id': id_, 'raid_level': check_for_none(int, data.get('level'), 0), 'raid_end': raid_end, 'raid_begin': raid_begin, 'lat': float(data['latitude']), 'lng': float(data['longitude']), 'gym_name': data.get('gym_name'), 'gym_url': data.get('gym_url'), 'team_id': check_for_none(int, data.get('team'), 0) } egg['gmaps'] = get_gmaps_link(egg['lat'], egg['lng']) egg['applemaps'] = get_applemaps_link(egg['lat'], egg['lng']) return egg
def egg(data): log.debug("Converting to egg: \n {}".format(data)) raid_end = None raid_begin = None if 'raid_begin' in data: raid_begin = datetime.utcfromtimestamp(data['raid_begin']) elif 'battle' in data: raid_begin = datetime.utcfromtimestamp(data['battle']) elif 'start' in data: raid_begin = datetime.utcfromtimestamp(data['start']) if 'raid_end' in data: # monocle raid_end = datetime.utcfromtimestamp(data['raid_end']) elif 'end' in data: # rocketmap raid_end = datetime.utcfromtimestamp(data['end']) if 'raid_seed' in data: # monocle sends a unique raid seed id_ = data.get('raid_seed') else: id_ = data.get('gym_id') # RM sends the gym id egg = { 'type': 'egg', 'id': id_, 'raid_level': check_for_none(int, data.get('level'), 0), 'raid_end': raid_end, 'raid_begin': raid_begin, 'lat': float(data['latitude']), 'lng': float(data['longitude']) } egg['gmaps'] = get_gmaps_link(egg['lat'], egg['lng']) egg['applemaps'] = get_applemaps_link(egg['lat'], egg['lng']) return egg
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
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
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