From 428f5d4ae0e9e8b15ea219a86e6b9df941ebc417 Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 18:20:14 +0700 Subject: [PATCH 01/13] now bot can use berries --- .../cell_workers/pokemon_catch_worker.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index aef2c1538b..3587fa1f1f 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -110,7 +110,26 @@ def work(self): # Begin searching for pokestops. self.config.mode = 'farm' return PokemonCatchWorker.NO_POKEBALLS - + + ## Use berry to increase success chance. + berry_id = 701 # @ TODO: use better berries if possible + berries_count = self.bot.item_inventory_count(berry_id) + if(catch_rate[pokeball-1] < 0.5 and berries_count > 0): # and potion is in stock + success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) + logger.log('[x] Catch Rate is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(pokeball)],berries_count-1)) + self.api.use_item_capture( + item_id=berry_id, + encounter_id = encounter_id, + spawn_point_guid = spawnpoint_id + ) + response_dict = self.api.call() + if response_dict and response_dict['status_code'] is 1: + catch_rate[pokeball-1] = catch_rate[pokeball-1] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] + success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) + logger.log('[#] Catch Rate has increased to {}%'.format(success_percentage)) + else: + logger.log('[x] Fail to use berry. Status Code: {}'.format(response_dict['status_code']),'red') + balls_stock[pokeball] = balls_stock[pokeball] - 1 success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) logger.log('[x] Using {} (chance: {}%)... ({} left!)'.format( From 3a93c0be49cd3f2a4c37097daa352da7463e8f7c Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 18:40:00 +0700 Subject: [PATCH 02/13] improve berry logic. apply berry before chosing the type of ball --- .../cell_workers/pokemon_catch_worker.py | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 4d1dcc42f6..46242b8a54 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -84,22 +84,6 @@ def work(self): else: pokeball = 0 # player doesn't have any of pokeballs, great balls or ultra balls - while(pokeball < 3): - if catch_rate[pokeball-1] < 0.35 and balls_stock[pokeball+1] > 0: - # if current ball chance to catch is under 35%, and player has better ball - then use it - pokeball = pokeball+1 # use better ball - else: - break - - # @TODO, use the best ball in stock to catch VIP (Very Important Pokemon: Configurable) - - if pokeball is 0: - logger.log( - '[x] Out of pokeballs, switching to farming mode...', 'red') - # Begin searching for pokestops. - self.config.mode = 'farm' - return PokemonCatchWorker.NO_POKEBALLS - ## Use berry to increase success chance. berry_id = 701 # @ TODO: use better berries if possible berries_count = self.bot.item_inventory_count(berry_id) @@ -113,11 +97,30 @@ def work(self): ) response_dict = self.api.call() if response_dict and response_dict['status_code'] is 1: - catch_rate[pokeball-1] = catch_rate[pokeball-1] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] + + for i in catch_rate: + catch_rate[i] = catch_rate[i] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] + success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) logger.log('[#] Catch Rate has increased to {}%'.format(success_percentage)) else: logger.log('[x] Fail to use berry. Status Code: {}'.format(response_dict['status_code']),'red') + + while(pokeball < 3): + if catch_rate[pokeball-1] < 0.35 and balls_stock[pokeball+1] > 0: + # if current ball chance to catch is under 35%, and player has better ball - then use it + pokeball = pokeball+1 # use better ball + else: + break + + # @TODO, use the best ball in stock to catch VIP (Very Important Pokemon: Configurable) + + if pokeball is 0: + logger.log( + '[x] Out of pokeballs, switching to farming mode...', 'red') + # Begin searching for pokestops. + self.config.mode = 'farm' + return PokemonCatchWorker.NO_POKEBALLS balls_stock[pokeball] = balls_stock[pokeball] - 1 success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) From 0436a04460af5dfb792f62005081acdec647b897 Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 18:46:50 +0700 Subject: [PATCH 03/13] fix bug --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 46242b8a54..d453896075 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -97,8 +97,8 @@ def work(self): ) response_dict = self.api.call() if response_dict and response_dict['status_code'] is 1: - - for i in catch_rate: + + for i in range(len(catch_rate)): catch_rate[i] = catch_rate[i] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) From 188578f5f8f216dbf0e589b26d742edd54b72e4a Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 18:49:55 +0700 Subject: [PATCH 04/13] fix wrong item id --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index d453896075..0759e92756 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -89,7 +89,7 @@ def work(self): berries_count = self.bot.item_inventory_count(berry_id) if(catch_rate[pokeball-1] < 0.5 and berries_count > 0): # and potion is in stock success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) - logger.log('[x] Catch Rate is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(pokeball)],berries_count-1)) + logger.log('[x] Catch Rate is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(berry_id)],berries_count-1)) self.api.use_item_capture( item_id=berry_id, encounter_id = encounter_id, @@ -97,8 +97,8 @@ def work(self): ) response_dict = self.api.call() if response_dict and response_dict['status_code'] is 1: - - for i in range(len(catch_rate)): + + for i in catch_rate: catch_rate[i] = catch_rate[i] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) From 0775b3cfa124e2d557abfc8c7549d37a88b67174 Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 18:53:44 +0700 Subject: [PATCH 05/13] fix error --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 0759e92756..a18a15381f 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -98,7 +98,7 @@ def work(self): response_dict = self.api.call() if response_dict and response_dict['status_code'] is 1: - for i in catch_rate: + for i in range(len(catch_rate)): catch_rate[i] = catch_rate[i] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) From f1a464b2a6da50d3e8f768a8d136cd7b807ac3a1 Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 18:55:32 +0700 Subject: [PATCH 06/13] improve log message --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index a18a15381f..43ae750eec 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -89,7 +89,7 @@ def work(self): berries_count = self.bot.item_inventory_count(berry_id) if(catch_rate[pokeball-1] < 0.5 and berries_count > 0): # and potion is in stock success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) - logger.log('[x] Catch Rate is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(berry_id)],berries_count-1)) + logger.log('[x] Catch Rate with normal Pokeball is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(berry_id)],berries_count-1)) self.api.use_item_capture( item_id=berry_id, encounter_id = encounter_id, @@ -102,7 +102,7 @@ def work(self): catch_rate[i] = catch_rate[i] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult'] success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) - logger.log('[#] Catch Rate has increased to {}%'.format(success_percentage)) + logger.log('[#] Catch Rate with normal Pokeball has increased to {}%'.format(success_percentage)) else: logger.log('[x] Fail to use berry. Status Code: {}'.format(response_dict['status_code']),'red') From 9c39fa7696f6b003c6cf689ec1030258e620f66c Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 19:03:12 +0700 Subject: [PATCH 07/13] - add blue color log - remove extras log on capture - display IV on capture --- .../cell_workers/pokemon_catch_worker.py | 18 ++++++++---------- pokemongo_bot/logger.py | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 43ae750eec..8a6e01e75d 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -155,14 +155,7 @@ def work(self): logger.log( '[x] Oh no! {} vanished! :('.format(pokemon_name), 'red') if status is 1: - logger.log( - '[x] Captured {}! [CP {}] [IV {}]'.format( - pokemon_name, - cp, - pokemon_potential - ), 'green' - ) - + id_list2 = self.count_pokemon_inventory() if self.config.evolve_captured: @@ -189,8 +182,13 @@ def work(self): logger.log( '[#] {} has been exchanged for candy!'.format(pokemon_name), 'green') else: - logger.log( - '[x] Captured {}! [CP {}]'.format(pokemon_name, cp), 'green') + logger.log('[x] Captured {}! [CP {}] [{}/{}/{}]'.format( + pokemon_name, + cp, + pokemon['pokemon_data']['individual_stamina'], + pokemon['pokemon_data']['individual_attack'], + pokemon['pokemon_data']['individual_defense'] + ), 'blue') break time.sleep(5) diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 151e578a0f..f80d6b4ccb 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -9,9 +9,10 @@ def log(string, color = 'white'): colorHex = { + 'red': '91m', 'green': '92m', 'yellow': '93m', - 'red': '91m' + 'blue': '94m' } if color not in colorHex: print('[' + time.strftime("%Y-%m-%d %H:%M:%S") + '] '+ string) From 83fdda7d9213141d36dbc08a1d86ef151d35af4f Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 19:11:11 +0700 Subject: [PATCH 08/13] fix bug #660 --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 8a6e01e75d..c983263619 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -81,8 +81,6 @@ def work(self): pokeball = 2 # then use great balls elif balls_stock[3] > 0: # or if great balls are out of stock too, and player has ultra balls... pokeball = 3 # then use ultra balls - else: - pokeball = 0 # player doesn't have any of pokeballs, great balls or ultra balls ## Use berry to increase success chance. berry_id = 701 # @ TODO: use better berries if possible @@ -115,7 +113,7 @@ def work(self): # @TODO, use the best ball in stock to catch VIP (Very Important Pokemon: Configurable) - if pokeball is 0: + if balls_stock[pokeball] is 0: logger.log( '[x] Out of pokeballs, switching to farming mode...', 'red') # Begin searching for pokestops. @@ -148,7 +146,7 @@ def work(self): 'CATCH_POKEMON']['status'] if status is 2: logger.log( - '[-] Attempted to capture {}- failed.. trying again!'.format(pokemon_name), 'red') + '[-] Attempted to capture {} - failed.. trying again!'.format(pokemon_name), 'red') sleep(2) continue if status is 3: From 265a2d35cf2815a516ac3e2ed0a410bcdf2e7ba8 Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 19:16:27 +0700 Subject: [PATCH 09/13] improve code as comments --- .../cell_workers/pokemon_catch_worker.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index c983263619..fe96c602fc 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -119,7 +119,7 @@ def work(self): # Begin searching for pokestops. self.config.mode = 'farm' return PokemonCatchWorker.NO_POKEBALLS - + balls_stock[pokeball] = balls_stock[pokeball] - 1 success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) logger.log('[x] Using {} (chance: {}%)... ({} left!)'.format( @@ -155,7 +155,15 @@ def work(self): if status is 1: id_list2 = self.count_pokemon_inventory() - + + logger.log('[x] Captured {}! [CP {}] [{}/{}/{}]'.format( + pokemon_name, + cp, + pokemon['pokemon_data']['individual_stamina'], + pokemon['pokemon_data']['individual_attack'], + pokemon['pokemon_data']['individual_defense'] + ), 'blue') + if self.config.evolve_captured: pokemon_to_transfer = list(Set(id_list2) - Set(id_list1)) self.api.evolve_pokemon(pokemon_id=pokemon_to_transfer[0]) @@ -179,14 +187,7 @@ def work(self): pokemon_to_transfer[0]) logger.log( '[#] {} has been exchanged for candy!'.format(pokemon_name), 'green') - else: - logger.log('[x] Captured {}! [CP {}] [{}/{}/{}]'.format( - pokemon_name, - cp, - pokemon['pokemon_data']['individual_stamina'], - pokemon['pokemon_data']['individual_attack'], - pokemon['pokemon_data']['individual_defense'] - ), 'blue') + break time.sleep(5) From 30c32d4f2b68de666309f44d789b2dc89a968f8b Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 20:17:57 +0700 Subject: [PATCH 10/13] fix https://github.com/PokemonGoF/PokemonGo-Bot/issues/666 --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index fe96c602fc..a859eb422b 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -33,8 +33,11 @@ def work(self): if 'ENCOUNTER' in response_dict['responses']: if 'status' in response_dict['responses']['ENCOUNTER']: if response_dict['responses']['ENCOUNTER']['status'] is 7: - logger.log('[x] Pokemon Bag is full!', 'red') - return PokemonCatchWorker.BAG_FULL + if self.config.initial_transfer: + logger.log('[x] Pokemon Bag is full!', 'red') + return PokemonCatchWorker.BAG_FULL + else: + raise RuntimeError('Pokemon Bag is full!') if response_dict['responses']['ENCOUNTER']['status'] is 1: cp = 0 From 3dbc9150c867c3be39373cfd85426a6b7eecf8f0 Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 20:24:51 +0700 Subject: [PATCH 11/13] show amount of Razz berries on start --- pokemongo_bot/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index fe2e8c441a..324d191c13 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -174,6 +174,7 @@ def _setup_api(self): logger.log('[#] PokeBalls: ' + str(balls_stock[1])) logger.log('[#] GreatBalls: ' + str(balls_stock[2])) logger.log('[#] UltraBalls: ' + str(balls_stock[3])) + logger.log('[#] Razz Berries: ' + str(self.bot.item_inventory_count(701))) self.get_player_info() From 1857a2bd8a5025fca250ee07705a153772cb018f Mon Sep 17 00:00:00 2001 From: earthchie Date: Sun, 24 Jul 2016 20:25:32 +0700 Subject: [PATCH 12/13] fix error --- pokemongo_bot/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 324d191c13..7dad030b48 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -174,7 +174,7 @@ def _setup_api(self): logger.log('[#] PokeBalls: ' + str(balls_stock[1])) logger.log('[#] GreatBalls: ' + str(balls_stock[2])) logger.log('[#] UltraBalls: ' + str(balls_stock[3])) - logger.log('[#] Razz Berries: ' + str(self.bot.item_inventory_count(701))) + logger.log('[#] Razz Berries: ' + str(self.item_inventory_count(701))) self.get_player_info() From febbd1f58983936ae6e571a5ef4f5ee9897dea78 Mon Sep 17 00:00:00 2001 From: earthchie Date: Mon, 25 Jul 2016 12:40:32 +0700 Subject: [PATCH 13/13] - improve code as comments in PR - fix typo --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index da0628ba2a..55f5742c50 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -88,7 +88,7 @@ def work(self): ## Use berry to increase success chance. berry_id = 701 # @ TODO: use better berries if possible berries_count = self.bot.item_inventory_count(berry_id) - if(catch_rate[pokeball-1] < 0.5 and berries_count > 0): # and potion is in stock + if(catch_rate[pokeball-1] < 0.5 and berries_count > 0): # and berry is in stock success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) logger.log('[x] Catch Rate with normal Pokeball is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(berry_id)],berries_count-1)) self.api.use_item_capture( @@ -97,7 +97,7 @@ def work(self): spawn_point_guid = spawnpoint_id ) response_dict = self.api.call() - if response_dict and response_dict['status_code'] is 1: + if response_dict and response_dict['status_code'] is 1 and 'item_capture_mult' in response_dict['responses']['USE_ITEM_CAPTURE']: for i in range(len(catch_rate)): catch_rate[i] = catch_rate[i] * response_dict['responses']['USE_ITEM_CAPTURE']['item_capture_mult']