diff --git a/CommitCrimeEntry.cs b/CommitCrimeEntry.cs new file mode 100644 index 0000000..c2f0cdd --- /dev/null +++ b/CommitCrimeEntry.cs @@ -0,0 +1,20 @@ +namespace EDJournal { + public class CommitCrimeEntry : Entry { + private string crimetype = "assault"; + private string faction; + private string victim; + private int bounty = 0; + + public string CrimeType => crimetype; + public string Faction => faction; + public string Victim => victim; + public int Bounty => bounty; + + protected override void Initialise() { + crimetype = JSON.Value("CrimeType") ?? "assault"; + faction = JSON.Value("Faction") ?? ""; + victim = JSON.Value("Victim") ?? ""; + bounty = JSON.Value("Bounty") ?? 0; + } + } +} diff --git a/DiedEntry.cs b/DiedEntry.cs new file mode 100644 index 0000000..53e96cd --- /dev/null +++ b/DiedEntry.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using Newtonsoft.Json.Linq; + +namespace EDJournal { + public class Killer { + private string name; + private string rank; + private string ship; + + public string Name { + get => name; + set => name = value; + } + public string Rank { + get => rank; + set => rank = value; + } + public string Ship { + get => ship; + set => ship = value; + } + } + + public class DiedEntry : Entry { + private readonly List killers = new List(); + + public List Killers => killers; + public Killer Killer => killers.Count > 0 ? killers[0] : null; + public bool WasWing => killers.Count > 1; + + protected override void Initialise() { + var wing = JSON.Value("Killers"); + if (wing != null) { + /* a wing killed us */ + foreach (JObject child in wing.Children()) { + Killer killer = new Killer { + Name = child.Value("Name") ?? "", + Rank = child.Value("Rank") ?? "", + Ship = child.Value("Ship") ?? "" + }; + killers.Add(killer); + } + } else { + /* a single ship killed us */ + Killer killer = new Killer { + Name = JSON.Value("KillerName") ?? "", + Rank = JSON.Value("KillerRank") ?? "", + Ship = JSON.Value("KillerShip") ?? "" + }; + killers.Add(killer); + } + } + } +} diff --git a/Entry.cs b/Entry.cs index 508e29f..9f4c977 100644 --- a/Entry.cs +++ b/Entry.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; namespace EDJournal { /// @@ -12,21 +12,23 @@ namespace EDJournal { /// public class Entry { private static readonly Dictionary classes = new Dictionary { + { Events.Bounty, typeof(BountyEntry) }, + { Events.CommitCrime, typeof(CommitCrimeEntry) }, + { Events.Died, typeof(DiedEntry) }, { Events.Docked, typeof(DockedEntry) }, { Events.FSDJump, typeof(FSDJumpEntry) }, + { Events.HullDamage, typeof(HullDamageEntry) }, + { Events.MarketSell, typeof(MarketSellEntry) }, { Events.MissionAbandoned, typeof(MissionAbandonedEntry) }, { Events.MissionAccepted, typeof(MissionAcceptedEntry) }, { Events.MissionCompleted, typeof(MissionCompletedEntry) }, { Events.MissionRedirected, typeof(MissionRedirectedEntry) }, { Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) }, - { Events.MarketSell, typeof(MarketSellEntry) }, - { Events.SellMicroResources, typeof(SellMicroResourcesEntry) }, { Events.RedeemVoucher, typeof(RedeemVoucherEntry) }, - { Events.Bounty, typeof(BountyEntry) }, + { Events.SellMicroResources, typeof(SellMicroResourcesEntry) }, + { Events.ShieldState, typeof(ShieldStateEntry) }, { Events.ShipTargeted, typeof(ShipTargetedEntry) }, { Events.UnderAttack, typeof(UnderAttackEntry) }, - { Events.ShieldState, typeof(ShieldStateEntry) }, - { Events.HullDamage, typeof(HullDamageEntry) }, }; private string eventtype = null; diff --git a/Events.cs b/Events.cs index 4540b04..e8d3f41 100644 --- a/Events.cs +++ b/Events.cs @@ -1,23 +1,22 @@ namespace EDJournal { public class Events { - /** - * A mission has been completed. - */ - public static readonly string MissionCompleted = "MissionCompleted"; - public static readonly string MissionAccepted = "MissionAccepted"; - public static readonly string MissionAbandoned = "MissionAbandoned"; - public static readonly string Docked = "Docked"; - public static readonly string FSDJump = "FSDJump"; - public static readonly string MultiSellExplorationData = "MultiSellExplorationData"; - public static readonly string MarketSell = "MarketSell"; - public static readonly string SellMicroResources = "SellMicroResources"; - public static readonly string RedeemVoucher = "RedeemVoucher"; public static readonly string Bounty = "Bounty"; - public static readonly string ShipTargeted = "ShipTargeted"; - public static readonly string ShieldState = "ShieldState"; - public static readonly string MissionRedirected = "MissionRedirected"; - public static readonly string UnderAttack = "UnderAttack"; - public static readonly string HullDamage = "HullDamage"; + public static readonly string CommitCrime = "CommitCrime"; + public static readonly string Died = "Died"; + public static readonly string Docked = "Docked"; public static readonly string FighterDestroyed = "FighterDestroyed"; + public static readonly string FSDJump = "FSDJump"; + public static readonly string HullDamage = "HullDamage"; + public static readonly string MarketSell = "MarketSell"; + public static readonly string MissionAbandoned = "MissionAbandoned"; + public static readonly string MissionAccepted = "MissionAccepted"; + public static readonly string MissionCompleted = "MissionCompleted"; + public static readonly string MissionRedirected = "MissionRedirected"; + public static readonly string MultiSellExplorationData = "MultiSellExplorationData"; + public static readonly string RedeemVoucher = "RedeemVoucher"; + public static readonly string SellMicroResources = "SellMicroResources"; + public static readonly string ShieldState = "ShieldState"; + public static readonly string ShipTargeted = "ShipTargeted"; + public static readonly string UnderAttack = "UnderAttack"; } } diff --git a/edjournal.csproj b/edjournal.csproj index b2ffd89..0ef60ac 100644 --- a/edjournal.csproj +++ b/edjournal.csproj @@ -36,16 +36,13 @@ - - - - - + +