def parse_encounter_response(self, responses, job): if not responses: return self.scout_error("Empty encounter response") if self.has_captcha(): return self.scout_error("Account captcha'd") if self.is_banned(): return self.scout_error("Account banned") encounter = responses.get('ENCOUNTER') if not encounter: return self.scout_error("No encounter result returned.") if not encounter.HasField('wild_pokemon'): self.errors += 1 return self.scout_error("No wild pokemon info found.") enc_status = encounter.status # Check for shadowban - ENCOUNTER_BLOCKED_BY_ANTICHEAT if enc_status == 8: self.errors += 1 self.shadowbanned = True if enc_status != 1: return self.scout_error(ENCOUNTER_RESULTS[enc_status]) scout_level = self.get_stats('level') if scout_level < cfg_get('level'): return self.scout_error( "Trainer level {} is too low. Needs to be {}+".format( scout_level, cfg_get("level"))) pokemon_info = encounter.wild_pokemon.pokemon_data cp = pokemon_info.cp pokemon_level = calc_pokemon_level(pokemon_info.cp_multiplier) probs = encounter.capture_probability.capture_probability at = pokemon_info.individual_attack df = pokemon_info.individual_defense st = pokemon_info.individual_stamina iv = calc_iv(at, df, st) moveset_grades = get_moveset_grades(job.pokemon_id, job.pokemon_name, pokemon_info.move_1, pokemon_info.move_2) responses = { 'success': True, 'encounter_id': job.encounter_id, 'encounter_id_b64': b64encode(str(job.encounter_id)), 'height': pokemon_info.height_m, 'weight': pokemon_info.weight_kg, 'gender': pokemon_info.pokemon_display.gender, 'iv_percent': iv, 'iv_attack': at, 'iv_defense': df, 'iv_stamina': st, 'move_1': pokemon_info.move_1, 'move_2': pokemon_info.move_2, 'rating_attack': moveset_grades['offense'], 'rating_defense': moveset_grades['defense'], 'cp': cp, 'cp_multiplier': pokemon_info.cp_multiplier, 'level': pokemon_level, 'catch_prob_1': probs[0], 'catch_prob_2': probs[1], 'catch_prob_3': probs[2], 'scout_level': scout_level, 'encountered_time': time.time() } # Add form of Unown if job.pokemon_id == 201: responses['form'] = pokemon_info.pokemon_display.form self.log_info( u"Found a {:.1f}% ({}/{}/{}) L{} {} with {} CP (scout level {}).". format(iv, at, df, st, pokemon_level, job.pokemon_name, cp, scout_level)) inc_for_pokemon(job.pokemon_id) return responses
def parse_encounter_response(self, responses, job): if not responses: return self.scout_error("Empty encounter response.") if self.has_captcha(): return self.scout_error("Scout account captcha'd.") encounter = responses.get('ENCOUNTER', {}) enc_status = encounter.get('status', None) # Check for shadowban - ENCOUNTER_BLOCKED_BY_ANTICHEAT if enc_status == 8: self.shadowbanned = True if enc_status != 1: return self.scout_error(ENCOUNTER_RESULTS[enc_status]) if 'wild_pokemon' not in encounter: return self.scout_error("No wild pokemon info found.") scout_level = self.player_stats['level'] if scout_level < cfg_get("require_min_trainer_level"): return self.scout_error( "Trainer level {} is too low. Needs to be {}+".format( scout_level, cfg_get("require_min_trainer_level"))) pokemon_info = encounter['wild_pokemon']['pokemon_data'] cp = pokemon_info['cp'] pokemon_level = calc_pokemon_level(pokemon_info['cp_multiplier']) probs = encounter['capture_probability']['capture_probability'] at = pokemon_info.get('individual_attack', 0) df = pokemon_info.get('individual_defense', 0) st = pokemon_info.get('individual_stamina', 0) iv = calc_iv(at, df, st) moveset_grades = get_moveset_grades(job.pokemon_id, job.pokemon_name, pokemon_info['move_1'], pokemon_info['move_2']) responses = { 'success': True, 'encounter_id': job.encounter_id, 'encounter_id_b64': b64encode(str(job.encounter_id)), 'height': pokemon_info['height_m'], 'weight': pokemon_info['weight_kg'], 'gender': pokemon_info['pokemon_display']['gender'], 'iv_percent': iv, 'iv_attack': at, 'iv_defense': df, 'iv_stamina': st, 'move_1': pokemon_info['move_1'], 'move_2': pokemon_info['move_2'], 'rating_attack': moveset_grades['offense'], 'rating_defense': moveset_grades['defense'], 'cp': cp, 'cp_multiplier': pokemon_info['cp_multiplier'], 'level': pokemon_level, 'catch_prob_1': probs[0], 'catch_prob_2': probs[1], 'catch_prob_3': probs[2], 'scout_level': scout_level, 'encountered_time': time.time() } # Add form of Unown if job.pokemon_id == 201: responses['form'] = pokemon_info['pokemon_display'].get('form', None) self.log_info( u"Found a {:.1f}% ({}/{}/{}) L{} {} with {} CP (scout level {}).".format( iv, at, df, st, pokemon_level, job.pokemon_name, cp, scout_level)) inc_for_pokemon(job.pokemon_id) return responses
def parse_encounter_response(self, response, pokemon_id, pokemon_name): if response is None: return self.scout_error("Encounter response is None.") if has_captcha(response): return self.scout_error("Scout account captcha'd.") encounter = response.get('responses', {}).get('ENCOUNTER', {}) if encounter.get('status', None) == 3: return self.scout_error("Pokemon already despawned.") if 'wild_pokemon' not in encounter: return self.scout_error("No wild pokemon info found.") worker_level = get_player_level(response) if worker_level < cfg_get("require_min_trainer_level"): return self.scout_error( "Trainer level {} is too low. Needs to be {}+".format( worker_level, cfg_get("require_min_trainer_level"))) pokemon_info = encounter['wild_pokemon']['pokemon_data'] cp = pokemon_info['cp'] pokemon_level = calc_pokemon_level(pokemon_info['cp_multiplier']) probs = encounter['capture_probability']['capture_probability'] at = pokemon_info.get('individual_attack', 0) df = pokemon_info.get('individual_defense', 0) st = pokemon_info.get('individual_stamina', 0) iv = calc_iv(at, df, st) moveset_grades = get_moveset_grades(pokemon_id, pokemon_name, pokemon_info['move_1'], pokemon_info['move_2']) response = { 'success': True, 'height': pokemon_info['height_m'], 'weight': pokemon_info['weight_kg'], 'gender': pokemon_info['pokemon_display']['gender'], 'iv_percent': iv, 'iv_attack': at, 'iv_defense': df, 'iv_stamina': st, 'move_1': pokemon_info['move_1'], 'move_2': pokemon_info['move_2'], 'rating_attack': moveset_grades['offense'], 'rating_defense': moveset_grades['defense'], 'cp': cp, 'cp_multiplier': pokemon_info['cp_multiplier'], 'pokemon_level': pokemon_level, 'catch_prob_1': probs[0], 'catch_prob_2': probs[1], 'catch_prob_3': probs[2], 'worker_level': worker_level, 'encountered_time': time.time() } self.log_info( u"Found a {:.1f}% ({}/{}/{}) L{} {} with {} CP (scout level {}).". format(iv, at, df, st, pokemon_level, pokemon_name, cp, worker_level)) inc_for_pokemon(pokemon_id) return response