本文整理汇总了Python中api_wrapper.ApiWrapper.get_inventory方法的典型用法代码示例。如果您正苦于以下问题:Python ApiWrapper.get_inventory方法的具体用法?Python ApiWrapper.get_inventory怎么用?Python ApiWrapper.get_inventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_wrapper.ApiWrapper
的用法示例。
在下文中一共展示了ApiWrapper.get_inventory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PokemonGoBot
# 需要导入模块: from api_wrapper import ApiWrapper [as 别名]
# 或者: from api_wrapper.ApiWrapper import get_inventory [as 别名]
#.........这里部分代码省略.........
self.event_manager.register_event(
'move_to_map_pokemon_teleport_to',
parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',
'disappears_in')
)
self.event_manager.register_event(
'move_to_map_pokemon_encounter',
parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',
'disappears_in')
)
self.event_manager.register_event(
'move_to_map_pokemon_move_towards',
parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',
'disappears_in')
)
self.event_manager.register_event(
'move_to_map_pokemon_teleport_back',
parameters=('last_lat', 'last_lon')
)
def tick(self):
self.health_record.heartbeat()
self.cell = self.get_meta_cell()
self.tick_count += 1
# Check if session token has expired
self.check_session(self.position[0:2])
for worker in self.workers:
if worker.work() == WorkerResult.RUNNING:
return
def open_bag(self):
response = self.get_inventory()
self.inventory = list()
own_pokemon_list = {
int(x['Number']): {'name': x['Name'], 'candies_needed': x.get('Next Evolution Requirements', {'Amount': 18446744073709551615 }).get('Amount'), 'count': 0}
for x in self.pokemon_list
}
inventory_items = response.get('responses', {}).get('GET_INVENTORY', {}).get(
'inventory_delta', {}).get('inventory_items', {})
if inventory_items:
for item in inventory_items:
item_info = item.get('inventory_item_data', {})
if {"pokemon_family"}.issubset(set(item_info.keys())):
pokemon_family = item['inventory_item_data']['pokemon_family']
pokemon_data = own_pokemon_list[pokemon_family['family_id']]
pokemon_data['candies_number'] = pokemon_family['candy']
if {"pokemon_data"}.issubset(set(item_info.keys())):
pokemon_id = item['inventory_item_data']['pokemon_data'].get('pokemon_id')
if pokemon_id:
pokemon = own_pokemon_list[pokemon_id]
pokemon['count'] += 1
with open('pokemons_process.csv', 'wb') as csvfile:
spamwriter = csv.writer(
csvfile,
delimiter=str(u';'),
quotechar=str(u'"'),
quoting=csv.QUOTE_MINIMAL
)
spamwriter.writerow([
'pokemon', 'evolution_cost', 'total_candies', 'total_evolutions',
示例2: PokemonGoBot
# 需要导入模块: from api_wrapper import ApiWrapper [as 别名]
# 或者: from api_wrapper.ApiWrapper import get_inventory [as 别名]
#.........这里部分代码省略.........
'not geocoding.'
)
return float(possible_coordinates[0]), float(possible_coordinates[1]), (float(possible_coordinates[2]) if len(possible_coordinates) == 3 else self.alt)
geolocator = GoogleV3(api_key=self.config.gmapkey)
loc = geolocator.geocode(location_name, timeout=10)
return float(loc.latitude), float(loc.longitude), float(loc.altitude)
def heartbeat(self):
# Remove forts that we can now spin again.
now = time.time()
self.fort_timeouts = {id: timeout for id, timeout
in self.fort_timeouts.iteritems()
if timeout >= now * 1000}
if now - self.last_heartbeat >= self.heartbeat_threshold:
self.last_heartbeat = now
request = self.api.create_request()
request.get_player()
request.check_awarded_badges()
request.call()
try:
self.web_update_queue.put_nowait(True) # do this outside of thread every tick
except Queue.Full:
pass
def update_web_location_worker(self):
while True:
self.web_update_queue.get()
self.update_web_location()
def display_player_info(self):
inventory_items = self.api.get_inventory()
inventory_items = inventory_items['responses']['GET_INVENTORY']['inventory_delta']['inventory_items']
player_stats = next((x["inventory_item_data"]["player_stats"]
for x in inventory_items
if x.get("inventory_item_data", {}).get("player_stats", {})),
None)
if player_stats:
nextlvlxp = (int(player_stats.get('next_level_xp', 0)) - int(player_stats.get('experience', 0)))
if 'level' in player_stats and 'experience' in player_stats:
self.logger.info(
'Level: {level}'.format(
**player_stats) +
' (Next Level: {} XP)'.format(
nextlvlxp) +
' (Total: {experience} XP)'
''.format(**player_stats))
if 'pokemons_captured' in player_stats and 'poke_stop_visits' in player_stats:
self.logger.info(
'Pokemon Captured: '
'{pokemons_captured}'.format(
**player_stats) +
' | Pokestops Visited: '
'{poke_stop_visits}'.format(
**player_stats))
def get_forts(self, order_by_distance=False):
forts = [fort
for fort in self.cell['forts']
if 'latitude' in fort and 'type' in fort]
示例3: PokemonGoBot
# 需要导入模块: from api_wrapper import ApiWrapper [as 别名]
# 或者: from api_wrapper.ApiWrapper import get_inventory [as 别名]
#.........这里部分代码省略.........
# print('Response dictionary: \n\r{}'.format(json.dumps(response_dict, indent=2)))
currency_1 = "0"
currency_2 = "0"
if response_dict:
self._player = response_dict['responses']['GET_PLAYER']['player_data']
player = self._player
else:
logger.log(
"The API didn't return player info, servers are unstable - "
"retrying.", 'red'
)
sleep(5)
self._print_character_info()
# @@@ TODO: Convert this to d/m/Y H:M:S
creation_date = datetime.datetime.fromtimestamp(
player['creation_timestamp_ms'] / 1e3)
creation_date = creation_date.strftime("%Y/%m/%d %H:%M:%S")
pokecoins = '0'
stardust = '0'
items_stock = self.current_inventory()
if 'amount' in player['currencies'][0]:
pokecoins = player['currencies'][0]['amount']
if 'amount' in player['currencies'][1]:
stardust = player['currencies'][1]['amount']
logger.log('')
logger.log('--- {username} ---'.format(**player), 'cyan')
self.get_player_info()
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'
)
# 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]) +
示例4: PokemonGoBot
# 需要导入模块: from api_wrapper import ApiWrapper [as 别名]
# 或者: from api_wrapper.ApiWrapper import get_inventory [as 别名]
#.........这里部分代码省略.........
self._set_starting_position()
self.login()
# chain subrequests (methods) into one RPC call
# get player profile call
# ----------------------
self.api.get_player()
response_dict = self.api.call()
# print('Response dictionary: \n\r{}'.format(json.dumps(response_dict, indent=2)))
currency_1 = "0"
currency_2 = "0"
player = response_dict['responses']['GET_PLAYER']['player_data']
# @@@ TODO: Convert this to d/m/Y H:M:S
creation_date = datetime.datetime.fromtimestamp(
player['creation_timestamp_ms'] / 1e3)
pokecoins = '0'
stardust = '0'
balls_stock = self.pokeball_inventory()
if 'amount' in player['currencies'][0]:
pokecoins = player['currencies'][0]['amount']
if 'amount' in player['currencies'][1]:
stardust = player['currencies'][1]['amount']
logger.log('[#] Username: {username}'.format(**player))
logger.log('[#] Acccount Creation: {}'.format(creation_date))
logger.log('[#] Bag Storage: {}/{}'.format(
self.get_inventory_count('item'), player['max_item_storage']))
logger.log('[#] Pokemon Storage: {}/{}'.format(
self.get_inventory_count('pokemon'), player[
'max_pokemon_storage']))
logger.log('[#] Stardust: {}'.format(stardust))
logger.log('[#] Pokecoins: {}'.format(pokecoins))
logger.log('[#] PokeBalls: ' + str(balls_stock[1]))
logger.log('[#] GreatBalls: ' + str(balls_stock[2]))
logger.log('[#] UltraBalls: ' + str(balls_stock[3]))
self.get_player_info()
if self.config.email_status:
emailer.periodic_email_status(self)
if self.config.initial_transfer:
worker = InitialTransferWorker(self)
worker.work()
logger.log('[#]')
self.update_inventory()
def catch_pokemon(self, pokemon):
worker = PokemonCatchWorker(pokemon, self)
return_value = worker.work()
if return_value == PokemonCatchWorker.BAG_FULL:
logger.log("Bag is full, call EvolveAllWorker first, then raise transfer upperbound and call InitialTransferWorker...", "red")
evolve_worker = EvolveAllWorker(self)
evolve_worker.work()
self.config.initial_transfer = self.config.bag_full_transfer
worker = InitialTransferWorker(self)
worker.work()