add missions entry
This commit is contained in:
parent
821b030213
commit
9feb176c31
@ -30,6 +30,7 @@ public class Entry {
|
|||||||
{ Events.MissionCompleted, typeof(MissionCompletedEntry) },
|
{ Events.MissionCompleted, typeof(MissionCompletedEntry) },
|
||||||
{ Events.MissionFailed, typeof(MissionFailedEntry) },
|
{ Events.MissionFailed, typeof(MissionFailedEntry) },
|
||||||
{ Events.MissionRedirected, typeof(MissionRedirectedEntry) },
|
{ Events.MissionRedirected, typeof(MissionRedirectedEntry) },
|
||||||
|
{ Events.Missions, typeof(MissionsEntry) },
|
||||||
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
|
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
|
||||||
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
|
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
|
||||||
{ Events.SearchAndRescue, typeof(SearchAndRescueEntry) },
|
{ Events.SearchAndRescue, typeof(SearchAndRescueEntry) },
|
||||||
|
@ -20,6 +20,7 @@ public class Events {
|
|||||||
public static readonly string MissionCompleted = "MissionCompleted";
|
public static readonly string MissionCompleted = "MissionCompleted";
|
||||||
public static readonly string MissionFailed = "MissionFailed";
|
public static readonly string MissionFailed = "MissionFailed";
|
||||||
public static readonly string MissionRedirected = "MissionRedirected";
|
public static readonly string MissionRedirected = "MissionRedirected";
|
||||||
|
public static readonly string Missions = "Missions";
|
||||||
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
|
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
|
||||||
public static readonly string RedeemVoucher = "RedeemVoucher";
|
public static readonly string RedeemVoucher = "RedeemVoucher";
|
||||||
public static readonly string SearchAndRescue = "SearchAndRescue";
|
public static readonly string SearchAndRescue = "SearchAndRescue";
|
||||||
|
48
EDPlayerJournal/Entries/MissionsEntry.cs
Normal file
48
EDPlayerJournal/Entries/MissionsEntry.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -176,6 +176,11 @@ public class Mission : IComparable<Mission> {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Expiry { get; set; }
|
public string? Expiry { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Certain missions have an expires number. No one knows what that is.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? Expires { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Influence reward offered. This is for accepting missions only, see the
|
/// Influence reward offered. This is for accepting missions only, see the
|
||||||
/// mission effects for actual effects once the mission is complete.
|
/// mission effects for actual effects once the mission is complete.
|
||||||
@ -273,7 +278,8 @@ public class Mission : IComparable<Mission> {
|
|||||||
mission.Target = o.Value<string>("Target");
|
mission.Target = o.Value<string>("Target");
|
||||||
mission.TargetLocalised = o.Value<string>("Target_Localised");
|
mission.TargetLocalised = o.Value<string>("Target_Localised");
|
||||||
|
|
||||||
mission.Expiry = o.Value<JToken>("Expiry")?.ToString();
|
mission.Expiry = o.Value<string?>("Expiry");
|
||||||
|
mission.Expires = o.Value<ulong?>("Expires");
|
||||||
mission.Wing = o.Value<bool?>("Wing") ?? false;
|
mission.Wing = o.Value<bool?>("Wing") ?? false;
|
||||||
|
|
||||||
mission.Name = o.Value<string>("Name");
|
mission.Name = o.Value<string>("Name");
|
||||||
|
@ -118,4 +118,27 @@ public class MissionTest {
|
|||||||
Assert.AreEqual(m.Influences["Salus Imperial Society"][1865919973739UL], "++");
|
Assert.AreEqual(m.Influences["Salus Imperial Society"][1865919973739UL], "++");
|
||||||
Assert.AreEqual(m.Influences["Salus Imperial Society"][1733186884306UL], "++");
|
Assert.AreEqual(m.Influences["Salus Imperial Society"][1733186884306UL], "++");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void MissionsTest() {
|
||||||
|
string missionsstr = /*lang=json,strict*/ """{ "timestamp":"2022-11-15T12:40:45Z", "event":"Missions", "Active":[ { "MissionID":900147917, "Name":"Mission_Courier_name", "PassengerMission":false, "Expires":26848 }, { "MissionID":900148007, "Name":"Mission_Courier_name", "PassengerMission":false, "Expires":26848 } ], "Failed":[ ], "Complete":[ ] }""";
|
||||||
|
|
||||||
|
Entry? entry = Entry.Parse(missionsstr);
|
||||||
|
|
||||||
|
Assert.IsNotNull(entry);
|
||||||
|
Assert.IsInstanceOfType(entry, typeof(MissionsEntry));
|
||||||
|
|
||||||
|
MissionsEntry? missions = entry as MissionsEntry;
|
||||||
|
|
||||||
|
Assert.IsNotNull(missions);
|
||||||
|
|
||||||
|
Assert.AreEqual(missions.Active.Count, 2);
|
||||||
|
Assert.AreEqual(missions.Failed.Count, 0);
|
||||||
|
Assert.AreEqual(missions.Complete.Count, 0);
|
||||||
|
|
||||||
|
Mission m = missions.Active[0];
|
||||||
|
Assert.AreEqual(m.MissionID, 900147917UL);
|
||||||
|
Assert.AreEqual(m.Name, "Mission_Courier_name");
|
||||||
|
Assert.AreEqual(m.Expires, 26848UL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user