From d3be07975391f52254b76ecbfe79abf514b9fac8 Mon Sep 17 00:00:00 2001 From: Surceis Date: Wed, 27 Jul 2016 12:46:43 +0300 Subject: [PATCH 1/3] Update __init__.py --- pokemongo_bot/__init__.py | 45 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index bc9c4ab270..3605ab82da 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -281,7 +281,7 @@ def _print_character_info(self): pokecoins = '0' stardust = '0' - balls_stock = self.pokeball_inventory() + items_stock = self.current_inventory() if 'amount' in player['currencies'][0]: pokecoins = player['currencies'][0]['amount'] @@ -293,14 +293,28 @@ def _print_character_info(self): logger.log('Pokemon Bag: {}/{}'.format(self.get_inventory_count('pokemon'), player['max_pokemon_storage']), 'cyan') logger.log('Items: {}/{}'.format(self.get_inventory_count('item'), player['max_item_storage']), 'cyan') logger.log('Stardust: {}'.format(stardust) + ' | Pokecoins: {}'.format(pokecoins), 'cyan') - # Pokeball Output - logger.log('PokeBalls: ' + str(balls_stock[1]) + - ' | GreatBalls: ' + str(balls_stock[2]) + - ' | UltraBalls: ' + str(balls_stock[3]), 'cyan') - logger.log('Razz Berries: ' + str(self.item_inventory_count(701)), 'cyan') + # Items Output + logger.log('PokeBalls: ' + str(items_stock[1]) + + ' | GreatBalls: ' + str(items_stock[2]) + + ' | UltraBalls: ' + str(items_stock[3]), 'cyan') + logger.log('RazzBerries: ' + str(items_stock[701]) + + ' | BlukBerries: ' + str(items_stock[702]) + + ' | NanabBerries: ' + str(items_stock[703]), 'cyan') + logger.log('LuckyEgg: ' + str(items_stock[301]) + + ' | Incubator: ' + str(items_stock[902]) + + ' | TroyDisk: ' + str(items_stock[501]), 'cyan') + logger.log('Potion: ' + str(items_stock[101]) + + ' | SuperPotion: ' + str(items_stock[102]) + + ' | HyperPotion: ' + str(items_stock[103]), 'cyan') + logger.log('Incense: ' + str(items_stock[401]) + + ' | IncenseSpicy: ' + str(items_stock[402]) + + ' | IncenseCool: ' + str(items_stock[403]), 'cyan') + logger.log('Revive: ' + str(items_stock[201]) + + ' | MaxRevive: ' + str(items_stock[202]), 'cyan') logger.log('') + def use_lucky_egg(self): self.api.use_item_xp_boost(item_id=301) inventory_req = self.api.call() @@ -330,7 +344,7 @@ def update_inventory(self): self.inventory.append(item['inventory_item_data'][ 'item']) - def pokeball_inventory(self): + def current_inventory(self): self.api.get_player().get_inventory() inventory_req = self.api.call() @@ -341,9 +355,9 @@ def pokeball_inventory(self): with open(user_web_inventory, 'w') as outfile: json.dump(inventory_dict, outfile) - # get player balls stock + # get player items stock # ---------------------- - balls_stock = {1: 0, 2: 0, 3: 0, 4: 0} + items_stock = {x.value:0 for x in list(Item)} for item in inventory_dict: try: @@ -351,18 +365,11 @@ def pokeball_inventory(self): item_id = item['inventory_item_data']['item']['item_id'] item_count = item['inventory_item_data']['item']['count'] - if item_id == Item.ITEM_POKE_BALL.value: - # print('Poke Ball count: ' + str(item_count)) - balls_stock[1] = item_count - if item_id == Item.ITEM_GREAT_BALL.value: - # print('Great Ball count: ' + str(item_count)) - balls_stock[2] = item_count - if item_id == Item.ITEM_ULTRA_BALL.value: - # print('Ultra Ball count: ' + str(item_count)) - balls_stock[3] = item_count + if item_id in items_stock: + items_stock[item_id] = item_count except: continue - return balls_stock + return items_stock def item_inventory_count(self, id): self.api.get_player().get_inventory() From 3ae971c61eb3f556ff9673164e1cebdbc9b72bc6 Mon Sep 17 00:00:00 2001 From: Surceis Date: Wed, 27 Jul 2016 12:49:12 +0300 Subject: [PATCH 2/3] Update pokemon_catch_worker.py --- .../cell_workers/pokemon_catch_worker.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 1fbcd8dba9..c1c8c17a24 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -94,20 +94,20 @@ def work(self): #logger.log('[x] Rule prevents capture.') return False - balls_stock = self.bot.pokeball_inventory() + items_stock = self.bot.current_inventory() while(True): ## pick the most simple ball from stock pokeball = 1 # start from 1 - PokeBalls current_type = pokeball - while(balls_stock[current_type] is 0 and current_type < 3): # if this type's stock = 0 and not top tier yet + while(items_stock[current_type] is 0 and current_type < 3): # if this type's stock = 0 and not top tier yet current_type = current_type + 1 # progress to next tier - if balls_stock[current_type] > 0: # next tier's stock > 0 + if items_stock[current_type] > 0: # next tier's stock > 0 pokeball = current_type ## re-check stock again - if balls_stock[pokeball] is 0: + if items_stock[pokeball] is 0: logger.log('Out of pokeballs, switching to farming mode...', 'red') # Begin searching for pokestops. self.config.mode = 'farm' @@ -120,7 +120,7 @@ def work(self): success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) logger.log('Catch Rate with normal Pokeball is low ({}%). Throwing {}... ({} left!)'.format(success_percentage,self.item_list[str(berry_id)],berries_count-1)) - if balls_stock[pokeball] is 0: + if items_stock[pokeball] is 0: break self.api.use_item_capture( @@ -146,18 +146,18 @@ def work(self): current_type = pokeball while(current_type < 3): current_type = current_type+1 - if catch_rate[pokeball-1] < 0.35 and balls_stock[current_type] > 0: + if catch_rate[pokeball-1] < 0.35 and items_stock[current_type] > 0: # if current ball chance to catch is under 35%, and player has better ball - then use it pokeball = current_type # use better ball # @TODO, use the best ball in stock to catch VIP (Very Important Pokemon: Configurable) - balls_stock[pokeball] = balls_stock[pokeball] - 1 + items_stock[pokeball] = items_stock[pokeball] - 1 success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100) logger.log('Using {} (chance: {}%)... ({} left!)'.format( self.item_list[str(pokeball)], success_percentage, - balls_stock[pokeball] + items_stock[pokeball] )) id_list1 = self.count_pokemon_inventory() From 9053ae94c4755fe972ea5addcfbd84ea154c15cd Mon Sep 17 00:00:00 2001 From: Surceis Date: Wed, 27 Jul 2016 12:49:44 +0300 Subject: [PATCH 3/3] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6447770df8..1d1609d722 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -37,4 +37,5 @@ * VictorChen * AlvaroGzP * fierysolid - * surfaace \ No newline at end of file + * surfaace + * surceis