diff --git a/EDPlayerJournal/Entries/Entry.cs b/EDPlayerJournal/Entries/Entry.cs index 3266d1d..dcf5b81 100644 --- a/EDPlayerJournal/Entries/Entry.cs +++ b/EDPlayerJournal/Entries/Entry.cs @@ -35,6 +35,7 @@ public class Entry { { Events.MissionRedirected, typeof(MissionRedirectedEntry) }, { Events.Missions, typeof(MissionsEntry) }, { Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) }, + { Events.ReceiveText, typeof(ReceiveTextEntry) }, { Events.RedeemVoucher, typeof(RedeemVoucherEntry) }, { Events.SearchAndRescue, typeof(SearchAndRescueEntry) }, { Events.SellExplorationData, typeof(SellExplorationDataEntry) }, diff --git a/EDPlayerJournal/Entries/Events.cs b/EDPlayerJournal/Entries/Events.cs index 7bf0dd6..94624b3 100644 --- a/EDPlayerJournal/Entries/Events.cs +++ b/EDPlayerJournal/Entries/Events.cs @@ -25,6 +25,7 @@ public class Events { public static readonly string MissionRedirected = "MissionRedirected"; public static readonly string Missions = "Missions"; public static readonly string MultiSellExplorationData = "MultiSellExplorationData"; + public static readonly string ReceiveText = "ReceiveText"; public static readonly string RedeemVoucher = "RedeemVoucher"; public static readonly string SearchAndRescue = "SearchAndRescue"; public static readonly string SellExplorationData = "SellExplorationData"; diff --git a/EDPlayerJournal/Entries/ReceiveTextEntry.cs b/EDPlayerJournal/Entries/ReceiveTextEntry.cs new file mode 100644 index 0000000..a8303ee --- /dev/null +++ b/EDPlayerJournal/Entries/ReceiveTextEntry.cs @@ -0,0 +1,77 @@ +namespace EDPlayerJournal.Entries; + +public class ReceiveTextEntry : Entry { + /// + /// From whom this message is + /// + public string? From { get; set; } + /// + /// The message, if it is just an NPC text, it will be a message ID + /// + public string? Message { get; set; } + /// + /// Message localised + /// + public string? MessageLocalised { get; set; } + /// + /// On what channel this was received. + /// + public string? Channel { get; set; } + + public bool HasNPCCategory { + get { + if (From == null) { + return false; + } + + if (From.Contains(';') && From.StartsWith("$")) { + return true; + } + + return false; + } + } + + /// + /// Returns the NPC's category, if it has one. + /// + public string? NPCCategory { + get { + if (!HasNPCCategory || From == null) { + return null; + } + + string[] parts = From.Split(";", StringSplitOptions.TrimEntries); + if (parts.Length < 2) { + return null; + } + + return parts[0]; + } + } + + /// + /// Returns the NPC's category, if it has one. + /// + public string? NPCName { + get { + if (!HasNPCCategory || From == null) { + return null; + } + + string[] parts = From.Split(";", StringSplitOptions.TrimEntries); + if (parts.Length < 2) { + return null; + } + + return parts[1]; + } + } + + protected override void Initialise() { + From = JSON.Value("From"); + Message = JSON.Value("Message"); + MessageLocalised = JSON.Value("Message_localised"); + Channel = JSON.Value("Channel"); + } +}