From 47fcbdb07117102c9fab15f61e04111b45b2023b Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Mon, 7 Feb 2022 16:21:44 +0100 Subject: [PATCH] add SellOrganicData event --- Entry.cs | 1 + Events.cs | 1 + SellOrganicDataEntry.cs | 48 +++++++++++++++++++++++++++++++++++++++++ edjournal.csproj | 1 + 4 files changed, 51 insertions(+) create mode 100644 SellOrganicDataEntry.cs diff --git a/Entry.cs b/Entry.cs index 3e840e4..f984a6b 100644 --- a/Entry.cs +++ b/Entry.cs @@ -31,6 +31,7 @@ namespace EDJournal { { Events.RedeemVoucher, typeof(RedeemVoucherEntry) }, { Events.SellExplorationData, typeof(SellExplorationDataEntry) }, { Events.SellMicroResources, typeof(SellMicroResourcesEntry) }, + { Events.SellOrganicData, typeof(SellOrganicDataEntry) }, { Events.ShieldState, typeof(ShieldStateEntry) }, { Events.ShipTargeted, typeof(ShipTargetedEntry) }, { Events.UnderAttack, typeof(UnderAttackEntry) }, diff --git a/Events.cs b/Events.cs index 87c622f..b0e3f26 100644 --- a/Events.cs +++ b/Events.cs @@ -20,6 +20,7 @@ public static readonly string RedeemVoucher = "RedeemVoucher"; public static readonly string SellExplorationData = "SellExplorationData"; public static readonly string SellMicroResources = "SellMicroResources"; + public static readonly string SellOrganicData = "SellOrganicData"; public static readonly string ShieldState = "ShieldState"; public static readonly string ShipTargeted = "ShipTargeted"; public static readonly string UnderAttack = "UnderAttack"; diff --git a/SellOrganicDataEntry.cs b/SellOrganicDataEntry.cs new file mode 100644 index 0000000..67156e6 --- /dev/null +++ b/SellOrganicDataEntry.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace EDJournal { + public class BioData { + public string Genus { get; set; } + public string GenusLocalised { get; set; } + public string Species { get; set; } + public string SpeciesLocalised { get; set; } + public long Value { get; set; } + public long Bonus { get; set; } + public long TotalValue => Value + Bonus; + } + public class SellOrganicDataEntry : Entry { + public long MarketID { get; set; } + public List BioData { get; set; } + + protected override void Initialise() { + MarketID = JSON.Value("MarketID") ?? 0; + + var biodata = JSON.Value("BioData"); + BioData = new List(); + + if (biodata == null) { + return; + } + + foreach (JObject item in biodata) { + BioData data = new BioData { + Bonus = item.Value("Bonus") ?? 0, + Value = item.Value("Value") ?? 0, + Species = item.Value("Species") ?? "", + Genus = item.Value("Genus") ?? "", + GenusLocalised = item.Value("Genus_Localised") ?? "", + SpeciesLocalised = item.Value("Species_Localised") ?? "" + }; + + BioData.Add(data); + } + } + + public long TotalValue => BioData.Sum(x => x.TotalValue); + } +} diff --git a/edjournal.csproj b/edjournal.csproj index e24f549..b8c361c 100644 --- a/edjournal.csproj +++ b/edjournal.csproj @@ -71,6 +71,7 @@ +