diff --git a/README.md b/README.md index 4c0d8f4b44..7af7d2c0cb 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,10 @@ We use [Slack](https://slack.com) as a web chat. [Click here to join the chat!]( You need modify config.json (config.json.example for example) then pokecli.py --config config.json Please clean up your old clone if you have issue, and following the [install instruction](https://github.com/PokemonGoF/PokemonGo-Bot#installation). -## About dev/stable/master Branch +## About dev/master Branch Dev branch has most up to date feature and even everyone handle the part well, still, will have broken changes. Your test contribute and PR for fix are warm welcome. -Stable branch is better than dev branch. Setup with milestone tag. -Master branch is the thing you familiar. -No PR on stable/master branch to keep things easier. +Master branch is the stable branch. +No PR on master branch to keep things easier. ## Table of Contents - [Project Chat](#project-chat) - [Features](#features) @@ -191,11 +190,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. @@ -338,6 +341,7 @@ If using multiple usernames format like this: * riberod07 * th3w4y * Leaklessgfy + * codybaldwin ------- ## Credits diff --git a/config.json.example b/config.json.example index 3245708e6d..e6863521c9 100644 --- a/config.json.example +++ b/config.json.example @@ -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 } diff --git a/pokecli.py b/pokecli.py index 07cf746c06..dfd4506ae2 100755 --- a/pokecli.py +++ b/pokecli.py @@ -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: diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index d6df1a38d7..8fa7748e10 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -38,10 +38,39 @@ 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 + use_lucky_egg = self.config.use_lucky_egg + lucky_egg_count = self.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)) + 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(lucky_egg_count-1), 'green') + else: + logger.log('[+] Failed to use lucky egg!', 'red') + skip_evolves = True + elif use_lucky_egg: #lucky_egg_count is 0 + # 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) @@ -204,6 +233,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()