Skip to content

Commit

Permalink
Merge pull request #5539 from Gobberwart/gobb_dev_catcherror
Browse files Browse the repository at this point in the history
Fixed 'pokemon_caught' event
  • Loading branch information
Gobberwart authored Sep 19, 2016
2 parents 05b0ba8 + 0aa4b42 commit 86d9bf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ If you do not want any data to be gathered, you can turn off this feature by set
* rawgni
* Breeze Ro
* bruno-kenji
* Gobberwart

## Disclaimer
©2016 Niantic, Inc. ©2016 Pokémon. ©1995–2016 Nintendo / Creatures Inc. / GAME FREAK inc. © 2016 Pokémon/Nintendo Pokémon and Pokémon character names are trademarks of Nintendo. The Google Maps Pin is a trademark of Google Inc. and the trade dress in the product design is a trademark of Google Inc. under license to The Pokémon Company. Other trademarks are the property of their respective owners.
Expand Down
29 changes: 10 additions & 19 deletions pokemongo_bot/event_handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,21 @@ def get_player_stats(self):
return ("Stats not loaded yet\n")

def get_event(self, event, formatted_msg, data):
msg = None
if event == 'level_up':
msg = "level up ({})".format(data["current_level"])
elif event == 'pokemon_caught':
if isinstance(self.pokemons, list): # alert_catch is a plain list
if data["pokemon"] in self.pokemons or "all" in self.pokemons:
trigger = None
if data["pokemon"] in self.pokemons:
trigger = self.pokemons[data["pokemon"]]
elif "all" in self.pokemons:
trigger = self.pokemons["all"]
if trigger:
if ((not "operator" in trigger or trigger["operator"] == "and") and data["cp"] >= trigger["cp"] and data["iv"] >= trigger["iv"]) or \
("operator" in trigger and trigger["operator"] == "or" and (data["cp"] >= trigger["cp"] or data["iv"] >= trigger["iv"])):
msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"], data["cp"], data["iv"])
else:
return "Catch error 1"
else: # alert_catch is a dict
if data["pokemon"] in self.pokemons:
trigger = self.pokemons[data["pokemon"]]
elif "all" in self.pokemons:
trigger = self.pokemons["all"]
else:
return
if (not "operator" in trigger or trigger["operator"] == "and") and data["cp"] >= trigger["cp"] and data[
"iv"] >= trigger["iv"] or ("operator" in trigger and trigger["operator"] == "or" and (
data["cp"] >= trigger["cp"] or data["iv"] >= trigger["iv"])):
msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"], data["cp"], data["iv"])
else:
return "Catch error 2"
elif event == 'egg_hatched':
msg = "Egg hatched with a {} CP: {}, IV: {} {}".format(data["name"], data["cp"], data["iv_ads"],
data["iv_pct"])
msg = "Egg hatched with a {} CP: {}, IV: {} {}".format(data["name"], data["cp"], data["iv_ads"], data["iv_pct"])
elif event == 'bot_sleep':
msg = "I am too tired, I will take a sleep till {}.".format(data["wake"])
elif event == 'catch_limit':
Expand Down

0 comments on commit 86d9bf7

Please sign in to comment.