40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Newtonsoft.Json.Linq;
|
|
|
|
namespace EDPlayerJournal.Entries;
|
|
|
|
public class ConstructionContribution {
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public string NameLocalised { get; set; } = string.Empty;
|
|
|
|
public ulong Amount { get; set; } = 0;
|
|
|
|
public static ConstructionContribution FromJSON(JObject obj) {
|
|
ConstructionContribution res = new();
|
|
|
|
res.Name = obj.Value<string?>("Name") ?? string.Empty;
|
|
res.NameLocalised = obj.Value<string?>("Name_Localised") ?? string.Empty;
|
|
res.Amount = obj.Value<ulong?>("Amount") ?? 0;
|
|
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public class ColonisationContributionEntry : Entry {
|
|
public ulong MarketID { get; set; } = 0;
|
|
|
|
public List<ConstructionContribution> Contributions { get; set; } = new();
|
|
|
|
protected override void Initialise() {
|
|
MarketID = JSON.Value<ulong?>("MarketID") ?? 0;
|
|
|
|
JArray? resources = JSON.Value<JArray?>("Contributions");
|
|
if (resources != null) {
|
|
foreach (JObject res in resources) {
|
|
ConstructionContribution resource = ConstructionContribution.FromJSON(res);
|
|
Contributions.Add(resource);
|
|
}
|
|
}
|
|
}
|
|
}
|