private async void UpdateViewModel() { var profile = AppState.Data.Profile; if (!AppState.Data.DefinitionsLoaded || profile == null) { return; } viewIsUpdating = true; triumphs.Clear(); PresentationNodeDef = await Definitions.GetPresentationNode(presentationNodeHash); if (PresentationNodeDef == null) { return; } foreach (var childRecord in PresentationNodeDef.Children.Records) { var recordDefinition = await Definitions.GetRecord(childRecord.RecordHash); var triumph = new Triumph { Definition = recordDefinition, Hash = childRecord.RecordHash, Objectives = new List <Objective>(), Record = Triumph.FindRecordInProfileOrDefault(childRecord.RecordHash.ToString(), profile) }; if (triumph.Record == null) { Log.Info($"Triumph {childRecord.RecordHash} is missing its record from profile data"); } foreach (var objectiveProgress in triumph.ObjectiveProgresses) { if (objectiveProgress == null) { continue; } var obj = new Objective { Progress = objectiveProgress }; await obj.PopulateDefinition(); triumph.Objectives.Add(obj); } triumphs.Add(triumph); } viewIsUpdating = false; UpdateSelection(); }
public static TrackedEntry FromTriumph(Triumph triumph) { return(new TrackedEntry { Type = TrackedEntryType.Record, Hash = triumph.Hash }); }
private async void UpdateViewModel() { var profile = AppState.Data.Profile; if (!AppState.Data.DefinitionsLoaded || profile == null) { return; } viewIsUpdating = true; triumphs.Clear(); var presentationNode = await Definitions.GetPresentationNode(presentationNodeHash); if (presentationNode == null) { return; } foreach (var childRecord in presentationNode.Children.Records) { var recordDefinition = await Definitions.GetRecord(childRecord.RecordHash); var triumph = new Triumph { Definition = recordDefinition, Hash = childRecord.RecordHash, Objectives = new List <Objective>(), Record = Triumph.FindRecordInProfile(childRecord.RecordHash.ToString(), profile) }; var objectives = (triumph.Record?.IntervalObjectives?.Count ?? 0) > 0 ? triumph.Record.IntervalObjectives : triumph.Record?.Objectives ?? new List <DestinyQuestsDestinyObjectiveProgress>(); foreach (var objectiveProgress in objectives) { var obj = new Objective { Progress = objectiveProgress }; await obj.PopulateDefinition(); triumph.Objectives.Add(obj); } if (triumph.Record != null) { triumphs.Add(triumph); } else { Log( $"triumph {triumph.Definition.DisplayProperties.Name} skipped because its record is missing"); } } viewIsUpdating = false; UpdateSelection(); Log($"actual triumphs: {triumphs.Count}"); }
public bool Matches(Triumph triumph) { return(Type == TrackedEntryType.Record && Hash == triumph.Hash); }
private async void UpdateViewModel() { var profile = AppState.Data.Profile; if (!AppState.Data.DefinitionsLoaded || profile == null) { return; } viewIsUpdating = true; triumphs.Clear(); PresentationNodeDef = await Definitions.GetPresentationNode(presentationNodeHash); if (PresentationNodeDef == null) { return; } foreach (var childRecord in PresentationNodeDef.Children.Records) { var recordDefinition = await Definitions.GetRecord(childRecord.RecordHash); var triumph = new Triumph { Definition = recordDefinition, Hash = childRecord.RecordHash, Objectives = new List <Objective>(), Record = Triumph.FindRecordInProfileOrDefault(childRecord.RecordHash.ToString(), profile) }; if (triumph.Record == null) { Log.Info($"Triumph {childRecord.RecordHash} is missing its record from profile data"); } var objectives = triumph.Record?.Objectives ?? new List <DestinyObjectiveProgress>(); var hasIntervalObjectives = (triumph.Record?.IntervalObjectives?.Count ?? 0) > 0; var intervalObjectives = hasIntervalObjectives ? triumph.Record.IntervalObjectives : new List <DestinyObjectiveProgress>(); var allIntervalsComplete = intervalObjectives.All(v => v.Complete); var remainingIntervalObjectives = intervalObjectives.Where(v => !v.Complete); objectives.AddRange(remainingIntervalObjectives); if (hasIntervalObjectives && allIntervalsComplete) { objectives.Add(intervalObjectives.LastOrDefault()); } foreach (var objectiveProgress in objectives) { if (objectiveProgress == null) { continue; } var obj = new Objective { Progress = objectiveProgress }; await obj.PopulateDefinition(); triumph.Objectives.Add(obj); } triumphs.Add(triumph); } viewIsUpdating = false; UpdateSelection(); }