Skip to content

Commit

Permalink
Useful features.
Browse files Browse the repository at this point in the history
# Get pokeballs > store them.

#Get pokemons > store them >
## group them by ID >
## sort CP in each group for each pokemon >
## transfer all low CP pokemon duplicates. (commented for now, uncomment if want to test.)
  • Loading branch information
necrozis authored Jul 22, 2016
1 parent 949bda2 commit 4645d5f
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,72 @@ def _setup_api(self):

# chain subrequests (methods) into one RPC call

# get player inventory call
# ----------------------
self.api.get_player().get_inventory()

inventory_req = self.api.call()

inventory_dict = inventory_req['responses']['GET_INVENTORY']['inventory_delta']['inventory_items']

# get player balls stock
# ----------------------
balls_stock = {1:0,2:0,3:0,4:0}

for item in inventory_dict:
try:
if item['inventory_item_data']['item']['item'] == 1:
#print('Poke Ball count: ' + str(item['inventory_item_data']['item']['count']))
balls_stock[1] = item['inventory_item_data']['item']['count']
if item['inventory_item_data']['item']['item'] == 2:
#print('Great Ball count: ' + str(item['inventory_item_data']['item']['count']))
balls_stock[2] = item['inventory_item_data']['item']['count']
if item['inventory_item_data']['item']['item'] == 3:
#print('Ultra Ball count: ' + str(item['inventory_item_data']['item']['count']))
balls_stock[3] = item['inventory_item_data']['item']['count']
except:
continue

# get player pokemon[id] group by pokemon[pokemon_id]
# ----------------------
pokemon_stock = {}

for pokemon in inventory_dict:
try:
id1 = pokemon['inventory_item_data']['pokemon']['pokemon_id']
id2 = pokemon['inventory_item_data']['pokemon']['id']
id3 = pokemon['inventory_item_data']['pokemon']['cp']
#DEBUG - Hide
#print(str(id1))
if id1 not in pokemon_stock:
pokemon_stock[id1] = {}
#DEBUG - Hide
#print(str(id2))
pokemon_stock[id1].update({id3:id2})
except:
continue

#DEBUG - Hide
#print pokemon_stock

for id in pokemon_stock:
#DEBUG - Hide
#print id
sorted_cp = pokemon_stock[id].keys()
if len(sorted_cp) > 1:
sorted_cp.sort()
sorted_cp.reverse()
#DEBUG - Hide
#print sorted_cp

#Hide for now. If Unhide transfer all poke duplicates exept most CP.
#for x in range(1, len(sorted_cp)):
#DEBUG - Hide
#print x
#print pokemon_stock[id][sorted_cp[x]]
#self.api.release_pokemon(pokemon_id=pokemon_stock[id][sorted_cp[x]])
#response_dict = self.api.call()

# get player profile call
# ----------------------
self.api.get_player()
Expand Down

1 comment on commit 4645d5f

@CtrlAltDefeat94
Copy link

Choose a reason for hiding this comment

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

#127

Looks good :3

Please sign in to comment.