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 # 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 self.gender = MonUtils.get_gender_sym( check_for_none(int, data.get('gender'), Unknown.TINY)) # Form self.form_id = check_for_none(int, data.get('form'), 0) # Costume self.costume_id = check_for_none(int, data.get('costume'), 0) # 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_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) # 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.sponsor_id = check_for_none(int, data.get('sponsor'), Unknown.TINY) self.park = check_for_none(str, data.get('park'), Unknown.REGULAR) self.ex_eligible = check_for_none(int, data.get('is_ex_raid_eligible'), Unknown.REGULAR) # Gym Team (this is only available from cache) self.current_team_id = check_for_none( int, data.get('team_id', data.get('team')), Unknown.TINY) self.name = self.gym_id self.geofence = Unknown.REGULAR self.custom_dts = {}
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 __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 = {}