Skip to content

[FIX] evolve_all and use_lucky_egg #1541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, config):
self.latest_inventory = None
self.cell = None
self.recent_forts = [None] * config.max_circle_size
self.tick_count = 0

def start(self):
self._setup_logging()
Expand Down Expand Up @@ -66,6 +67,8 @@ def tick(self):
return

self.navigator.take_step()

self.tick_count +=1

def get_meta_cell(self):
location = self.position[0:2]
Expand Down
29 changes: 14 additions & 15 deletions pokemongo_bot/cell_workers/evolve_all_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,34 @@ def work(self):

def _should_run(self):
# Will skip evolving if user wants to use an egg and there is none
skip_evolves = False
if not self.config.evolve_all:
return False

if self.config.evolve_all:
return skip_evolves
# Evolve all is used - Don't run after the first tick or if the config flag is false
if self.bot.tick_count is not 0 or not self.config.use_lucky_egg:
return True

# Pop lucky egg before evolving to maximize xp gain
use_lucky_egg = self.config.use_lucky_egg
lucky_egg_count = self.bot.item_inventory_count(Item.ITEM_LUCKY_EGG.value)

if use_lucky_egg and lucky_egg_count > 0:
logger.log('Using lucky egg ... you have {}'
.format(lucky_egg_count))
# Lucky Egg should only be popped at the first tick
# Make sure the user has a lucky egg and skip if not
if lucky_egg_count > 0:
logger.log('Using lucky egg ... you have {}'.format(lucky_egg_count))
response_dict_lucky_egg = self.bot.use_lucky_egg()
if response_dict_lucky_egg and 'responses' in response_dict_lucky_egg and \
'USE_ITEM_XP_BOOST' in response_dict_lucky_egg['responses'] and \
'result' in response_dict_lucky_egg['responses']['USE_ITEM_XP_BOOST']:
result = response_dict_lucky_egg['responses']['USE_ITEM_XP_BOOST']['result']
if result is 1: # Request success
logger.log('Successfully used lucky egg... ({} left!)'
.format(lucky_egg_count-1), 'green')
logger.log('Successfully used lucky egg... ({} left!)'.format(lucky_egg_count-1), 'green')
return True
else:
logger.log('Failed to use lucky egg!', 'red')
skip_evolves = True
elif use_lucky_egg: #lucky_egg_count is 0
return False
else:
# Skipping evolve so they aren't wasted
logger.log('No lucky eggs... skipping evolve!', 'yellow')
skip_evolves = True

return skip_evolves
return False

def _release_evolved(self, release_cand_list_ids):
response_dict = self.bot.get_inventory()
Expand Down