Skip to content

Commit 179fd80

Browse files
authored
Merge pull request jekirl#288 from infinitewarp/bug286
check disk encounter result before trying to read pokemon data; fixes j-e-k/poketrainer/jekirl#286
2 parents 808793e + 78754b4 commit 179fd80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pgoapi/pgoapi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,11 @@ def disk_encounter_pokemon(self, lureinfo, retry=False):
792792
POKEMON_NAMES.get(str(lureinfo.get('active_pokemon_id', 0)), "NA"))
793793
resp = self.disk_encounter(encounter_id=encounter_id, fort_id=fort_id, player_latitude=position[0],
794794
player_longitude=position[1]).call()['responses']['DISK_ENCOUNTER']
795-
pokemon = Pokemon(resp.get('pokemon_data', {}))
796795
result = resp.get('result', -1)
797-
capture_probability = create_capture_probability(resp.get('capture_probability', {}))
798-
self.log.debug("Attempt Encounter: %s", json.dumps(resp, indent=4, sort_keys=True))
799-
if result == 1:
796+
if result == 1 and 'pokemon_data' in resp and 'capture_probability' in resp:
797+
pokemon = Pokemon(resp.get('pokemon_data', {}))
798+
capture_probability = create_capture_probability(resp.get('capture_probability', {}))
799+
self.log.debug("Attempt Encounter: %s", json.dumps(resp, indent=4, sort_keys=True))
800800
return self.do_catch_pokemon(encounter_id, fort_id, capture_probability, pokemon)
801801
elif result == 5:
802802
self.log.info("Couldn't catch %s Your pokemon bag was full, attempting to clear and re-try",

0 commit comments

Comments
 (0)