EDBGS/EDPlayerJournal/Entries/MissionsEntry.cs

49 lines
1.4 KiB
C#

using Newtonsoft.Json.Linq;
namespace EDPlayerJournal.Entries;
public class MissionsEntry : Entry {
/// <summary>
/// List of currently active mission.
/// </summary>
public List<Mission> Active { get; set; } = new List<Mission>();
/// <summary>
/// List of failed missions, not yet discarded.
/// </summary>
public List<Mission> Failed { get; set; } = new List<Mission>();
/// <summary>
/// List of completed missions, not yet turned in.
/// </summary>
public List<Mission> Complete { get; set; } = new List<Mission>();
protected override void Initialise() {
JArray? arr;
arr = JSON.Value<JArray?>("Active");
if (arr != null) {
foreach (JObject item in arr.Children().OfType<JObject>()) {
Mission m = Mission.FromMissionAccepted(item);
Active.Add(m);
}
}
arr = JSON.Value<JArray?>("Failed");
if (arr != null) {
foreach (JObject item in arr.Children().OfType<JObject>()) {
Mission m = Mission.FromMissionAccepted(item);
Failed.Add(m);
}
}
arr = JSON.Value<JArray?>("Complete");
if (arr != null) {
foreach (JObject item in arr.Children().OfType<JObject>()) {
Mission m = Mission.FromMissionAccepted(item);
Complete.Add(m);
}
}
}
}