示例#1
0
import os
import sys
import json
from DestinyLib import Destiny, Person, Faction



import pprint
import json
from pprint import pprint

import argparse
parser = argparse.ArgumentParser(description='Get the progression information for a character')
parser.add_argument('usernames', metavar='USERNAME', type=str, nargs='+',
                help='usernames to check')
args = parser.parse_args()

API_KEY = os.environ['DESTINY_API_KEY'].strip()
DESTINY_CLAN_ID = os.environ['DESTINY_CLAN_ID'].strip()
d = Destiny()
d.login()

for username in args.usernames:
    p = Person(username = username, destiny_obj = d)

    ## Get next faction to level up
    for c in p.getCharacters():
        for k, v in c.getAdvisors().iteritems():
            print k
def main():
    """
    Main function
    """
    parser = argparse.ArgumentParser(description="Get the progression information for a character")
    parser.add_argument("usernames", metavar="USERNAME", type=str, nargs="+", help="usernames to check")
    args = parser.parse_args()

    # API_KEY = os.environ['DESTINY_API_KEY'].strip()
    DESTINY_CLAN_ID = os.environ["DESTINY_CLAN_ID"].strip()
    DESTINY = Destiny()
    DESTINY.login()

    remaining_warning = {"Glimmer": 3000, "Legendary Marks": 20, "Silver": None}

    material_names = ["Spinmetal", "Spirit Bloom", "Relic Iron", "Helium Filaments"]

    ammo_names = ["Heavy Ammo Synthesis", "Special Ammo Synthesis", "Ammo Synthesis"]

    from collections import Counter

    item_counts = Counter()
    for username in args.usernames:
        person = Person(username=username)
        for c in person.getCharacters():
            for bucket in c.get_inventory_items():
                item_counts += bucket.count_items()

        c = person.getCharacters()[0]
        c.get_character_complete()
        for curren in c.character_complete["inventory"]["currencies"]:
            c_obj = Currency(curren["itemHash"])
            remaining_credits = c_obj["maxStackSize"] - curren["value"]
            warning_level = remaining_warning.get(c_obj["itemName"], None)
            if not warning_level:
                continue

            if remaining_credits <= warning_level:
                print "%s is close to max level (%s away)" % (c_obj["itemName"], remaining_credits)

        for bucket in DESTINY.get_vault():

            if bucket["bucketName"] != "General":
                continue

            item_counts += bucket.count_items()

    ## Show stuff to buy here
    import operator

    sorted_counts = sorted(item_counts.items(), key=operator.itemgetter(1))
    print "Need to blow some glimmer?  Here are your ammo synth levels:"
    for material_name, material_count in sorted_counts:
        if material_name not in ammo_names:
            continue
        print "%-23s %-6s" % (material_name, material_count)
    print
    print "Need to blow some marks?  Here are the material totals across your account:"
    for material_name, material_count in sorted_counts:
        if material_name not in material_names:
            continue
        print "%-17s %-6s" % (material_name, material_count)
    return 0


import pprint
import json
from pprint import pprint

import argparse
parser = argparse.ArgumentParser(description='Get the progression information for a character')
parser.add_argument('usernames', metavar='USERNAME', type=str, nargs='+',
                help='usernames to check')
args = parser.parse_args()

API_KEY = os.environ['DESTINY_API_KEY'].strip()
DESTINY_CLAN_ID = os.environ['DESTINY_CLAN_ID'].strip()
d = Destiny()
d.login()

total_glimmer = 0
for username in args.usernames:
    p = Person(username = username)

    vault = d.get_vault()
    for bucket in vault:

        #inventoryBucketDescription = d.query('/Destiny/Manifest/5/%s' % bucket['bucketHash'])
        for i in bucket.inventory_items:
            #i = InventoryItem(destiny_obj=d, info=item)
            i.calculate_liquidity()
            if i.liquidity['glimmer'] == 0:
                continue