add construction entries
This commit is contained in:
parent
1b9635ccfe
commit
f14c841e51
@ -0,0 +1,60 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class ConstructionResource {
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string NameLocalised { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public ulong RequiredAmount { get; set; } = 0;
|
||||||
|
|
||||||
|
public ulong ProvidedAmount { get; set; } = 0;
|
||||||
|
|
||||||
|
public ulong Payment { get; set; } = 0;
|
||||||
|
|
||||||
|
public static ConstructionResource FromJSON(JObject obj) {
|
||||||
|
ConstructionResource res = new();
|
||||||
|
|
||||||
|
res.Name = obj.Value<string?>("Name") ?? string.Empty;
|
||||||
|
res.NameLocalised = obj.Value<string?>("Name_Localised") ?? string.Empty;
|
||||||
|
res.RequiredAmount = obj.Value<ulong?>("RequiredAmount") ?? 0;
|
||||||
|
res.ProvidedAmount = obj.Value<ulong?>("ProvidedAmount") ?? 0;
|
||||||
|
res.Payment = obj.Value<ulong?>("Payment") ?? 0;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ColonisationConstructionDepotEntry : Entry {
|
||||||
|
public ulong MarketID { get; set; } = 0;
|
||||||
|
|
||||||
|
public double ConstructionProgress { get; set; } = 0.0;
|
||||||
|
|
||||||
|
public double ConstructionProgressInPercent {
|
||||||
|
get {
|
||||||
|
return ConstructionProgress * 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ConstructionComplete { get; set; } = false;
|
||||||
|
|
||||||
|
public bool ConstructionFailed { get; set; } = false;
|
||||||
|
|
||||||
|
public List<ConstructionResource> ResourcesRequired { get; set; } = new();
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
MarketID = JSON.Value<ulong?>("MarketID") ?? 0;
|
||||||
|
ConstructionProgress = JSON.Value<double?>("ConstructionProgress") ?? 0;
|
||||||
|
ConstructionComplete = JSON.Value<bool?>("ConstructionComplete") ?? false;
|
||||||
|
ConstructionFailed = JSON.Value<bool?>("ConstructionFailed") ?? false;
|
||||||
|
|
||||||
|
JArray? resources = JSON.Value<JArray?>("ResourcesRequired");
|
||||||
|
if (resources != null) {
|
||||||
|
foreach (JObject res in resources) {
|
||||||
|
ConstructionResource resource = ConstructionResource.FromJSON(res);
|
||||||
|
ResourcesRequired.Add(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
EDPlayerJournal/Entries/ColonisationContributionEntry.cs
Normal file
39
EDPlayerJournal/Entries/ColonisationContributionEntry.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,8 @@ public class Entry {
|
|||||||
{ Events.Bounty, typeof(BountyEntry) },
|
{ Events.Bounty, typeof(BountyEntry) },
|
||||||
{ Events.CapShipBond, typeof(CapShipBondEntry) },
|
{ Events.CapShipBond, typeof(CapShipBondEntry) },
|
||||||
{ Events.CarrierJump, typeof(CarrierJump) },
|
{ Events.CarrierJump, typeof(CarrierJump) },
|
||||||
|
{ Events.ColonisationConstructionDepot, typeof(ColonisationConstructionDepotEntry) },
|
||||||
|
{ Events.ColonisationContribution, typeof(ColonisationContributionEntry) },
|
||||||
{ Events.Commander, typeof(CommanderEntry) },
|
{ Events.Commander, typeof(CommanderEntry) },
|
||||||
{ Events.CommitCrime, typeof(CommitCrimeEntry) },
|
{ Events.CommitCrime, typeof(CommitCrimeEntry) },
|
||||||
{ Events.Died, typeof(DiedEntry) },
|
{ Events.Died, typeof(DiedEntry) },
|
||||||
|
@ -5,6 +5,8 @@ public class Events {
|
|||||||
public static readonly string Bounty = "Bounty";
|
public static readonly string Bounty = "Bounty";
|
||||||
public static readonly string CapShipBond = "CapShipBond";
|
public static readonly string CapShipBond = "CapShipBond";
|
||||||
public static readonly string CarrierJump = "CarrierJump";
|
public static readonly string CarrierJump = "CarrierJump";
|
||||||
|
public static readonly string ColonisationConstructionDepot = "ColonisationConstructionDepot";
|
||||||
|
public static readonly string ColonisationContribution = "ColonisationContribution";
|
||||||
public static readonly string Commander = "Commander";
|
public static readonly string Commander = "Commander";
|
||||||
public static readonly string CommitCrime = "CommitCrime";
|
public static readonly string CommitCrime = "CommitCrime";
|
||||||
public static readonly string Died = "Died";
|
public static readonly string Died = "Died";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user