Compare commits
	
		
			No commits in common. "9feb176c31d9df546fb8eb3fe75a4ec4e10a2153" and "a2c4056979db65c9332cb58e4e209c52b7656ec9" have entirely different histories.
		
	
	
		
			9feb176c31
			...
			a2c4056979
		
	
		
@ -1,9 +1,13 @@
 | 
				
			|||||||
namespace EDPlayerJournal.Entries;
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace EDPlayerJournal.Entries; 
 | 
				
			||||||
public class CommanderEntry : Entry {
 | 
					public class CommanderEntry : Entry {
 | 
				
			||||||
    public string? Name { get; set; }
 | 
					    public string? Name { get; set; }
 | 
				
			||||||
    public string? FID { get; set; }
 | 
					    public string? FID { get; set; }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected override void Initialise() {
 | 
					    protected override void Initialise() {
 | 
				
			||||||
        Name = JSON.Value<string>("Name") ?? "";
 | 
					        Name = JSON.Value<string>("Name") ?? "";
 | 
				
			||||||
        FID = JSON.Value<string>("FID") ?? "";
 | 
					        FID = JSON.Value<string>("FID") ?? "";
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,11 @@ using System.Runtime.InteropServices;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace EDPlayerJournal.Entries;
 | 
					namespace EDPlayerJournal.Entries;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class InvalidJournalEntryException : Exception {
 | 
				
			||||||
 | 
					    public InvalidJournalEntryException() { }
 | 
				
			||||||
 | 
					    public InvalidJournalEntryException(string message) : base(message) { }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// <summary>
 | 
					/// <summary>
 | 
				
			||||||
/// Base class for a single entry within the player journal. If no specific sub class is available
 | 
					/// Base class for a single entry within the player journal. If no specific sub class is available
 | 
				
			||||||
/// this class gives basic information, such as EventType or date when it happened. It also allows
 | 
					/// this class gives basic information, such as EventType or date when it happened. It also allows
 | 
				
			||||||
@ -17,7 +22,6 @@ public class Entry {
 | 
				
			|||||||
        { Events.CommitCrime, typeof(CommitCrimeEntry) },
 | 
					        { Events.CommitCrime, typeof(CommitCrimeEntry) },
 | 
				
			||||||
        { Events.Died, typeof(DiedEntry) },
 | 
					        { Events.Died, typeof(DiedEntry) },
 | 
				
			||||||
        { Events.Docked, typeof(DockedEntry) },
 | 
					        { Events.Docked, typeof(DockedEntry) },
 | 
				
			||||||
        { Events.FileHeader, typeof(FileHeaderEntry) },
 | 
					 | 
				
			||||||
        { Events.FactionKillBond, typeof(FactionKillBondEntry) },
 | 
					        { Events.FactionKillBond, typeof(FactionKillBondEntry) },
 | 
				
			||||||
        { Events.FSDJump, typeof(FSDJumpEntry) },
 | 
					        { Events.FSDJump, typeof(FSDJumpEntry) },
 | 
				
			||||||
        { Events.HullDamage, typeof(HullDamageEntry) },
 | 
					        { Events.HullDamage, typeof(HullDamageEntry) },
 | 
				
			||||||
@ -30,7 +34,6 @@ 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) },
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,6 @@ public class Events {
 | 
				
			|||||||
    public static readonly string Docked = "Docked";
 | 
					    public static readonly string Docked = "Docked";
 | 
				
			||||||
    public static readonly string FactionKillBond = "FactionKillBond";
 | 
					    public static readonly string FactionKillBond = "FactionKillBond";
 | 
				
			||||||
    public static readonly string FighterDestroyed = "FighterDestroyed";
 | 
					    public static readonly string FighterDestroyed = "FighterDestroyed";
 | 
				
			||||||
    public static readonly string FileHeader = "Fileheader";
 | 
					 | 
				
			||||||
    public static readonly string FSDJump = "FSDJump";
 | 
					    public static readonly string FSDJump = "FSDJump";
 | 
				
			||||||
    public static readonly string HullDamage = "HullDamage";
 | 
					    public static readonly string HullDamage = "HullDamage";
 | 
				
			||||||
    public static readonly string LoadGame = "LoadGame";
 | 
					    public static readonly string LoadGame = "LoadGame";
 | 
				
			||||||
@ -20,7 +19,6 @@ 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";
 | 
				
			||||||
 | 
				
			|||||||
@ -1,37 +0,0 @@
 | 
				
			|||||||
namespace EDPlayerJournal.Entries;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class FileHeaderEntry : Entry {
 | 
					 | 
				
			||||||
    /// <summary>
 | 
					 | 
				
			||||||
    /// File part.
 | 
					 | 
				
			||||||
    /// </summary>
 | 
					 | 
				
			||||||
    public ulong Part { get; set; } = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /// <summary>
 | 
					 | 
				
			||||||
    /// Local language of the file.
 | 
					 | 
				
			||||||
    /// </summary>
 | 
					 | 
				
			||||||
    public string? Language { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /// <summary>
 | 
					 | 
				
			||||||
    /// Whether the file is for an Odyssey version
 | 
					 | 
				
			||||||
    /// </summary>
 | 
					 | 
				
			||||||
    public bool Odyssey { get; set; } = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /// <summary>
 | 
					 | 
				
			||||||
    /// Game version in question (3.8 or 4.0)
 | 
					 | 
				
			||||||
    /// </summary>
 | 
					 | 
				
			||||||
    public string GameVersion { get; set; } = "3.8";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /// <summary>
 | 
					 | 
				
			||||||
    /// Build version (SVN revision number).
 | 
					 | 
				
			||||||
    /// </summary>
 | 
					 | 
				
			||||||
    public string? Build { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected override void Initialise() {
 | 
					 | 
				
			||||||
        Part = JSON.Value<ulong?>("part") ?? 1;
 | 
					 | 
				
			||||||
        Language = JSON.Value<string?>("language") ?? string.Empty;
 | 
					 | 
				
			||||||
        // If this entry is not there then its a legacy entry
 | 
					 | 
				
			||||||
        Odyssey = JSON.Value<bool?>("Odyssey") ?? false;
 | 
					 | 
				
			||||||
        GameVersion = JSON.Value<string?>("gameversion") ?? "3.8";
 | 
					 | 
				
			||||||
        Build = JSON.Value<string?>("build");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,48 +0,0 @@
 | 
				
			|||||||
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);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,16 +1,7 @@
 | 
				
			|||||||
namespace EDPlayerJournal;
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// <summary>
 | 
					namespace EDPlayerJournal; 
 | 
				
			||||||
/// Thrown when the parser encounters an invalid journal entry
 | 
					 | 
				
			||||||
/// </summary>
 | 
					 | 
				
			||||||
public class InvalidJournalEntryException : Exception {
 | 
					 | 
				
			||||||
    public InvalidJournalEntryException() { }
 | 
					 | 
				
			||||||
    public InvalidJournalEntryException(string message) : base(message) { }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/// <summary>
 | 
					 | 
				
			||||||
/// Thrown when the parser finds an invalid journal file
 | 
					 | 
				
			||||||
/// </summary>
 | 
					 | 
				
			||||||
public class JournalException : Exception {
 | 
					public class JournalException : Exception {
 | 
				
			||||||
    public JournalException(string message) : base(message) {}
 | 
					    public JournalException(string message) : base(message) {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -176,11 +176,6 @@ 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.
 | 
				
			||||||
@ -278,8 +273,7 @@ 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<string?>("Expiry");
 | 
					        mission.Expiry = o.Value<JToken>("Expiry")?.ToString();
 | 
				
			||||||
        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");
 | 
				
			||||||
 | 
				
			|||||||
@ -1,50 +0,0 @@
 | 
				
			|||||||
using EDPlayerJournal.Entries;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace EDPlayerJournalTests;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[TestClass]
 | 
					 | 
				
			||||||
public class FileHeaderTest {
 | 
					 | 
				
			||||||
    [TestMethod]
 | 
					 | 
				
			||||||
    public void OdysseyFileHeader() {
 | 
					 | 
				
			||||||
        string fileheader = /*lang=json,strict*/ """{ "timestamp":"2022-11-21T15:04:36Z", "event":"Fileheader", "part":1, "language":"English/UK", "Odyssey":true, "gameversion":"4.0.0.1450", "build":"r286858/r0 " }""";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Entry? entry = Entry.Parse(fileheader);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Assert.IsNotNull(entry);
 | 
					 | 
				
			||||||
        Assert.IsInstanceOfType(entry, typeof(FileHeaderEntry));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        FileHeaderEntry? header = entry as FileHeaderEntry;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Assert.IsNotNull(header);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Part, 1UL);
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Language, "English/UK");
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Odyssey, true);
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.GameVersion, "4.0.0.1450");
 | 
					 | 
				
			||||||
        // Someone at FDev messed up string building there.
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Build, "r286858/r0 ");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    [TestMethod]
 | 
					 | 
				
			||||||
    public void LegacyFileHeader() {
 | 
					 | 
				
			||||||
        // This is the oldest file header I could find.
 | 
					 | 
				
			||||||
        string fileheader = /*lang=json,strict*/ """{ "timestamp":"2020-01-02T23:45:23Z", "event":"Fileheader", "part":1, "language":"English\\UK", "gameversion":"3.5.3.400 EDH", "build":"r213094/r0 " }""";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Entry? entry = Entry.Parse(fileheader);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Assert.IsNotNull(entry);
 | 
					 | 
				
			||||||
        Assert.IsInstanceOfType(entry, typeof(FileHeaderEntry));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        FileHeaderEntry? header = entry as FileHeaderEntry;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Assert.IsNotNull(header);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Part, 1UL);
 | 
					 | 
				
			||||||
        // At some point they switche to a forward slash. Curious.
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Language, """English\UK""");
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Odyssey, false);
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.GameVersion, "3.5.3.400 EDH");
 | 
					 | 
				
			||||||
        // ~73k commits in two years. Not bad.
 | 
					 | 
				
			||||||
        Assert.AreEqual(header.Build, "r213094/r0 ");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -118,27 +118,4 @@ 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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user