EDBGS/EDPlayerJournal/Entries/SellOrganicDataEntry.cs

49 lines
1.4 KiB
C#

using Newtonsoft.Json.Linq;
namespace EDPlayerJournal.Entries;
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; } = 0;
public long Bonus { get; set; } = 0;
public long TotalValue {
get {
return Value + Bonus;
}
}
}
public class SellOrganicDataEntry : Entry {
public long MarketID { get; set; }
public List<BioData> BioData { get; } = new();
protected override void Initialise() {
MarketID = JSON.Value<long?>("MarketID") ?? 0;
var biodata = JSON.Value<JArray>("BioData");
if (biodata == null) {
return;
}
foreach (JObject item in biodata) {
BioData data = new BioData {
Bonus = item.Value<long?>("Bonus") ?? 0,
Value = item.Value<long?>("Value") ?? 0,
Species = item.Value<string>("Species"),
Genus = item.Value<string>("Genus"),
GenusLocalised = item.Value<string>("Genus_Localised"),
SpeciesLocalised = item.Value<string>("Species_Localised")
};
BioData.Add(data);
}
}
public long TotalValue {
get { return BioData.Sum(x => x.TotalValue); }
}
}