From 3afc52cbf5703ed0affeafdda0e05b9aa4325e22 Mon Sep 17 00:00:00 2001 From: Daniel Mateus Pires Date: Sat, 23 Jul 2016 18:16:49 +0100 Subject: [PATCH 1/5] merging --- .../cell_workers/pokemon_catch_worker.py | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 7f800f5c0d..e13a3b276e 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -68,14 +68,20 @@ def work(self): # print 'use Poke Ball' pokeball = 1 - if cp > 300 and balls_stock[2] > 0: - # print 'use Great Ball' - pokeball = 2 - - if cp > 700 and balls_stock[3] > 0: - # print 'use Utra Ball' - pokeball = 3 - + if balls_stock[2] > 0: + if pokeball is 0 and cp <= 300 and balls_stock[2] < 10: + print('Great Ball stock is low... saving for pokemon with cp greater than 300') + elif cp > 300 or pokeball is 0: + #print 'use Great Ball' + pokeball = 2 + + if balls_stock[3] > 0: + if pokeball is 0 and cp <= 700 and balls_stock[3] < 10: + print('Ultra Ball stock is low... saving for pokemon with cp greater than 700') + elif cp > 700 or pokeball is 0: + #print 'use Utra Ball' + pokeball = 3 + if pokeball is 0: print_red( '[x] Out of pokeballs, switching to farming mode...') From a754ce85ad8fcb7ec29cf822944969fa1c93f71f Mon Sep 17 00:00:00 2001 From: Daniel Mateus Pires Date: Sat, 23 Jul 2016 21:39:05 +0100 Subject: [PATCH 2/5] Added a filter items that will recycle all unwanted items when they are collected at a Pokestop --- pokecli.py | 2 ++ pokemongo_bot/__init__.py | 9 ++++---- .../cell_workers/seen_fort_worker.py | 21 +++++++++++++++++-- pokemongo_bot/stepper.py | 3 ++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/pokecli.py b/pokecli.py index ba80176a35..cf2d0a37e0 100755 --- a/pokecli.py +++ b/pokecli.py @@ -83,6 +83,8 @@ def init_config(): "-t", "--test", help="Only parse the specified location", type=bool, default=False) parser.add_argument("-du", "--distance_unit", help="Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)", type=str, default="km") + parser.add_argument( + "-if", "--item_filter", help="Pass a list of unwanted items to recycle when collected at a Pokestop (e.g, [\"101\",\"102\",\"103\",\"104\"] to recycle potions when collected)", type=list, default=[]) config = parser.parse_args() if not config.username and not 'username' in load: config.username = raw_input("Username: ") diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index b7cdca3725..ea762c3371 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -178,9 +178,6 @@ def _setup_api(self): logger.log('[#] GreatBalls: ' + str(balls_stock[2])) logger.log('[#] UltraBalls: ' + str(balls_stock[3])) - # Testing - # self.drop_item(Item.ITEM_POTION.value,1) - # exit(0) self.get_player_info() if self.config.initial_transfer: @@ -190,9 +187,13 @@ def _setup_api(self): self.update_inventory() def drop_item(self, item_id, count): + print('test') self.api.recycle_inventory_item(item_id=item_id, count=count) inventory_req = self.api.call() - print(inventory_req) + + # 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 initial_transfer(self): logger.log('[x] Initial Transfer.') diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index 93249a387d..9b651e93d5 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -13,6 +13,7 @@ class SeenFortWorker(object): def __init__(self, fort, bot): self.fort = fort self.api = bot.api + self.bot = bot self.position = bot.position self.config = bot.config self.item_list = bot.item_list @@ -81,11 +82,27 @@ def work(self): tmp_count_items[item_id] += item['item_count'] for item_id, item_count in tmp_count_items.iteritems(): - item_id = str(item_id) - item_name = self.item_list[item_id] + item_name = self.item_list[str(item_id)] logger.log("[+] " + str(item_count) + "x " + item_name, 'green') + + # RECYCLING UNWANTED ITEMS + if str(item_id) in self.config.item_filter: + logger.log("[+] Recycling " + str(item_count) + "x " + item_name + "...", 'green') + #RECYCLE_INVENTORY_ITEM + response_dict_recycle = self.bot.drop_item(item_id=item_id, count=item_count) + print(response_dict_recycle) + + if response_dict_recycle and \ + 'responses' in response_dict_recycle and \ + 'RECYCLE_INVENTORY_ITEM' in response_dict_recycle['responses'] and \ + 'result' in response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']: + result = response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['result'] + if result is 1: # Request success + logger.log("[+] Recycling success, new count of " + item_name + ": " + response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['new_count'], 'green') + else: + logger.log("[+] Recycling failed!", 'red') else: logger.log("[#] Nothing found.", 'yellow') diff --git a/pokemongo_bot/stepper.py b/pokemongo_bot/stepper.py index 14667629ea..d8ec019956 100644 --- a/pokemongo_bot/stepper.py +++ b/pokemongo_bot/stepper.py @@ -35,7 +35,8 @@ def take_step(self): position = (self.origin_lat, self.origin_lon, 0.0) self.api.set_position(*position) - + print(self.api.list_curr_methods()) + self.api.list_curr_methods() for step in range(self.steplimit2): # starting at 0 index logger.log( From caaf708a807727e09bca41bbab408e94a3511e66 Mon Sep 17 00:00:00 2001 From: Daniel Mateus Pires Date: Sat, 23 Jul 2016 21:41:20 +0100 Subject: [PATCH 3/5] Fixing minor display bugs and deleting some printing that I used to debug --- pokemongo_bot/__init__.py | 1 - pokemongo_bot/cell_workers/seen_fort_worker.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index ea762c3371..02ae9191c0 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -187,7 +187,6 @@ def _setup_api(self): self.update_inventory() def drop_item(self, item_id, count): - print('test') self.api.recycle_inventory_item(item_id=item_id, count=count) inventory_req = self.api.call() diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index 9b651e93d5..7eb8ea154c 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -100,7 +100,7 @@ def work(self): 'result' in response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']: result = response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['result'] if result is 1: # Request success - logger.log("[+] Recycling success, new count of " + item_name + ": " + response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['new_count'], 'green') + logger.log("[+] Recycling success, count of " + item_name + " kept at : " + str(response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['new_count']), 'green') else: logger.log("[+] Recycling failed!", 'red') From 7592824f754e8d0a860c846bce1e796d7d291574 Mon Sep 17 00:00:00 2001 From: Daniel Mateus Pires Date: Sat, 23 Jul 2016 21:47:56 +0100 Subject: [PATCH 4/5] Updated README and took off some other debug messages from my part --- README.md | 1 + config.json.example | 5 +++-- pokemongo_bot/cell_workers/seen_fort_worker.py | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9120c14932..988eac2856 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ This project uses Google Maps. There's one map coupled with the project, but as -it, --initial_transfer Start the bot with a pokemon clean up, keeping only the higher CP of each pokemon. It respects -c as upper limit to release. -ms, --max_steps MAX_STEP Set the steps around your initial location (DEFAULT 5 mean 25 cells around your location) -iv IV, --pokemon_potential Set the ratio for the IV values to transfer (DEFAULT 0.4 eg. 0.4 will transfer a pokemon with IV 0.3) + -if LIST, --item_filter LIST Pass a list of unwanted items to recycle when collected at a Pokestop (e.g, [\"101\",\"102\",\"103\",\"104\"] to recycle potions when collected)" -d, --debug Debug Mode -t, --test Only parse the specified location diff --git a/config.json.example b/config.json.example index 66aed50122..4886d229b1 100644 --- a/config.json.example +++ b/config.json.example @@ -11,7 +11,8 @@ "debug": false, "test": false, "initial_transfer": false, - "pokemon_potential": 0.70, + "pokemon_potential": 0.1, "location_cache": true, - "distance_unit": "km" + "distance_unit": "km", + "item_filter": ["101","102","103","104"] } diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index 7eb8ea154c..6f1f113e92 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -92,7 +92,6 @@ def work(self): logger.log("[+] Recycling " + str(item_count) + "x " + item_name + "...", 'green') #RECYCLE_INVENTORY_ITEM response_dict_recycle = self.bot.drop_item(item_id=item_id, count=item_count) - print(response_dict_recycle) if response_dict_recycle and \ 'responses' in response_dict_recycle and \ From 79c65876e76d8665bdfc54b7f799e761754964ac Mon Sep 17 00:00:00 2001 From: Daniel Mateus Pires Date: Sat, 23 Jul 2016 22:00:38 +0100 Subject: [PATCH 5/5] merging --- pokemongo_bot/stepper.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pokemongo_bot/stepper.py b/pokemongo_bot/stepper.py index ad7fd77bd3..d6004d9fe3 100644 --- a/pokemongo_bot/stepper.py +++ b/pokemongo_bot/stepper.py @@ -35,8 +35,6 @@ def take_step(self): position = (self.origin_lat, self.origin_lon, 0.0) self.api.set_position(*position) - print(self.api.list_curr_methods()) - self.api.list_curr_methods() for step in range(self.steplimit2): # starting at 0 index logger.log('[#] Scanning area for objects ({} / {})'.format(