Skip to content

Commit

Permalink
Lucky Egg - Evolve All
Browse files Browse the repository at this point in the history
Provides the ability to use a lucky egg before evolve_all. This will
maximize xp gain.
  • Loading branch information
codybaldwin committed Jul 25, 2016
1 parent 55adefe commit abfdb59
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,15 @@ To update your project do: `git pull` in the project folder
- `distance_unit` :
- `item_filter` :
- `evolve_all` : Set to true to evolve pokemon if possible
- `use_lucky_egg` : Set to true to use lucky egg (if available) before evolve_all

### Evolve All Configuration
By setting the `evolve_all` attribute in config.json, you can instruct the bot to automatically
evolve specified pokemons on startup. This is especially useful for batch-evolving after popping up
a lucky egg (currently this needs to be done manually).
a lucky egg.

A lucky egg can be used before evolving by setting the `use_lucky_egg` to true in config.json. If a
lucky egg is not available and "use_lucky_egg" is set to true, evolving will be skipped.

The evolve all mechanism evolves only higher CP pokemons. It does this by first ordering them from high-to-low CP.
It will also automatically transfer the evolved pokemons based on the release configuration.
Expand Down Expand Up @@ -338,6 +342,7 @@ If using multiple usernames format like this:
* riberod07
* th3w4y
* Leaklessgfy
* codybaldwin

-------
## Credits
Expand Down
3 changes: 2 additions & 1 deletion config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"location_cache": true,
"distance_unit": "km",
"item_filter": "101,102,103,104",
"evolve_all": "NONE"
"evolve_all": "NONE",
"use_lucky_egg": false
}
5 changes: 5 additions & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ def init_config():
help="(Ad-hoc mode) Bot will attempt to evolve all the pokemons captured!",
type=bool,
default=False)
parser.add_argument("-le",
"--use_lucky_egg",
help="Uses lucky egg when using evolve_all",
type=bool,
default=False)

config = parser.parse_args()
if not config.username and 'username' not in load:
Expand Down
43 changes: 39 additions & 4 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,38 @@ def take_step(self):

def work_on_cell(self, cell, position, include_fort_on_path):
if self.config.evolve_all:
# Run evolve all once. Flip the bit.
print('[#] Attempting to evolve all pokemons ...')
worker = EvolveAllWorker(self)
worker.work()
# Will skip evolving if user wants to use an egg and there is none
skip_evolves = False

# Pop lucky egg before evolving to maximize xp gain
if self.config.use_lucky_egg:
if self.item_inventory_count(Item.ITEM_LUCKY_EGG.value) > 0:
logger.log('[#] Using lucky egg ... you have {}'
.format(self.item_inventory_count(Item.ITEM_LUCKY_EGG.value)))
response_dict_lucky_egg = self.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(self.item_inventory_count(Item.ITEM_LUCKY_EGG.value)), 'green')
else:
logger.log('[+] Failed to use lucky egg!', 'red')
skip_evolves = True
else:
# Skipping evolve so they aren't wasted
logger.log('[#] No lucky eggs... skipping evolve!', 'yellow')
skip_evolves = True

if not skip_evolves:
# Run evolve all once.
print('[#] Attempting to evolve all pokemons ...')
worker = EvolveAllWorker(self)
worker.work()

# Flip the bit.
self.config.evolve_all = []

self._filter_ignored_pokemons(cell)
Expand Down Expand Up @@ -204,6 +232,13 @@ def drop_item(self, item_id, count):
# Example of good request response
#{'responses': {'RECYCLE_INVENTORY_ITEM': {'result': 1, 'new_count': 46}}, 'status_code': 1, 'auth_ticket': {'expire_timestamp_ms': 1469306228058L, 'start': '/HycFyfrT4t2yB2Ij+yoi+on778aymMgxY6RQgvrGAfQlNzRuIjpcnDd5dAxmfoTqDQrbz1m2dGqAIhJ+eFapg==', 'end': 'f5NOZ95a843tgzprJo4W7Q=='}, 'request_id': 8145806132888207460L}
return inventory_req

def use_lucky_egg(self):
self.api.use_item_xp_boost(item_id=301)
inventory_req = self.api.call()

return inventory_req


def update_inventory(self):
self.api.get_inventory()
Expand Down

0 comments on commit abfdb59

Please sign in to comment.