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.login()

    for username in args.usernames:
        person = Person(username=username)

        ## Get next faction to level up
        for character in person.getCharacters():
            for advisor_info in character.getAdvisors()\
                    ['activityAdvisors'].values():
                activity_advisor = ActivityAdvisor(advisor_info)
                pprint(activity_advisor)
                #pprint(activity_advisor.manifest)
                print

            print
    return 0
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()

action_factions = [
    "faction_pvp_dead_orbit",
    "faction_pvp_future_war_cult",
    "faction_pvp_new_monarchy",
    #'faction_fotc_vanguard'
]

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

    ## Get next faction to level up
    faction_info = {}
    vanguard_info = {}
    gunsmith_info = {}
    crucible_info = {}
    for c in p.getCharacters():
        progressions = c.getProgression()
        keys = progressions.keys()
        keys.sort()

        for k in keys:
            ## Skip unknown junk
            if k in action_factions:
                faction = Faction(k)
Beispiel #3
0
def main():
    """
    Main function
    """
    utc = UTC()
    now = datetime.now(utc)
    parser = argparse.ArgumentParser(description='Get the progression information for a character')
    parser.add_argument('usernames', metavar='USERNAME', type=str, nargs='+',
                        help='usernames to check')
    parser.add_argument('--include-raids', '-r', help="Include Raids in listing",
                        action='store_true')
    parser.add_argument('--include-patrols', '-p', help="Include Patrols in listing",
                        action='store_true')
    parser.add_argument('--pvp', help="Only show PvP missions", action='store_true')
    parser.add_argument('--pve', help="Only show PvE missions", action='store_true')
    parser.add_argument('--class-filter', '-c', help="Only show this character class",
                        metavar="CLASS", choices=['Hunter', 'Warlock', 'Titan'])
    args = parser.parse_args()

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

    if not args.pvp and not args.pve:
        pv_display = 'all'
    elif args.pvp and args.pve:
        pv_display = 'all'
    elif args.pvp:
        pv_display = 'pvp'
    elif args.pve:
        pv_display = 'pve'
    else:
        sys.stderr.write("WTF, how did we get here?")
        sys.exit(2)

    if args.class_filter:
        class_filter = args.class_filter
    else:
        class_filter = None


    for username in args.usernames:
        person = Person(username=username)

        ## Get next faction to level up
        for character in person.getCharacters():
            if class_filter and (class_filter != character.classname):
                continue
            print character
            tasks = []


            ## TODO:  Handle: 'armsDay', 'events'
            for quest_info in character.getAdvisors()['quests']['quests']:
                quest = QuestItem(quest_info)
                task = Task(quest)
                tasks.append(task)

            for bucket in character.get_inventory_items():
                if bucket.manifest['bucketName'] != 'Bounties':
                    continue
                for bounty in bucket.inventory_items:
                    #print bounty.manifest['itemTypeName'], bounty.manifest['values']
                    task = Task(bounty, needs_pickup=None)
                    tasks.append(task)

            for vendor_info in character.getAdvisors()['vendorAdvisors'].values():
                ## Just skip if it's not bounties
                if 'pendingBounties' not in vendor_info:
                    continue
                for bounty_info in vendor_info['pendingBounties']['saleItems']:
                    inventory_item = InventoryItem(bounty_info['item'])
                    task = Task(inventory_item, needs_pickup=True)
                    tasks.append(task)

            for advisor_info in character.getAdvisors()['weeklyCrucible']:
                tasks.append(Task(ActivityAdvisor(advisor_info)))


            for advisor_info in character.getAdvisors()\
                    ['activityAdvisors'].values():
                activity_advisor = ActivityAdvisor(advisor_info)

                #pprint(activity_advisor.manifest)
                #pprint(activity_advisor['activity'].manifest['rewards'])

                ## Skip if we aren't looking at raids
                if activity_advisor['activity'].\
                        activity_type.manifest['activityTypeName'] == 'Raid':
                    if not args.include_raids:
                        continue

                ## Skip if we aren't looking at patrols
                if activity_advisor['activity'].\
                        activity_type.manifest['activityTypeName'] == 'Patrol':
                    if not args.include_patrols:
                        continue

                tasks.append(Task(activity_advisor))


            for task in tasks:
                if task.is_completed:
                    continue
                if not pv_display == 'all':
                    if pv_display == 'pvp' and task.pv_type.lower() != 'pvp':
                        continue
                    elif pv_display == 'pve' and task.pv_type.lower() != 'pve':
                        continue

                data = "%-4s %-14s %s: %s" % (
                    task.pv_type, "%s (%s)" % (task.task_type, task.reputation), task.name,
                    task.description.replace('\n', ' ').replace('\r', ''))
                if task.needs_pickup:
                    data = data + " (Needs Pickup)"
                terminal_width = get_terminal_width()
                data = data.encode('ascii', 'ignore')
                if len(data) > terminal_width:
                    print data[:terminal_width - 3], '..'
                else:
                    print data
    return 0
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