public static async Task <List <Item> > ItemsFromProfile(DestinyResponsesDestinyProfileResponse profile, Character activeCharacter) { var bounties = new List <Item>(); foreach (var inventoryKv in profile.CharacterInventories.Data) { var characterId = inventoryKv.Key; var inventory = inventoryKv.Value; if (characterId != activeCharacter.CharacterId.ToString()) { continue; } var character = new Character { CharacterComponent = profile.Characters.Data[characterId] }; await character.PopulateDefinition(); foreach (var inventoryItem in inventory.Items) { if (inventoryItem.BucketHash != PersuitsBucketHash) { continue; } var bounty = await ItemFromItemComponent(inventoryItem, profile, character); if (bounty.Objectives?.Count > 0) { bounties.Add(bounty); } } } //foreach (var inventoryItem in profile.ProfileInventory.Data.Items) //{ // var bounty = await ItemFromItemComponent(inventoryItem, profile); // if (bounty.Objectives?.Count > 0 && (addCompletedBounties || !bounty.IsCompleted)) // { // bounties.Add(bounty); // } //} return(bounties); }
public static async Task <Item> ItemFromItemComponent(DestinyEntitiesItemsDestinyItemComponent item, DestinyResponsesDestinyProfileResponse profile, Character ownerCharacter = default) { var uninstancedObjectivesData = ownerCharacter == null ? new Dictionary <string, DestinyEntitiesItemsDestinyItemObjectivesComponent>() : profile.CharacterUninstancedItemComponents[ownerCharacter.CharacterComponent.CharacterId.ToString()].Objectives.Data; var objectives = new List <DestinyQuestsDestinyObjectiveProgress>(); var itemInstanceId = item.ItemInstanceId.ToString(); var itemHash = item.ItemHash.ToString(); if (profile.ItemComponents.Objectives.Data.ContainsKey(itemInstanceId)) { objectives.AddRange(profile.ItemComponents.Objectives.Data[itemInstanceId]?.Objectives); } if (item.ItemInstanceId.Equals(0) && uninstancedObjectivesData.ContainsKey(itemHash)) { objectives.AddRange(uninstancedObjectivesData[itemHash].Objectives); } if (objectives.Count == 0) { return(new Item()); } var bounty = new Item() { ItemHash = item.ItemHash, ItemInstanceId = item.ItemInstanceId, OwnerCharacter = ownerCharacter, Objectives = new List <Objective>() }; await bounty.PopulateDefinition(); foreach (var destinyQuestsDestinyObjectiveProgress in objectives) { var obj = new Objective { Progress = destinyQuestsDestinyObjectiveProgress }; await obj.PopulateDefinition(); bounty.Objectives.Add(obj); } return(bounty); }
private async Task <Item> ItemFromTrackedEntry(TrackedEntry entry, DestinyResponsesDestinyProfileResponse profile, Dictionary <long, Character> characters) { if (profile == null) { return(default);
public static DestinyComponentsRecordsDestinyRecordComponent FindRecordInProfile(string triumphHash, DestinyResponsesDestinyProfileResponse profile) { var characterIds = profile?.Profile?.Data?.CharacterIds ?? new List <long>(); DestinyComponentsRecordsDestinyRecordComponent record; if (profile?.CharacterRecords?.Data == null) { return(default);