def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ hatch_time = get_time_as_str(self.hatch_time, timezone) raid_end_time = get_time_as_str(self.raid_end, timezone) weather_name = locale.get_weather_name(self.weather_id) dts = self.custom_dts.copy() dts.update({ # Identification 'gym_id': self.gym_id, # Time Remaining 'hatch_time_left': hatch_time[0], '12h_hatch_time': hatch_time[1], '24h_hatch_time': hatch_time[2], 'raid_time_left': raid_end_time[0], '12h_raid_end': raid_end_time[1], '24h_raid_end': raid_end_time[2], # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence, 'weather_id': self.weather_id, 'weather': weather_name, 'weather_or_empty': Unknown.or_empty(weather_name), 'weather_emoji': get_weather_emoji(self.weather_id), # Egg info 'egg_lvl': self.egg_lvl, # Gym Details 'gym_name': self.gym_name, 'gym_description': self.gym_description, 'gym_image': self.gym_image, 'sponsor_id': self.sponsor_id, 'sponsored': self.sponsor_id > 0 if Unknown.is_not(self.sponsor_id) else Unknown.REGULAR, 'park': self.park, 'team_id': self.current_team_id, 'team_name': locale.get_team_name(self.current_team_id), 'team_leader': locale.get_leader_name(self.current_team_id) }) return dts
def quest_reward(self, stop_id, reward=None, task=None, last_modified=None): """ Update and return the reward and task for a quest.""" if Unknown.is_not(reward): self._quest_reward[stop_id] = reward if Unknown.is_not(task): self._quest_task[stop_id] = task if Unknown.is_not(last_modified): self._quest_last_modified[stop_id] = last_modified return self._quest_reward.get(stop_id, Unknown.REGULAR), \ self._quest_task.get(stop_id, Unknown.REGULAR), \ self._quest_last_modified.get(stop_id, Unknown.REGULAR)
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ dts = self.custom_dts.copy() dts.update({ # Identification 'stop_id': self.stop_id, 'stop_name': self.stop_name, 'stop_image': self.stop_image, # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lat), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, # Quest Details 'quest': self.quest, 'reward': self.reward, 'expiry': self.expiry }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ time = get_time_as_str(self.expiration, timezone) dts = self.custom_dts.copy() dts.update({ # Identification 'stop_id': self.stop_id, # Time left 'time_left': time[0], '12h_time': time[1], '24h_time': time[2], # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lat), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence }) return dts
def generate_dts(self, locale): """ Return a dict with all the DTS for this event. """ time = get_time_as_str(self.expiration) dts = self.custom_dts.copy() dts.update({ # Identification 'stop_id': self.stop_id, # Time left 'time_left': time[0], '12h_time': time[1], '24h_time': time[2], # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lat), 'distance': ( get_dist_as_str(self.distance) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence }) return dts
def __init__(self, data): """ Creates a new Gym Event based on the given dict. """ super(GymEvent, self).__init__('gym') check_for_none = BaseEvent.check_for_none # Identification self.gym_id = data.get('gym_id', data.get('id')) # Location self.lat = float(data['latitude']) self.lng = float(data['longitude']) self.distance = Unknown.SMALL # Completed by Manager self.direction = Unknown.TINY # Completed by Manager # Team Info self.old_team_id = Unknown.TINY self.new_team_id = int(data.get('team_id', data.get('team'))) # Gym Details self.gym_name = check_for_none(str, data.get('name'), Unknown.REGULAR).strip() self.gym_description = check_for_none(str, data.get('description'), Unknown.REGULAR).strip() self.gym_image = check_for_none(str, data.get('url'), Unknown.REGULAR) # Gym Guards self.slots_available = check_for_none(int, data.get('slots_available'), Unknown.TINY) self.guard_count = ((6 - self.slots_available) if Unknown.is_not( self.slots_available) else Unknown.TINY) self.name = self.gym_id self.geofence = Unknown.REGULAR self.custom_dts = {}
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ dts = self.custom_dts.copy() dts.update({ # Identification 'gym_id': self.gym_id, # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': (get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence, # Team Info 'old_team': locale.get_team_name(self.old_team_id), 'old_team_id': self.old_team_id, 'old_team_leader': locale.get_leader_name(self.old_team_id), 'new_team': locale.get_team_name(self.new_team_id), 'new_team_id': self.new_team_id, 'new_team_leader': locale.get_leader_name(self.new_team_id), # Details 'gym_name': self.gym_name, 'gym_description': self.gym_description, 'gym_image': self.gym_image, # Guards 'slots_available': self.slots_available, 'guard_count': self.guard_count, }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ weather_name = locale.get_weather_name(self.weather_id) severity_locale = locale.get_severity_name(self.severity_id) dts = self.custom_dts.copy() dts.update({ # Identification 's2_cell_id': self.s2_cell_id, # Location - center of the s2 cell 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': (get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, 'waze': get_waze_link(self.lat, self.lng), # Weather Info 'weather_id': self.weather_id, 'weather_id_3': "{:03}".format(self.weather_id), 'weather': weather_name, 'weather_emoji': get_weather_emoji(self.weather_id), 'severity_id': self.severity_id, 'severity_id_3': "{:03}".format(self.severity_id), 'severity': severity_locale, 'severity_or_empty': '' if self.severity_id == 0 else severity_locale, 'day_or_night_id': self.day_or_night_id, 'day_or_night_id_3': "{:03}".format(self.day_or_night_id), 'day_or_night': locale.get_day_or_night(self.day_or_night_id) }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ time = get_time_as_str(self.expiration, timezone) dts = self.custom_dts.copy() type_name = locale.get_grunt_type_name(self.type_id) dts.update({ # Identification 'stop_id': self.stop_id, # Details 'stop_name': self.stop_name, 'stop_image': self.stop_image, 'type_id': self.type_id, 'type_id_3': "{:03}".format(self.type_id), 'type_name': type_name, 'type_emoji': get_type_emoji(get_grunt_type_id(type_name)), 'gender_id': self.gender_id, 'gender': self.gender, # ToDo: Add reward (should probably be sent via webhook) # Time left 'time_left': time[0], '12h_time': time[1], '24h_time': time[2], 'time_left_no_secs': time[3], '12h_time_no_secs': time[4], '24h_time_no_secs': time[5], 'time_left_raw_hours': time[6], 'time_left_raw_minutes': time[7], 'time_left_raw_seconds': time[8], # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ dts = self.custom_dts.copy() dts.update({ # Identification 'stop_id': self.stop_id, 'stop_name': self.stop_name, 'stop_image': self.stop_image, # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lat), 'distance': (get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, # Quest Details 'quest': get_string_for_quest_task(locale, self.quest, self.condition, self.target), 'reward': (locale.get_pokemon_name(self.monster_id) if self.reward == 'Pokemon' else "{} ({})".format( locale.get_item_name(self.item_id), self.item_amount)), 'expiry': self.expiry }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ dts = self.custom_dts.copy() dts.update({ # Identification 'gym_id': self.gym_id, # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence, # Team Info 'old_team': locale.get_team_name(self.old_team_id), 'old_team_id': self.old_team_id, 'old_team_leader': locale.get_leader_name(self.old_team_id), 'new_team': locale.get_team_name(self.new_team_id), 'new_team_id': self.new_team_id, 'new_team_leader': locale.get_leader_name(self.new_team_id), # Details 'gym_name': self.gym_name, 'gym_description': self.gym_description, 'gym_image': self.gym_image, # Guards 'slots_available': self.slots_available, 'guard_count': self.guard_count, }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ weather_name = locale.get_weather_name(self.weather_id) severity_locale = locale.get_severity_name(self.severity_id) dts = self.custom_dts.copy() dts.update({ # Identification 's2_cell_id': self.s2_cell_id, # Location - center of the s2 cell 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, 'waze': get_waze_link(self.lat, self.lng), # Weather Info 'weather_id': self.weather_id, 'weather_id_3': "{:03}".format(self.weather_id), 'weather': weather_name, 'weather_emoji': get_weather_emoji(self.weather_id), 'severity_id': self.severity_id, 'severity_id_3': "{:03}".format(self.severity_id), 'severity': severity_locale, 'severity_or_empty': '' if self.severity_id is 0 else severity_locale, 'day_or_night_id': self.day_or_night_id, 'day_or_night_id_3': "{:03}".format(self.day_or_night_id), 'day_or_night': locale.get_day_or_night(self.day_or_night_id) }) return dts
def __init__(self, data): """ Creates a new Gym Event based on the given dict. """ super(GymEvent, self).__init__('gym') check_for_none = BaseEvent.check_for_none # Identification self.gym_id = data.get('gym_id', data.get('id')) # Location self.lat = float(data['latitude']) self.lng = float(data['longitude']) self.distance = Unknown.SMALL # Completed by Manager self.direction = Unknown.TINY # Completed by Manager # Team Info self.old_team_id = Unknown.TINY self.new_team_id = int(data.get('team_id', data.get('team'))) # Gym Details self.gym_name = check_for_none( str, data.get('name'), Unknown.REGULAR).strip() self.gym_description = check_for_none( str, data.get('description'), Unknown.REGULAR).strip() self.gym_image = check_for_none( str, data.get('url'), Unknown.REGULAR) # Gym Guards self.slots_available = check_for_none( int, data.get('slots_available'), Unknown.TINY) self.guard_count = ( (6 - self.slots_available) if Unknown.is_not(self.slots_available) else Unknown.TINY) self.name = self.gym_id self.geofence = Unknown.REGULAR self.custom_dts = {}
def severity_id(self, s2_cell_id, severity_id=Unknown.REGULAR): """ Update and return severity_id for a cell """ if Unknown.is_not(severity_id): self._severity_id[s2_cell_id] = severity_id return self._severity_id.get(s2_cell_id, Unknown.REGULAR)
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ form_name = locale.get_form_name(self.monster_id, self.monster_form_id) costume_name = locale.get_costume_name(self.monster_id, self.monster_costume_id) type1 = locale.get_type_name(self.monster_types[0]) type2 = locale.get_type_name(self.monster_types[1]) dts = self.custom_dts.copy() dts.update({ # Identification 'stop_id': self.stop_id, 'stop_name': self.stop_name, 'stop_image': self.stop_image, # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': (get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence, # Quest Details # ToDo: Interpret the `quest_condition` field and use that instead # of `quest_type` # Will be able to better serve manager specific locales # also do this for `quest_task` 'quest_type': self.quest_type_raw, 'quest_type_id': self.quest_type_id, 'quest_target': self.quest_target, 'quest_task': self.quest_task_raw, 'quest_template': self.quest_template, 'last_modified': self.last_modified, 'quest_condition': self.quest_condition_raw, 'quest_image': get_quest_image(self), # Reward Details 'reward_type_id': self.reward_type_id, 'reward_type': locale.get_quest_type_name(self.reward_type_id), 'reward_type_raw': self.reward_type_raw, 'reward_amount': self.item_amount, 'reward': reward_string(self, locale), # Monster Reward Details 'mon_name': locale.get_pokemon_name(self.monster_id), 'mon_id': self.monster_id, 'mon_id_3': "{:03}".format(self.monster_id), 'form': form_name, 'form_or_empty': Unknown.or_empty(form_name), 'form_id': self.monster_form_id, 'form_id_2': "{:02d}".format(self.monster_form_id), 'form_id_3': "{:03d}".format(self.monster_form_id), 'costume': costume_name, 'costume_or_empty': Unknown.or_empty(costume_name), 'costume_id': self.monster_costume_id, 'costume_id_2': "{:02d}".format(self.monster_costume_id), 'costume_id_3': "{:03d}".format(self.monster_costume_id), 'type1': type1, 'type1_or_empty': Unknown.or_empty(type1), 'type1_emoji': Unknown.or_empty(get_type_emoji(self.monster_types[0])), 'type2': type2, 'type2_or_empty': Unknown.or_empty(type2), 'type2_emoji': Unknown.or_empty(get_type_emoji(self.monster_types[1])), 'types': ("{}/{}".format(type1, type2) if Unknown.is_not(type2) else type1), 'types_emoji': ("{}{}".format(get_type_emoji(self.monster_types[0]), get_type_emoji(self.monster_types[1])) if Unknown.is_not(type2) else get_type_emoji(self.monster_types[0])), # Item Reward Details 'raw_item_type': self.item_type, 'item': get_item_id(self.item_id), 'item_id': self.item_id, 'item_id_4': "{:04d}".format(self.item_id) }) return dts
def day_or_night_id(self, s2_cell_id, day_or_night_id=Unknown.REGULAR): """ Update and return day_or_night_id for a cell """ if Unknown.is_not(day_or_night_id): self._day_or_night_id[s2_cell_id] = day_or_night_id return self._day_or_night_id.get(s2_cell_id, Unknown.REGULAR)
def __init__(self, data): """ Creates a new Monster Event based on the given dict. """ super(MonEvent, self).__init__('monster') check_for_none = BaseEvent.check_for_none # Identification self.enc_id = data['encounter_id'] self.monster_id = int(data['pokemon_id']) # Time Left self.disappear_time = datetime.utcfromtimestamp(data['disappear_time']) # Spawn Data self.spawn_start = check_for_none(int, data.get('spawn_start'), Unknown.REGULAR) self.spawn_end = check_for_none(int, data.get('spawn_end'), Unknown.REGULAR) self.spawn_verified = check_for_none(bool, data.get('verified'), False) # Location self.lat = float(data['latitude']) self.lng = float(data['longitude']) self.distance = Unknown.SMALL # Completed by Manager self.direction = Unknown.TINY # Completed by Manager self.weather_id = 7 # Encounter Stats self.mon_lvl = check_for_none(int, data.get('pokemon_level'), Unknown.TINY) self.cp = check_for_none(int, data.get('cp'), Unknown.TINY) # IVs self.atk_iv = check_for_none(int, data.get('individual_attack'), Unknown.TINY) self.def_iv = check_for_none(int, data.get('individual_defense'), Unknown.TINY) self.sta_iv = check_for_none(int, data.get('individual_stamina'), Unknown.TINY) if Unknown.is_not(self.atk_iv, self.def_iv, self.sta_iv): self.iv = \ 100 * (self.atk_iv + self.def_iv + self.sta_iv) / float(45) else: self.iv = Unknown.SMALL # Form self.form_id = check_for_none(int, data.get('form'), 0) # Quick Move self.quick_move_id = check_for_none(int, data.get('move_1'), Unknown.TINY) self.quick_damage = get_move_damage(self.quick_move_id) self.quick_dps = get_move_dps(self.quick_move_id) self.quick_duration = get_move_duration(self.quick_move_id) self.quick_energy = get_move_energy(self.quick_move_id) # Charge Move self.charge_move_id = check_for_none(int, data.get('move_2'), Unknown.TINY) self.charge_damage = get_move_damage(self.charge_move_id) self.charge_dps = get_move_dps(self.charge_move_id) self.charge_duration = get_move_duration(self.quick_move_id) self.charge_energy = get_move_energy(self.charge_move_id) # Cosmetic self.gender = MonUtils.get_gender_sym( check_for_none(int, data.get('gender'), Unknown.TINY)) self.height = check_for_none(float, data.get('height'), Unknown.SMALL) self.weight = check_for_none(float, data.get('weight'), Unknown.SMALL) if Unknown.is_not(self.height, self.weight): self.size = get_pokemon_size(self.monster_id, self.height, self.weight) else: self.size = Unknown.SMALL # Correct this later self.name = self.monster_id self.geofence = Unknown.REGULAR self.custom_dts = {}
def cell_weather_id(self, s2_cell_id, cell_weather_id=Unknown.REGULAR): """ Update and return weather_id for a cell """ if Unknown.is_not(cell_weather_id): self._cell_weather_id[s2_cell_id] = cell_weather_id return self._cell_weather_id.get(s2_cell_id, Unknown.REGULAR)
def gym_desc(self, gym_id, gym_desc=Unknown.REGULAR): """ Update and return the gym_desc for a gym. """ if Unknown.is_not(gym_desc): self._gym_desc[gym_id] = gym_desc return self._gym_desc.get(gym_id, Unknown.REGULAR)
def gym_team(self, gym_id, team_id=Unknown.TINY): """ Update and return the team_id of a gym. """ if Unknown.is_not(team_id): self._gym_team[gym_id] = team_id return self._gym_team.get(gym_id, Unknown.TINY)
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ time = get_time_as_str(self.disappear_time, timezone) form_name = locale.get_form_name(self.monster_id, self.form_id) costume_name = locale.get_costume_name(self.monster_id, self.costume_id) weather_name = locale.get_weather_name(self.weather_id) boosted_weather_name = locale.get_weather_name(self.boosted_weather_id) type1 = locale.get_type_name(self.types[0]) type2 = locale.get_type_name(self.types[1]) dts = self.custom_dts.copy() dts.update({ # Identification 'encounter_id': self.enc_id, 'mon_name': locale.get_pokemon_name(self.monster_id), 'mon_id': self.monster_id, 'mon_id_3': "{:03}".format(self.monster_id), # Time Remaining 'time_left': time[0], '12h_time': time[1], '24h_time': time[2], 'time_left_no_secs': time[3], '12h_time_no_secs': time[4], '24h_time_no_secs': time[5], 'time_left_raw_hours': time[6], 'time_left_raw_minutes': time[7], 'time_left_raw_seconds': time[8], # Spawn Data 'spawn_start': self.spawn_start, 'spawn_end': self.spawn_end, 'spawn_verified': self.spawn_verified > 0 if Unknown.is_not(self.spawn_verified) else Unknown.REGULAR, 'spawn_verified_emoji': get_spawn_verified_emoji(self.spawn_verified), 'spawn_verified_emoji_or_empty': ( '' if self.spawn_verified != 1 else get_spawn_verified_emoji(self.spawn_verified)), 'spawn_unverified_emoji_or_empty': ( '' if self.spawn_verified != 0 else get_spawn_verified_emoji(self.spawn_verified)), # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence, # Weather 'weather_id': self.weather_id, 'weather': weather_name, 'weather_or_empty': Unknown.or_empty(weather_name), 'weather_emoji': get_weather_emoji(self.weather_id), 'boosted_weather_id': self.boosted_weather_id, 'boosted_weather': boosted_weather_name, 'boosted_weather_or_empty': ( '' if self.boosted_weather_id == 0 else Unknown.or_empty(boosted_weather_name)), 'boosted_weather_emoji': get_weather_emoji(self.boosted_weather_id), 'boosted_or_empty': locale.get_boosted_text() if \ Unknown.is_not(self.boosted_weather_id) and self.boosted_weather_id != 0 else '', # Encounter Stats 'mon_lvl': self.mon_lvl, 'cp': self.cp, # IVs 'iv_0': ( "{:.0f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.TINY), 'iv': ( "{:.1f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.SMALL), 'iv_2': ( "{:.2f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.SMALL), 'atk': self.atk_iv, 'def': self.def_iv, 'sta': self.sta_iv, # PVP Information 'great_mon_id': self.great_id, 'great_product': self.great_product, 'great_mon_name': locale.get_pokemon_name(self.great_id), 'great_cp': self.great_cp, 'great_level': self.great_level, 'great_url': 'https://www.stadiumgaming.gg/rank-checker?' + urlencode({ 'pokemon': re.sub(r'[^A-Za-z0-9\s]+', '', locale.get_english_pokemon_name( self.great_id)), 'league': '1500', 'att_iv': self.atk_iv, 'def_iv': self.def_iv, 'hp_iv': self.sta_iv, 'min_iv': '0', 'include-best-buddy': 'false' }), 'great_pvpoke': 'https://pvpoke.com/rankings/all/1500/overall/{}{}/'.format( re.sub(r'[^A-Za-z0-9\s]+', '', locale.get_english_pokemon_name(self.great_id)) .lower().replace(' ', '_'), '_' + re.sub(r'[^A-Za-z0-9\s]+', '', locale.get_english_form_name( self.great_id, self.form_id) .lower().replace(' ', '_')) if not any(x in locale.get_english_form_name( self.great_id, self.form_id) for x in ['unknown', 'Normal']) else ''), 'ultra_mon_id': self.ultra_id, 'ultra_product': self.ultra_product, 'ultra_mon_name': locale.get_pokemon_name(self.ultra_id), 'ultra_cp': self.ultra_cp, 'ultra_level': self.ultra_level, 'ultra_url': 'https://www.stadiumgaming.gg/rank-checker?' + urlencode({ 'pokemon': re.sub(r'[^A-Za-z0-9\s]+', '', locale.get_english_pokemon_name( self.ultra_id)), 'league': '2500', 'att_iv': self.atk_iv, 'def_iv': self.def_iv, 'hp_iv': self.sta_iv, 'min_iv': '0', 'include-best-buddy': 'false' }), 'ultra_pvpoke': 'https://pvpoke.com/rankings/all/2500/overall/{}{}/'.format( re.sub(r'[^A-Za-z0-9\s]+', '', locale.get_english_pokemon_name(self.ultra_id)) .lower().replace(' ', '_'), '_' + re.sub(r'[^A-Za-z0-9\s]+', '', locale.get_english_form_name( self.ultra_id, self.form_id) .lower().replace(' ', '_')) if not any(x in locale.get_english_form_name( self.ultra_id, self.form_id) for x in ['unknown', 'Normal']) else ''), # Type 'type1': type1, 'type1_or_empty': Unknown.or_empty(type1), 'type1_emoji': Unknown.or_empty(get_type_emoji(self.types[0])), 'type2': type2, 'type2_or_empty': Unknown.or_empty(type2), 'type2_emoji': Unknown.or_empty(get_type_emoji(self.types[1])), 'types': ( "{}/{}".format(type1, type2) if Unknown.is_not(type2) else type1), 'types_emoji': ( "{}{}".format( get_type_emoji(self.types[0]), get_type_emoji(self.types[1])) if Unknown.is_not(type2) else get_type_emoji(self.types[0])), # Form 'form': form_name, 'form_or_empty': Unknown.or_empty(form_name), 'form_id': self.form_id, 'form_id_2': "{:02d}".format(self.form_id), 'form_id_3': "{:03d}".format(self.form_id), # Costume 'costume': costume_name, 'costume_or_empty': Unknown.or_empty(costume_name), 'costume_id': self.costume_id, 'costume_id_2': "{:02d}".format(self.costume_id), 'costume_id_3': "{:03d}".format(self.costume_id), # Quick Move 'quick_move': locale.get_move_name(self.quick_id), 'quick_id': self.quick_id, 'quick_type_id': self.quick_type, 'quick_type': locale.get_type_name(self.quick_type), 'quick_type_emoji': get_type_emoji(self.quick_type), 'quick_damage': self.quick_damage, 'quick_dps': self.quick_dps, 'quick_duration': self.quick_duration, 'quick_energy': self.quick_energy, # Charge Move 'charge_move': locale.get_move_name(self.charge_id), 'charge_id': self.charge_id, 'charge_type_id': self.charge_type, 'charge_type': locale.get_type_name(self.charge_type), 'charge_type_emoji': get_type_emoji(self.charge_type), 'charge_damage': self.charge_damage, 'charge_dps': self.charge_dps, 'charge_duration': self.charge_duration, 'charge_energy': self.charge_energy, # Cosmetic 'gender': self.gender, 'height_0': ( "{:.0f}".format(self.height) if Unknown.is_not(self.height) else Unknown.TINY), 'height': ( "{:.1f}".format(self.height) if Unknown.is_not(self.height) else Unknown.SMALL), 'height_2': ( "{:.2f}".format(self.height) if Unknown.is_not(self.height) else Unknown.SMALL), 'weight_0': ( "{:.0f}".format(self.weight) if Unknown.is_not(self.weight) else Unknown.TINY), 'weight': ( "{:.1f}".format(self.weight) if Unknown.is_not(self.weight) else Unknown.SMALL), 'weight_2': ( "{:.2f}".format(self.weight) if Unknown.is_not(self.weight) else Unknown.SMALL), 'size': locale.get_size_name(self.size_id), # Misc 'atk_grade': ( Unknown.or_empty(self.atk_grade, Unknown.TINY)), 'def_grade': ( Unknown.or_empty(self.def_grade, Unknown.TINY)), 'rarity_id': self.rarity_id, 'rarity': locale.get_rarity_name(self.rarity_id), # Catch Prob 'base_catch_0': ( "{:.0f}".format(self.base_catch * 100) if Unknown.is_not(self.base_catch) else Unknown.TINY), 'base_catch': ( "{:.1f}".format(self.base_catch * 100) if Unknown.is_not(self.base_catch) else Unknown.SMALL), 'base_catch_2': ( "{:.2f}".format(self.base_catch * 100) if Unknown.is_not(self.base_catch) else Unknown.SMALL), 'great_catch_0': ( "{:.0f}".format(self.great_catch * 100) if Unknown.is_not(self.great_catch) else Unknown.TINY), 'great_catch': ( "{:.1f}".format(self.great_catch * 100) if Unknown.is_not(self.great_catch) else Unknown.SMALL), 'great_catch_2': ( "{:.2f}".format(self.great_catch * 100) if Unknown.is_not(self.great_catch) else Unknown.SMALL), 'ultra_catch_0': ( "{:.0f}".format(self.ultra_catch * 100) if Unknown.is_not(self.ultra_catch) else Unknown.TINY), 'ultra_catch': ( "{:.1f}".format(self.ultra_catch * 100) if Unknown.is_not(self.ultra_catch) else Unknown.SMALL), 'ultra_catch_2': ( "{:.2f}".format(self.ultra_catch * 100) if Unknown.is_not(self.ultra_catch) else Unknown.SMALL), # Misc 'big_karp': ( 'big' if self.monster_id == 129 and Unknown.is_not(self.weight) and self.weight >= 13.13 else ''), 'tiny_rat': ( 'tiny' if self.monster_id == 19 and Unknown.is_not(self.weight) and self.weight <= 2.41 else '') }) return dts
def gym_image(self, gym_id, gym_image=Unknown.REGULAR): """ Update and return the gym_image for a gym. """ if Unknown.is_not(gym_image): self._gym_image[gym_id] = gym_image return self._gym_image.get(gym_id, get_image_url('icons/gym_0.png'))
def quest_reward(self, stop_id, reward=None): """ Update and return the reward for a quest.""" if Unknown.is_not(reward): self._reward[stop_id] = reward return self._reward.get(stop_id, Unknown.REGULAR)
def gym_name(self, gym_id, gym_name=Unknown.REGULAR): """ Update and return the gym_name for a gym. """ if Unknown.is_not(gym_name): self._gym_name[gym_id] = gym_name return self._gym_name.get(gym_id, Unknown.REGULAR)
def __init__(self, data): """ Creates a new Monster Event based on the given dict. """ super(MonEvent, self).__init__('monster') check_for_none = BaseEvent.check_for_none # Identification self.enc_id = data['encounter_id'] self.monster_id = int(data['pokemon_id']) # Time Left self.disappear_time = datetime.utcfromtimestamp(data['disappear_time']) self.time_left = get_seconds_remaining(self.disappear_time) # Spawn Data self.spawn_start = check_for_none(int, data.get('spawn_start'), Unknown.REGULAR) self.spawn_end = check_for_none(int, data.get('spawn_end'), Unknown.REGULAR) self.spawn_verified = check_for_none(int, data.get('verified'), Unknown.REGULAR) # Location self.lat = float(data['latitude']) self.lng = float(data['longitude']) self.distance = Unknown.SMALL # Completed by Manager self.direction = Unknown.TINY # Completed by Manager self.weather_id = check_for_none(int, data.get('weather'), Unknown.TINY) self.boosted_weather_id = check_for_none( int, data.get('boosted_weather') or data.get('weather_boosted_condition'), 0) # Encounter Stats self.mon_lvl = check_for_none(int, data.get('pokemon_level'), Unknown.TINY) self.cp = check_for_none(int, data.get('cp'), Unknown.TINY) # IVs self.atk_iv = check_for_none(int, data.get('individual_attack'), Unknown.TINY) self.def_iv = check_for_none(int, data.get('individual_defense'), Unknown.TINY) self.sta_iv = check_for_none(int, data.get('individual_stamina'), Unknown.TINY) if Unknown.is_not(self.atk_iv, self.def_iv, self.sta_iv): self.iv = \ 100 * (self.atk_iv + self.def_iv + self.sta_iv) / float(45) (self.great_product, self.great_id, self.great_cp, self.great_level, self.ultra_product, self.ultra_id, self.ultra_cp, self.ultra_level) = \ PvpUtils.get_pvp_info( self.monster_id, self.atk_iv, self.def_iv, self.sta_iv, self.mon_lvl) else: self.iv = Unknown.SMALL self.great_product = Unknown.SMALL self.ultra_product = Unknown.SMALL self.great_id = self.monster_id self.ultra_id = self.monster_id self.great_cp = Unknown.SMALL self.ultra_cp = Unknown.SMALL self.great_level = Unknown.SMALL self.ultra_level = Unknown.SMALL # Quick Move self.quick_id = check_for_none(int, data.get('move_1'), Unknown.TINY) self.quick_type = get_move_type(self.quick_id) self.quick_damage = get_move_damage(self.quick_id) self.quick_dps = get_move_dps(self.quick_id) self.quick_duration = get_move_duration(self.quick_id) self.quick_energy = get_move_energy(self.quick_id) # Charge Move self.charge_id = check_for_none(int, data.get('move_2'), Unknown.TINY) self.charge_type = get_move_type(self.charge_id) self.charge_damage = get_move_damage(self.charge_id) self.charge_dps = get_move_dps(self.charge_id) self.charge_duration = get_move_duration(self.charge_id) self.charge_energy = get_move_energy(self.charge_id) # Catch Probs self.base_catch = check_for_none(float, data.get('base_catch'), Unknown.TINY) self.great_catch = check_for_none(float, data.get('great_catch'), Unknown.TINY) self.ultra_catch = check_for_none(float, data.get('ultra_catch'), Unknown.TINY) # Attack Rating self.atk_grade = check_for_none(str, data.get('atk_grade'), Unknown.TINY) self.def_grade = check_for_none(str, data.get('def_grade'), Unknown.TINY) # Cosmetic self.gender = MonUtils.get_gender_sym( check_for_none(int, data.get('gender'), Unknown.TINY)) self.height = check_for_none(float, data.get('height'), Unknown.SMALL) self.weight = check_for_none(float, data.get('weight'), Unknown.SMALL) if Unknown.is_not(self.height, self.weight): self.size_id = get_pokemon_size(self.monster_id, self.height, self.weight) else: self.size_id = Unknown.SMALL self.types = get_base_types(self.monster_id) # Form self.form_id = check_for_none(int, data.get('form'), 0) # Costume self.costume_id = check_for_none(int, data.get('costume'), 0) # Rarity self.rarity_id = check_for_none(int, data.get('rarity'), Unknown.TINY) # Correct this later self.name = self.monster_id self.geofence = Unknown.REGULAR self.custom_dts = {}
def generate_dts(self, locale): """ Return a dict with all the DTS for this event. """ raid_end_time = get_time_as_str(self.raid_end) dts = self.custom_dts.copy() cp_range = get_pokemon_cp_range(self.mon_id, 20) dts.update({ # Identification 'gym_id': self.gym_id, # Time Remaining 'raid_time_left': raid_end_time[0], '12h_raid_end': raid_end_time[1], '24h_raid_end': raid_end_time[2], # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': (get_dist_as_str(self.distance) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, # Raid Info 'raid_lvl': self.raid_lvl, 'mon_name': locale.get_pokemon_name(self.mon_id), 'mon_id': self.mon_id, 'mon_id_3': "{:03}".format(self.mon_id), # TODO: Form? # Quick Move 'quick_move': locale.get_move_name(self.quick_id), 'quick_id': self.quick_id, 'quick_damage': self.quick_damage, 'quick_dps': self.quick_dps, 'quick_duration': self.quick_duration, 'quick_energy': self.quick_energy, # Charge Move 'charge_move': locale.get_move_name(self.charge_id), 'charge_id': self.charge_id, 'charge_damage': self.charge_damage, 'charge_dps': self.charge_dps, 'charge_duration': self.charge_duration, 'charge_energy': self.charge_energy, # Potential CP 'min_cp': cp_range[0], 'max_cp': cp_range[1], # Gym Details 'gym_name': self.gym_name, 'gym_description': self.gym_description, 'gym_image': self.gym_image, 'team_id': self.current_team_id, 'team_name': locale.get_team_name(self.current_team_id), 'team_leader': locale.get_leader_name(self.current_team_id) }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ raid_end_time = get_time_as_str(self.raid_end, timezone) dts = self.custom_dts.copy() form_name = locale.get_form_name(self.mon_id, self.form_id) costume_name = locale.get_costume_name(self.mon_id, self.costume_id) boosted_weather_name = locale.get_weather_name(self.boosted_weather_id) weather_name = locale.get_weather_name(self.weather_id) type1 = locale.get_type_name(self.types[0]) type2 = locale.get_type_name(self.types[1]) cp_range = get_pokemon_cp_range(self.mon_id, self.boss_level) dts.update({ # Identification 'gym_id': self.gym_id, # Time Remaining 'raid_time_left': raid_end_time[0], '12h_raid_end': raid_end_time[1], '24h_raid_end': raid_end_time[2], # Time Remaining Without Seconds 'raid_time_no_secs': raid_end_time[3], '12h_raid_end_no_secs': raid_end_time[4], '24h_raid_end_no_secs': raid_end_time[5], # Raw time remaining values 'raid_time_raw_hours': raid_end_time[6], 'raid_time_raw_minutes': raid_end_time[7], 'raid_time_raw_seconds': raid_end_time[8], # Type 'type1': type1, 'type1_or_empty': Unknown.or_empty(type1), 'type1_emoji': Unknown.or_empty(get_type_emoji(self.types[0])), 'type2': type2, 'type2_or_empty': Unknown.or_empty(type2), 'type2_emoji': Unknown.or_empty(get_type_emoji(self.types[1])), 'types': ("{}/{}".format(type1, type2) if Unknown.is_not(type2) else type1), 'types_emoji': ("{}{}".format(get_type_emoji(self.types[0]), get_type_emoji(self.types[1])) if Unknown.is_not(type2) else get_type_emoji(self.types[0])), # Form 'form': form_name, 'form_or_empty': Unknown.or_empty(form_name), 'form_id': self.form_id, 'form_id_2': "{:02d}".format(self.form_id), 'form_id_3': "{:03d}".format(self.form_id), # Costume 'costume': costume_name, 'costume_or_empty': Unknown.or_empty(costume_name), 'costume_id': self.costume_id, 'costume_id_2': "{:02d}".format(self.costume_id), 'costume_id_3': "{:03d}".format(self.costume_id), # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': (get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'waze': get_waze_link(self.lat, self.lng), 'geofence': self.geofence, # Weather 'weather_id': self.weather_id, 'weather': weather_name, 'weather_or_empty': Unknown.or_empty(weather_name), 'weather_emoji': get_weather_emoji(self.weather_id), 'boosted_weather_id': self.boosted_weather_id, 'boosted_weather': boosted_weather_name, 'boosted_weather_or_empty': ('' if self.boosted_weather_id == 0 else Unknown.or_empty(boosted_weather_name)), 'boosted_weather_emoji': get_weather_emoji(self.boosted_weather_id), 'boosted_or_empty': locale.get_boosted_text() if self.boss_level == 25 else '', # Raid Info 'raid_lvl': self.raid_lvl, 'mon_name': locale.get_pokemon_name(self.mon_id), 'mon_id': self.mon_id, 'mon_id_3': "{:03}".format(self.mon_id), 'gender': self.gender, # TODO: Form? # Quick Move 'quick_move': locale.get_move_name(self.quick_id), 'quick_id': self.quick_id, 'quick_type_id': self.quick_type, 'quick_type': locale.get_type_name(self.quick_type), 'quick_type_emoji': get_type_emoji(self.quick_type), 'quick_damage': self.quick_damage, 'quick_dps': self.quick_dps, 'quick_duration': self.quick_duration, 'quick_energy': self.quick_energy, # Charge Move 'charge_move': locale.get_move_name(self.charge_id), 'charge_id': self.charge_id, 'charge_type_id': self.charge_type, 'charge_type': locale.get_type_name(self.charge_type), 'charge_type_emoji': get_type_emoji(self.charge_type), 'charge_damage': self.charge_damage, 'charge_dps': self.charge_dps, 'charge_duration': self.charge_duration, 'charge_energy': self.charge_energy, # CP info 'cp': self.cp, 'min_cp': cp_range[0], 'max_cp': cp_range[1], # Gym Details 'gym_name': self.gym_name, 'gym_description': self.gym_description, 'gym_image': self.gym_image, 'sponsor_id': self.sponsor_id, 'sponsored': self.sponsor_id > 0 if Unknown.is_not(self.sponsor_id) else Unknown.REGULAR, 'ex_eligible': self.ex_eligible > 0 if Unknown.is_not(self.ex_eligible) else Unknown.REGULAR, 'ex_eligible_emoji': get_ex_eligible_emoji(self.ex_eligible), 'park': self.park, 'team_id': self.current_team_id, 'team_emoji': get_team_emoji(self.current_team_id), 'team_name': locale.get_team_name(self.current_team_id), 'team_color': locale.get_team_color(self.current_team_id), 'team_leader': locale.get_leader_name(self.current_team_id) }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ time = get_time_as_str(self.disappear_time, timezone) form_name = locale.get_form_name(self.monster_id, self.form_id) costume_name = locale.get_costume_name(self.monster_id, self.costume_id) weather_name = locale.get_weather_name(self.weather_id) boosted_weather_name = locale.get_weather_name(self.boosted_weather_id) type1 = locale.get_type_name(self.types[0]) type2 = locale.get_type_name(self.types[1]) dts = self.custom_dts.copy() dts.update({ # Identification 'encounter_id': self.enc_id, 'mon_name': locale.get_pokemon_name(self.monster_id), 'mon_id': self.monster_id, 'mon_id_3': "{:03}".format(self.monster_id), # Time Remaining 'time_left': time[0], '12h_time': time[1], '24h_time': time[2], # Spawn Data 'spawn_start': self.spawn_start, 'spawn_end': self.spawn_end, 'spawn_verified': self.spawn_verified, # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': ( get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, # Weather 'weather_id': self.weather_id, 'weather': weather_name, 'weather_or_empty': Unknown.or_empty(weather_name), 'weather_emoji': get_weather_emoji(self.weather_id), 'boosted_weather_id': self.boosted_weather_id, 'boosted_weather': boosted_weather_name, 'boosted_weather_or_empty': ( '' if self.boosted_weather_id == 0 else Unknown.or_empty(boosted_weather_name)), 'boosted_weather_emoji': get_weather_emoji(self.boosted_weather_id), 'boosted_or_empty': locale.get_boosted_text() if \ Unknown.is_not(self.boosted_weather_id) and self.boosted_weather_id != 0 else '', # Encounter Stats 'mon_lvl': self.mon_lvl, 'cp': self.cp, # IVs 'iv_0': ( "{:.0f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.TINY), 'iv': ( "{:.1f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.SMALL), 'iv_2': ( "{:.2f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.SMALL), 'atk': self.atk_iv, 'def': self.def_iv, 'sta': self.sta_iv, # Type 'type1': type1, 'type1_or_empty': Unknown.or_empty(type1), 'type1_emoji': Unknown.or_empty(get_type_emoji(self.types[0])), 'type2': type2, 'type2_or_empty': Unknown.or_empty(type2), 'type2_emoji': Unknown.or_empty(get_type_emoji(self.types[1])), 'types': ( "{}/{}".format(type1, type2) if Unknown.is_not(type2) else type1), 'types_emoji': ( "{}{}".format( get_type_emoji(self.types[0]), get_type_emoji(self.types[1])) if Unknown.is_not(type2) else get_type_emoji(self.types[0])), # Form 'form': form_name, 'form_or_empty': Unknown.or_empty(form_name), 'form_id': self.form_id, 'form_id_3': "{:03d}".format(self.form_id), # Costume 'costume': costume_name, 'costume_or_empty': Unknown.or_empty(costume_name), 'costume_id': self.costume_id, 'costume_id_3': "{:03d}".format(self.costume_id), # Quick Move 'quick_move': locale.get_move_name(self.quick_id), 'quick_id': self.quick_id, 'quick_type_id': self.quick_type, 'quick_type': locale.get_type_name(self.quick_type), 'quick_type_emoji': get_type_emoji(self.quick_type), 'quick_damage': self.quick_damage, 'quick_dps': self.quick_dps, 'quick_duration': self.quick_duration, 'quick_energy': self.quick_energy, # Charge Move 'charge_move': locale.get_move_name(self.charge_id), 'charge_id': self.charge_id, 'charge_type_id': self.charge_type, 'charge_type': locale.get_type_name(self.charge_type), 'charge_type_emoji': get_type_emoji(self.charge_type), 'charge_damage': self.charge_damage, 'charge_dps': self.charge_dps, 'charge_duration': self.charge_duration, 'charge_energy': self.charge_energy, # Cosmetic 'gender': self.gender, 'height_0': ( "{:.0f}".format(self.height) if Unknown.is_not(self.height) else Unknown.TINY), 'height': ( "{:.1f}".format(self.height) if Unknown.is_not(self.height) else Unknown.SMALL), 'height_2': ( "{:.2f}".format(self.height) if Unknown.is_not(self.height) else Unknown.SMALL), 'weight_0': ( "{:.0f}".format(self.weight) if Unknown.is_not(self.weight) else Unknown.TINY), 'weight': ( "{:.1f}".format(self.weight) if Unknown.is_not(self.weight) else Unknown.SMALL), 'weight_2': ( "{:.2f}".format(self.weight) if Unknown.is_not(self.weight) else Unknown.SMALL), 'size': locale.get_size_name(self.size_id), # Attack rating 'atk_grade': ( Unknown.or_empty(self.atk_grade, Unknown.TINY)), 'def_grade': ( Unknown.or_empty(self.def_grade, Unknown.TINY)), # Catch Prob 'base_catch_0': ( "{:.0f}".format(self.base_catch * 100) if Unknown.is_not(self.base_catch) else Unknown.TINY), 'base_catch': ( "{:.1f}".format(self.base_catch * 100) if Unknown.is_not(self.base_catch) else Unknown.SMALL), 'base_catch_2': ( "{:.2f}".format(self.base_catch * 100) if Unknown.is_not(self.base_catch) else Unknown.SMALL), 'great_catch_0': ( "{:.0f}".format(self.great_catch * 100) if Unknown.is_not(self.great_catch) else Unknown.TINY), 'great_catch': ( "{:.1f}".format(self.great_catch * 100) if Unknown.is_not(self.great_catch) else Unknown.SMALL), 'great_catch_2': ( "{:.2f}".format(self.great_catch * 100) if Unknown.is_not(self.great_catch) else Unknown.SMALL), 'ultra_catch_0': ( "{:.0f}".format(self.ultra_catch * 100) if Unknown.is_not(self.ultra_catch) else Unknown.TINY), 'ultra_catch': ( "{:.1f}".format(self.ultra_catch * 100) if Unknown.is_not(self.ultra_catch) else Unknown.SMALL), 'ultra_catch_2': ( "{:.2f}".format(self.ultra_catch * 100) if Unknown.is_not(self.ultra_catch) else Unknown.SMALL), # Misc 'big_karp': ( 'big' if self.monster_id == 129 and Unknown.is_not(self.weight) and self.weight >= 13.13 else ''), 'tiny_rat': ( 'tiny' if self.monster_id == 19 and Unknown.is_not(self.weight) and self.weight <= 2.41 else '') }) return dts
def __init__(self, data): """ Creates a new Stop Event based on the given dict. """ super(RaidEvent, self).__init__('raid') check_for_none = BaseEvent.check_for_none # Identification self.gym_id = data.get('gym_id') # Time Remaining self.raid_end = datetime.utcfromtimestamp( data.get('end') or data.get('raid_end')) # RM or Monocle self.time_left = get_seconds_remaining(self.raid_end) # Location self.lat = float(data['latitude']) self.lng = float(data['longitude']) self.distance = Unknown.SMALL # Completed by Manager self.direction = Unknown.TINY # Completed by Manager self.station = '' # Monster Info self.raid_lvl = int(data['level']) self.mon_id = int(data['pokemon_id']) self.cp = int(data['cp']) self.types = get_base_types(self.mon_id) self.boss_level = 20 # Weather Info self.weather_id = check_for_none(int, data.get('weather'), Unknown.TINY) self.boosted_weather_id = \ 0 if Unknown.is_not(self.weather_id) else Unknown.TINY if is_weather_boosted(self.mon_id, self.weather_id): self.boosted_weather_id = self.weather_id self.boss_level = 25 # Quick Move self.quick_id = check_for_none(int, data.get('move_1'), Unknown.TINY) self.quick_damage = get_move_damage(self.quick_id) self.quick_dps = get_move_dps(self.quick_id) self.quick_duration = get_move_duration(self.quick_id) self.quick_energy = get_move_energy(self.quick_id) # Charge Move self.charge_id = check_for_none(int, data.get('move_2'), Unknown.TINY) self.charge_damage = get_move_damage(self.charge_id) self.charge_dps = get_move_dps(self.charge_id) self.charge_duration = get_move_duration(self.quick_id) self.charge_energy = get_move_energy(self.charge_id) # Gym Details (currently only sent from Monocle) self.gym_name = check_for_none(str, data.get('name'), Unknown.REGULAR).strip() self.gym_description = check_for_none(str, data.get('description'), Unknown.REGULAR).strip() self.gym_image = check_for_none(str, data.get('url'), Unknown.REGULAR) self.gym_sponsor = check_for_none(int, data.get('sponsor'), Unknown.SMALL) self.gym_park = check_for_none(str, data.get('park'), Unknown.REGULAR) # Gym Team (this is only available from cache) self.current_team_id = check_for_none(int, int(data.get('team')), Unknown.TINY) self.name = self.gym_id self.geofence = Unknown.REGULAR self.custom_dts = {}
def generate_dts(self, locale): """ Return a dict with all the DTS for this event. """ time = get_time_as_str(self.disappear_time) form_name = locale.get_form_name(self.monster_id, self.form_id) weather_name = locale.get_weather_name(self.weather_id) dts = self.custom_dts.copy() dts.update({ # Identification 'encounter_id': self.enc_id, 'mon_name': locale.get_pokemon_name(self.monster_id), 'mon_id': self.monster_id, 'mon_id_3': "{:03}".format(self.monster_id), # Time Remaining 'time_left': time[0], '12h_time': time[1], '24h_time': time[2], # Spawn Data 'spawn_start': self.spawn_start, 'spawn_end': self.spawn_end, 'spawn_verified': self.spawn_verified, # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': (get_dist_as_str(self.distance) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, 'weather_id': self.weather_id, 'weather': weather_name, 'weather_or_empty': Unknown.or_empty(weather_name), 'weather_emoji': get_weather_emoji(self.weather_id), # Encounter Stats 'mon_lvl': self.mon_lvl, 'cp': self.cp, # IVs 'iv_0': ("{:.0f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.TINY), 'iv': ("{:.1f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.SMALL), 'iv_2': ("{:.2f}".format(self.iv) if Unknown.is_not(self.iv) else Unknown.SMALL), 'atk': self.atk_iv, 'def': self.def_iv, 'sta': self.sta_iv, # Form 'form': form_name, 'form_or_empty': Unknown.or_empty(form_name), 'form_id': self.form_id, 'form_id_3': "{:03d}".format(self.form_id), # Quick Move 'quick_move': locale.get_move_name(self.quick_move_id), 'quick_id': self.quick_move_id, 'quick_damage': self.quick_damage, 'quick_dps': self.quick_dps, 'quick_duration': self.quick_duration, 'quick_energy': self.quick_energy, # Charge Move 'charge_move': locale.get_move_name(self.charge_move_id), 'charge_id': self.charge_move_id, 'charge_damage': self.charge_damage, 'charge_dps': self.charge_dps, 'charge_duration': self.charge_duration, 'charge_energy': self.charge_energy, # Cosmetic 'gender': self.gender, 'height': self.height, 'weight': self.weight, 'size': self.size, # Misc 'big_karp': ('big' if self.monster_id == 129 and Unknown.is_not(self.weight) and self.weight >= 13.13 else ''), 'tiny_rat': ('tiny' if self.monster_id == 19 and Unknown.is_not(self.weight) and self.weight <= 2.41 else '') }) return dts
def generate_dts(self, locale, timezone, units): """ Return a dict with all the DTS for this event. """ raid_end_time = get_time_as_str(self.raid_end, timezone) dts = self.custom_dts.copy() exraid = self.gym_park if exraid == 'unknown': exraid = '' else: exraid = "\n*Potential EX Raid (" + exraid + ")*" boosted_weather_name = locale.get_weather_name(self.boosted_weather_id) weather_name = locale.get_weather_name(self.weather_id) type1 = locale.get_type_name(self.types[0]) type2 = locale.get_type_name(self.types[1]) cp_range = get_pokemon_cp_range(self.mon_id, self.boss_level) dts.update({ # Identification 'gym_id': self.gym_id, # Time Remaining 'raid_time_left': raid_end_time[0], '12h_raid_end': raid_end_time[1], '24h_raid_end': raid_end_time[2], # Type 'type1': type1, 'type1_or_empty': Unknown.or_empty(type1), 'type1_emoji': Unknown.or_empty(get_type_emoji(self.types[0])), 'type2': type2, 'type2_or_empty': Unknown.or_empty(type2), 'type2_emoji': Unknown.or_empty(get_type_emoji(self.types[1])), 'types': ("{}/{}".format(type1, type2) if Unknown.is_not(type2) else type1), 'types_emoji': ("{}{}".format(get_type_emoji(self.types[0]), get_type_emoji(self.types[1])) if Unknown.is_not(type2) else get_type_emoji(self.types[0])), # Location 'lat': self.lat, 'lng': self.lng, 'lat_5': "{:.5f}".format(self.lat), 'lng_5': "{:.5f}".format(self.lng), 'distance': (get_dist_as_str(self.distance, units) if Unknown.is_not(self.distance) else Unknown.SMALL), 'direction': self.direction, 'gmaps': get_gmaps_link(self.lat, self.lng), 'applemaps': get_applemaps_link(self.lat, self.lng), 'geofence': self.geofence, 'station': self.station, # Weather 'weather_id': self.weather_id, 'weather': weather_name, 'weather_or_empty': Unknown.or_empty(weather_name), 'weather_emoji': get_weather_emoji(self.weather_id), 'boosted_weather_id': self.boosted_weather_id, 'boosted_weather': boosted_weather_name, 'boosted_weather_or_empty': ('' if self.boosted_weather_id == 0 else Unknown.or_empty(boosted_weather_name)), 'boosted_weather_emoji': get_weather_emoji(self.boosted_weather_id), 'boosted_or_empty': locale.get_boosted_text() if self.boss_level == 25 else '', # Raid Info 'raid_lvl': self.raid_lvl, 'mon_name': locale.get_pokemon_name(self.mon_id), 'mon_id': self.mon_id, 'mon_id_3': "{:03}".format(self.mon_id), # TODO: Form? # Quick Move 'quick_move': locale.get_move_name(self.quick_id), 'quick_id': self.quick_id, 'quick_damage': self.quick_damage, 'quick_dps': self.quick_dps, 'quick_duration': self.quick_duration, 'quick_energy': self.quick_energy, # Charge Move 'charge_move': locale.get_move_name(self.charge_id), 'charge_id': self.charge_id, 'charge_damage': self.charge_damage, 'charge_dps': self.charge_dps, 'charge_duration': self.charge_duration, 'charge_energy': self.charge_energy, # CP info 'cp': self.cp, 'min_cp': cp_range[0], 'max_cp': cp_range[1], # Gym Details 'gym_name': self.gym_name, 'gym_description': self.gym_description, 'gym_image': self.gym_image, 'gym_sponsor': self.gym_sponsor, 'gym_park': exraid, 'team_id': self.current_team_id, 'team_name': locale.get_team_name(self.current_team_id), 'team_leader': locale.get_leader_name(self.current_team_id) }) return dts