Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "origin"]
path = web
url = https://github.com/OpenPoGo/OpenPoGoWeb.git
1 change: 1 addition & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,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.item_inventory_count(701)))

self.get_player_info()

Expand Down
58 changes: 40 additions & 18 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,8 +84,28 @@ 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

## Use berry to increase success chance.
berry_id = 701 # @ TODO: use better berries if possible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should reference the constant from item_list.py

berries_count = self.bot.item_inventory_count(berry_id)
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(
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 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']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been testing this for a while and at times, item_capture_mult doesn't exist in USE_ITEM_CAPTURE, so it throws an error and crashes the bot.
Should add a if statement to prevent it from happen.

Copy link
Contributor

@Nihisil Nihisil Jul 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this PR long time too and it have been working without issues to me.

item_capture_mult exists in USE_ITEM_CAPTURE.

https://github.com/PokemonGoF/PokemonGo-Bot/blob/dev/proto/RpcSub.proto#L436

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should exist in USE_ITEM_CAPTURE, yes, but as I said, it sometimes at rare occasions doesn't, which is why an IF statement would at least prevent a crash.


success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100)
logger.log('[#] Catch Rate with normal Pokeball has increased to {}%'.format(success_percentage))
else:
pokeball = 0 # player doesn't have any of pokeballs, great balls or ultra balls
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:
Expand All @@ -92,8 +115,8 @@ def work(self):
break

# @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.
Expand Down Expand Up @@ -126,23 +149,24 @@ 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:
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()


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])
Expand All @@ -166,9 +190,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), 'green')

break
time.sleep(5)

Expand Down
3 changes: 2 additions & 1 deletion pokemongo_bot/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion web
Submodule web deleted from dc742c