Exemplo n.º 1
0
def GetSource(code):
    source = manifest.GetDef('RewardSource', code) or {}
    return {
        'desc': source.get('description', ''),
        'icon': source.get('icon', '/img/misc/missing_icon.png'),
        'name': source.get('sourceName') or 'Source #%i' % code,
    }
Exemplo n.º 2
0
def GetPerk(code):
    perk = manifest.GetDef('SandboxPerk', code)
    return {
        'desc': perk.get('displayDescription', 'Undefined perk').strip(),
        'hidden': not perk['isDisplayable'],
        'icon': perk['displayIcon'],
        'name': perk.get('displayName') or '#%i' % code,
    }
Exemplo n.º 3
0
def GetProgression(progression):
    info = manifest.GetDef('Progression', progression['progressionHash'])
    return info['name'], {
        'current': progression['progressToNextLevel'],
        'daily': progression['dailyProgress'],
        'icon': info.get('icon', '/img/misc/missing_icon.png'),
        'level': progression['level'],
        'levels': 0 if info['repeatLastStep'] else len(info['steps']),
        'next': progression['nextLevelAt'],
        'total': progression['currentProgress'],
        'weekly': progression['weeklyProgress'],
    }
Exemplo n.º 4
0
def GetObjective(code):
    objective = manifest.GetDef('Objective', code)
    ret = {'count': objective['completionValue']}
    if objective.get('displayDescription'):
        ret['name'] = objective['displayDescription'].strip()
    elif objective.get('locationHash'):
        location = manifest.GetDef('Location', objective['locationHash'])
        for location_release in location['locationReleases']:
            if location_release.get('activityHash'):
                ret['name'] = 'Activity: ' + manifest.GetActivityName(
                    location_release['activityHash'])
                break
            elif location_release.get('destinationHash'):
                ret['name'] = 'Destination: ' + GetDestinationName(
                    location_release['destinationHash'])
                break
        else:
            ret['name'] = 'Location #%i' % objective['locationHash']
    else:
        ret['name'] = 'Objective #%i' % code
    return ret
Exemplo n.º 5
0
 def get(self, bucket_name):
     bucket = manifest.GetDef(bucket_name)
     self.response.render(
         'dashboard/db/bucket.html', {
             'breadcrumbs': (
                 ('/db/', 'DB'),
                 ('/db/%s/' % bucket_name, bucket_name),
             ),
             'bucket_name':
             bucket_name,
             'bucket':
             bucket,
         })
Exemplo n.º 6
0
 def get(self, bucket_name, hashcode):
     try:
         hashcode = long(hashcode)
     except ValueError:
         pass
     obj = manifest.GetDef(bucket_name, hashcode)
     self.response.render(
         'dashboard/object.html', {
             'breadcrumbs': (
                 ('/db/', 'DB'),
                 ('/db/%s/' % bucket_name, bucket_name),
                 ('/db/%s/%s' % (bucket_name, hashcode), hashcode),
             ),
             'obj':
             obj,
         })
Exemplo n.º 7
0
 def get(self):
     defs = manifest.GetDef()
     self.response.render('dashboard/db/index.html', {
         'breadcrumbs': (('/db/', 'DB'), ),
         'defs': defs,
     })
Exemplo n.º 8
0
 def get(self):
     for group in manifest.GetDef():
         for code in manifest.GetDef(group):
             manifest.GetDef(group, code)
Exemplo n.º 9
0
def GetReward(code):
    reward = manifest.GetDef('InventoryItem', code) or {}
    return {
        'icon': reward.get('icon', '/img/misc/missing_icon.png'),
        'name': reward.get('itemName') or 'Reward #%i' % code,
    }
Exemplo n.º 10
0
    def __init__(self, username, accounttype=None, accountid=None):
        username, accounttype, accountid, summary = GetDestinyUser(
            username, accounttype, accountid)

        self['name'] = username
        self['account_type'] = accounttype
        self['account_id'] = str(accountid)
        self['clan_name'] = summary.get('clanName', '').strip()
        self['clan_tag'] = summary.get('clanTag', '').strip()
        self['grimoire_score'] = summary.get('grimoireScore', 0)
        self['characters'] = []
        for ent in summary['characters']:
            bounties = []
            for vendor in ent['advisors']['vendorAdvisors'].itervalues():
                if not vendor.get('pendingBounties'):
                    continue
                for bounty in vendor['pendingBounties']['saleItems']:
                    item_info = manifest.GetDef('InventoryItem',
                                                bounty['item']['itemHash'])
                    bounties.append({
                        'active':
                        False,
                        'desc':
                        item_info.get('itemDescription', '').strip(),
                        'hash':
                        bounty['item']['itemHash'],
                        'icon':
                        item_info.get('icon', '/img/misc/missing_icon.png'),
                        'name':
                        item_info.get('itemName', '').strip()
                        or 'Item #%i' % ent['itemHash'],
                        'objectives': [
                            GetObjective(code)
                            for code in item_info['objectiveHashes']
                        ],
                        'rewards': [
                            GetReward(long(code))
                            for code in item_info['values']
                        ],
                        'sources': [
                            GetSource(code)
                            for code in item_info.get('sourceHashes', ())
                        ],
                    })

            self['characters'].append({
                'activities':
                GetActivityCompletion(ent['advisors']),
                'bounties':
                bounties,
                'class':
                manifest.GetClassName(ent['characterBase']['classHash']),
                'emblem_banner':
                ent['backgroundPath'],
                'emblem_icon':
                ent['emblemPath'],
                'gender':
                manifest.GetGenderName(ent['characterBase']['genderHash']),
                'history':
                [GetHistoryActivity(activity) for activity in ent['history']],
                'id':
                ent['characterBase']['characterId'],
                'level':
                ent['characterLevel'],
                'light':
                ent['characterBase']['powerLevel'],
                'inventory': {},
                'progress':
                dict(GetProgression(prog) for prog in ent['progressions']),
                'quests': {},
                'race':
                manifest.GetRaceName(ent['characterBase']['raceHash']),
                'stats': {
                    manifest.GetStatName(stat['statHash']): stat['value']
                    for stat in ent['characterBase']['stats'].itervalues()
                },
            })

        self['vault'] = {}
        for ent in summary['inventory']['items']:
            item_info = manifest.GetDef('InventoryItem', ent['itemHash']) or {}
            if item_info.get('bucketTypeHash'):
                bucket_name = GetBucketName(item_info['bucketTypeHash'])
            else:
                bucket_name = 'Undefined (%s)' % GetBucketName(
                    ent['bucketHash'])

            if item_info.get('questlineItemHash'):
                quests = self['characters'][ent['characterIndex']]['quests']
                line_hash = item_info['questlineItemHash']
                line_info = manifest.GetDef('InventoryItem', line_hash)
                quest = quests.get(line_info['itemName'])
                if quest is None:
                    quest = quests[line_info['itemName']] = {
                        'desc': line_info['displaySource'].strip(),
                        'hash': line_hash,
                        'icon': line_info.get('icon',
                                              '/img/misc/missing_icon.png'),
                        'name': line_info['itemName'],
                        'steps': [],
                    }
                    for step_hash in line_info['setItemHashes']:
                        step_info = manifest.GetDef('InventoryItem', step_hash)
                        quest['steps'].append({
                            'active':
                            False,
                            'desc':
                            step_info.get('displaySource', '').strip()
                            or step_info['itemDescription'].strip(),
                            'hash':
                            step_hash,
                            'name':
                            step_info['itemName'],
                            'objective':
                            step_info['itemDescription'].strip(),
                            'objectives': [
                                GetObjective(code)
                                for code in step_info['objectiveHashes']
                            ],
                            'rewards': [
                                GetReward(long(code))
                                for code in step_info['values']
                            ],
                        })
                for step in quest['steps']:
                    if step['hash'] == ent['itemHash']:
                        step['active'] = True
                continue

            if bucket_name == 'Bounties':
                bounties = self['characters'][
                    ent['characterIndex']]['bounties']
                bounty = {
                    'active':
                    True,
                    'desc':
                    item_info.get('itemDescription', '').strip(),
                    'hash':
                    ent['itemHash'],
                    'icon':
                    item_info.get('icon', '/img/misc/missing_icon.png'),
                    'name':
                    item_info.get('itemName', '').strip()
                    or 'Item #%i' % ent['itemHash'],
                    'objectives': [
                        GetObjective(code)
                        for code in item_info['objectiveHashes']
                    ],
                    'rewards':
                    [GetReward(long(code)) for code in item_info['values']],
                    'sources': [
                        GetSource(code)
                        for code in item_info.get('sourceHashes', ())
                    ],
                }
                for i, currentBounty in enumerate(bounties):
                    if currentBounty['hash'] == bounty['hash']:
                        bounties[i] = bounty
                        break
                else:
                    bounties.append(bounty)
                continue

            if ent.get('details'):
                perks = [
                    GetPerk(perk['perkHash'])
                    for perk in ent['details']['item']['perks']
                ]
                equipable = ent['details']['item']['isEquipment']
            else:
                perks = []
                equipable = False
            item = {
                'class':
                GetClassFromCategories(item_info.get('itemCategoryHashes',
                                                     ())),
                'damage_type':
                GetDamageType(ent['damageTypeHash']),
                'desc':
                item_info.get('itemDescription', '').strip(),
                'equipable':
                equipable,
                'equipped':
                bool(ent['transferStatus'] & 1),
                'fully_upgraded':
                ent['isGridComplete'],
                'hash':
                ent['itemHash'],
                'icon':
                item_info.get('icon', '/img/misc/missing_icon.png'),
                'id':
                ent['itemId'],
                'name':
                item_info.get('itemName', '').strip()
                or 'Item #%i' % ent['itemHash'],
                'objectives': [
                    GetObjective(code)
                    for code in item_info.get('objectiveHashes', ())
                ],
                'perks':
                perks,
                'primary_stat_value':
                ent.get('primaryStat') and ent['primaryStat']['value'],
                'primary_stat_type':
                (ent.get('primaryStat')
                 and manifest.GetStatName(ent['primaryStat']['statHash'])),
                'quantity':
                ent['quantity'],
                'sources': [
                    GetSource(code)
                    for code in item_info.get('sourceHashes', ())
                ],
                'state':
                ent['state'],
                'tier':
                item_info.get('tierTypeName', '').strip(),
                'transferrable':
                not item_info.get('nonTransferrable', True),
                'type':
                item_info.get('itemTypeName', '').strip(),
            }
            if ent['characterIndex'] == -1:
                where = self['vault']
            else:
                where = self['characters'][ent['characterIndex']]['inventory']
            if bucket_name not in where:
                where[bucket_name] = []
            where[bucket_name].append(item)
Exemplo n.º 11
0
def GetDestinationName(code):
    return manifest.GetDef('Destination', code)['destinationName'].strip()
Exemplo n.º 12
0
def GetDamageType(code):
    damage = code and manifest.GetDef('DamageType', code) or {}
    return {
        'icon': damage.get('iconPath', '/img/misc/missing_icon.png'),
        'name': damage.get('damageTypeName', 'Damage Type #%i' % code),
    }
Exemplo n.º 13
0
def GetClassFromCategories(codes):
    for code in codes:
        category = manifest.GetDef('ItemCategory', code)
        if category['identifier'].startswith('CATEGORY_CLASS_'):
            return category['title'].strip()
Exemplo n.º 14
0
def GetBucketName(code):
    bucket = manifest.GetDef('InventoryBucket', code)
    return (bucket.get('bucketName') or bucket.get('bucketIdentifier')
            or 'Bucket #%i' % code).strip()
Exemplo n.º 15
0
def GetActivityCompletion(advisors):
    activities = []
    for ent in advisors.get('arena', ()):
        activity = manifest.GetActivity(ent['activityHash'])
        activities.append({
            'complete':
            ent['isCompleted'],
            'desc':
            activity['activityDescription'],
            'hash':
            ent['activityHash'],
            'icon':
            ent['iconPath'],
            'modifiers': [],
            'name':
            activity['activityName'],
            'period':
            'Weekly',
            'rewards':
            GetActivityRewards(activity),
            'steps': [{
                'complete': ent['isCompleted'],
                'name': 'Completed'
            }],
            'type':
            'Prison of Elders',
        })
    for ent in advisors.get('weeklyCrucible', ()):
        bundle = manifest.GetDef('ActivityBundle', ent['activityBundleHash'])
        for code in bundle['activityHashes']:
            activity = manifest.GetActivity(code)
            activities.append({
                'complete':
                ent['isCompleted'],
                'desc':
                activity['activityDescription'],
                'hash':
                code,
                'icon':
                ent['iconPath'],
                'modifiers': [],
                'name':
                activity['activityName'].strip(),
                'period':
                'Weekly',
                'rewards':
                GetActivityRewards(activity),
                'steps': [{
                    'complete': ent['isCompleted'],
                    'name': 'Completed'
                }],
                'type':
                'Crucible',
            })
    for ent in advisors['activityAdvisors'].itervalues():
        if ent.get('dailyChapterActivities'):
            for code in ent['dailyChapterActivities']['tierActivityHashes']:
                activity = manifest.GetActivity(code)
                activities.append({
                    'complete':
                    ent['dailyChapterActivities']['isCompleted'],
                    'desc':
                    activity['activityDescription'],
                    'hash':
                    code,
                    'icon':
                    activity['releaseIcon'],
                    'modifiers':
                    [GetModifier(skull) for skull in activity['skulls']],
                    'name':
                    '%s (%i)' % (activity['activityName'].strip(),
                                 activity['activityLevel']),
                    'period':
                    'Daily',
                    'rewards':
                    GetActivityRewards(activity),
                    'steps': [{
                        'complete':
                        ent['dailyChapterActivities']['isCompleted'],
                        'name':
                        'Completed'
                    }],
                    'type':
                    'Mission',
                })
        elif ent.get('dailyCrucible'):
            bundle = manifest.GetDef('ActivityBundle',
                                     ent['activityBundleHash'])
            for code in bundle['activityHashes']:
                activity = manifest.GetActivity(code)
                activities.append({
                    'complete':
                    ent['dailyCrucible']['isCompleted'],
                    'desc':
                    activity['activityDescription'],
                    'hash':
                    code,
                    'icon':
                    ent['dailyCrucible']['iconPath'],
                    'modifiers': [],
                    'name':
                    activity['activityName'].strip(),
                    'period':
                    'Daily',
                    'rewards':
                    GetActivityRewards(activity),
                    'steps': [{
                        'complete': ent['dailyCrucible']['isCompleted'],
                        'name': 'Completed'
                    }],
                    'type':
                    'Crucible',
                })
        elif ent.get('nightfall'):
            bundle_activity = manifest.GetActivity(ent['activityBundleHash'])
            for tier in ent['nightfall']['tiers']:
                activity = manifest.GetActivity(tier['activityHash'])
                activities.append({
                    'complete':
                    tier['isCompleted'],
                    'desc':
                    activity['activityDescription'],
                    'hash':
                    tier['activityHash'],
                    'icon':
                    ent['nightfall']['iconPath'],
                    'modifiers': [
                        GetModifier(bundle_activity['skulls'][index])
                        for index in tier['skullIndexes']
                    ],
                    'name':
                    '%s (%i)' % (activity['activityName'].strip(),
                                 activity['activityLevel']),
                    'period':
                    'Weekly',
                    'rewards':
                    GetActivityRewards(activity),
                    'steps': [{
                        'complete': tier['isCompleted'],
                        'name': 'Completed'
                    }],
                    'type':
                    'Mission',
                })
        elif ent.get('raidActivities'):
            bundle = manifest.GetDef('ActivityBundle',
                                     ent['activityBundleHash'])
            step_names = RAID_STEPS.get(
                ent['raidActivities']['raidIdentifier'])
            for tier in ent['raidActivities']['tiers']:
                activity = manifest.GetActivity(tier['activityHash'])
                activities.append({
                    'complete':
                    tier['stepsComplete'] == tier['stepsTotal'],
                    'desc':
                    activity['activityDescription'],
                    'hash':
                    tier['activityHash'],
                    'icon':
                    bundle['releaseIcon'],
                    'modifiers':
                    [GetModifier(skull) for skull in activity['skulls']],
                    'name':
                    '%s (%i)' % (activity['activityName'].strip(),
                                 activity['activityLevel']),
                    'period':
                    'Weekly',
                    'rewards':
                    GetActivityRewards(activity),
                    'steps': [{
                        'complete':
                        step['isComplete'],
                        'name':
                        step_names and step_names[i] or 'Step #%i' % (i + 1)
                    } for i, step in enumerate(tier['steps'])],
                    'type':
                    'Raid',
                })
    return activities