diff --git a/BountyEntry.cs b/BountyEntry.cs new file mode 100644 index 0000000..3c9c90c --- /dev/null +++ b/BountyEntry.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EDJournal { + /** + * This entry appears whenever a bounty is awarded. + */ + public class BountyEntry : Entry { + private string victimfaction = null; + private string target = null; + private int rewards = 0; + + protected override void Initialise() { + rewards = JSON.Value("TotalReward") ?? 0; + victimfaction = JSON.Value("VictimFaction") ?? ""; + target = JSON.Value("Target_Localised") ?? ""; + } + + public string VictimFaction => victimfaction; + public string Target => target; + public int Rewards => rewards; + } +} diff --git a/Entry.cs b/Entry.cs index 9dc2b53..d03ab14 100644 --- a/Entry.cs +++ b/Entry.cs @@ -14,11 +14,17 @@ namespace EDJournal { private static readonly Dictionary classes = new Dictionary { { Events.Docked, typeof(DockedEntry) }, { Events.FSDJump, typeof(FSDJumpEntry) }, + { 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.ShipTargeted, typeof(ShipTargetedEntry) }, + { Events.UnderAttack, typeof(UnderAttackEntry) }, + { Events.ShieldState, typeof(ShieldStateEntry) }, }; private string eventtype = null; @@ -83,10 +89,7 @@ namespace EDJournal { } public override string ToString() { - if (json == null) { - return ""; - } - return json.ToString(); + return jsonstr ?? ""; } } } diff --git a/Events.cs b/Events.cs index 080dcd4..20517b5 100644 --- a/Events.cs +++ b/Events.cs @@ -1,11 +1,20 @@ 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 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"; } } diff --git a/MissionAcceptedEntry.cs b/MissionAcceptedEntry.cs new file mode 100644 index 0000000..865aa71 --- /dev/null +++ b/MissionAcceptedEntry.cs @@ -0,0 +1,30 @@ + +namespace EDJournal { + public class MissionAcceptedEntry : Entry { + private string faction = null; + private string name = null; + private string localisedname = null; + private string localisedtargettype = null; + private int killcount = 0; + private int missionid = 0; + private int reward = 0; + + public string Faction => faction; + public string Name => name; + public string LocalisedName => localisedname; + public string LocalisedTargetType => localisedtargettype; + public int KillCount => killcount; + public int MissionID => missionid; + public int Reward => reward; + + protected override void Initialise() { + faction = JSON.Value("Faction") ?? ""; + name = JSON.Value("Name") ?? ""; + localisedname = JSON.Value("LocalisedName") ?? ""; + localisedtargettype = JSON.Value("TargetType_Localised") ?? ""; + killcount = JSON.Value("KillCount") ?? 0; + missionid = JSON.Value("MissionID") ?? 0; + reward = JSON.Value("Reward") ?? 0; + } + } +} diff --git a/MissionRedirectedEntry.cs b/MissionRedirectedEntry.cs new file mode 100644 index 0000000..2e36081 --- /dev/null +++ b/MissionRedirectedEntry.cs @@ -0,0 +1,23 @@ +namespace EDJournal { + public class MissionRedirectedEntry : Entry { + private int missionid = 0; + private string name = null; + private string newdestinationstation = null; + private string newdestinationsystem = null; + private string olddestinationsystem = null; + + public int MissionID => missionid; + public string Name => name; + public string NewDestinationStation => newdestinationstation; + public string NewDestinationSystem => newdestinationsystem; + public string OldDestinationSystem => olddestinationsystem; + + protected override void Initialise() { + missionid = JSON.Value("MissionID") ?? 0; + name = JSON.Value("Name") ?? ""; + newdestinationstation = JSON.Value("NewDestinationStation") ?? ""; + newdestinationsystem = JSON.Value("NewDestinationSystem") ?? ""; + olddestinationsystem = JSON.Value("OldDestinationSystem") ?? ""; + } + } +} diff --git a/ShieldStateEntry.cs b/ShieldStateEntry.cs new file mode 100644 index 0000000..08fd2b5 --- /dev/null +++ b/ShieldStateEntry.cs @@ -0,0 +1,9 @@ +namespace EDJournal { + public class ShieldStateEntry : Entry { + public bool shieldsup = false; + public bool ShieldsUp => shieldsup; + protected override void Initialise() { + shieldsup = JSON.Value("ShieldsUp") ?? true; + } + } +} diff --git a/ShipTargetedEntry.cs b/ShipTargetedEntry.cs new file mode 100644 index 0000000..80cd885 --- /dev/null +++ b/ShipTargetedEntry.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EDJournal { + public class ShipTargetedEntry : Entry { + private string ship = null; + private string pilot = null; + private string rank = null; + private double shield = 0.0; + private double hull = 0.0; + private int bounty = 0; + private string legalstatus = null; + private string faction = null; + + public string Ship => ship; + public string Pilot => pilot; + public string Rank => rank; + public double ShieldHealth => shield; + public double HullHealth => hull; + public int Bounty => bounty; + public string LegalStatus => legalstatus; + public string Faction => faction; + + protected override void Initialise() { + ship = JSON.Value("Ship_Localised") ?? ""; + pilot = JSON.Value("PilotName_Localised") ?? ""; + rank = JSON.Value("PilotRank") ?? ""; + shield = JSON.Value("ShieldHealth") ?? 0.0; + hull = JSON.Value("HullHealth") ?? 0.0; + bounty = JSON.Value("Bounty") ?? 0; + legalstatus = JSON.Value("LegalStatus") ?? "Clean"; + faction = JSON.Value("Faction") ?? ""; + } + } +} diff --git a/UnderAttackEntry.cs b/UnderAttackEntry.cs new file mode 100644 index 0000000..fc65e22 --- /dev/null +++ b/UnderAttackEntry.cs @@ -0,0 +1,9 @@ +namespace EDJournal { + public class UnderAttackEntry : Entry { + private string target = null; + public string Target => target; + protected override void Initialise() { + target = JSON.Value("Target") ?? "You"; + } + } +} diff --git a/edjournal.csproj b/edjournal.csproj index eafe3a6..2ff5053 100644 --- a/edjournal.csproj +++ b/edjournal.csproj @@ -44,6 +44,7 @@ + @@ -54,12 +55,17 @@ + + + + +