using Newtonsoft.Json.Linq;
namespace EDPlayerJournal.Entries;
public class LocationEntry : Entry {
///
/// Current star system.
///
public string? StarSystem { get; set; }
///
/// Faction in control of the current star system. Empty for unpopulated
/// systems.
///
public string? SystemFaction { get; set; }
///
/// 64bit system address.
///
public ulong SystemAddress { get; set; }
///
/// Station name if docked at a station.
///
public string? StationName { get; set; }
///
/// Faction in control of the current station, if docked.
///
public string? StationFaction { get; set; }
///
/// Body within the system, might be null.
///
public string? Body { get; set; }
///
/// Returns true if the player is docked somewhere.
///
public bool Docked { get; set; }
///
/// Position of the star system.
///
public long[]? StarPos { get; set; }
public List SystemFactions { get; set; } = new List();
protected override void Initialise() {
StarSystem = JSON.Value("StarSystem") ?? "";
SystemAddress = JSON.Value("SystemAddress") ?? 0;
Docked = JSON.Value("Docked") ?? false;
StationName = JSON.Value("StationName") ?? "";
var pos = JSON.Value("StarPos");
if (pos != null) {
StarPos = pos.ToObject();
}
JObject? systemfaction = JSON.Value("SystemFaction");
if (systemfaction != null) {
SystemFaction = systemfaction.Value("Name");
}
JObject? stationfaction = JSON.Value("StationFaction");
if (stationfaction != null) {
StationFaction = stationfaction.Value("Name");
}
JArray? factions = JSON.Value("Factions");
if (factions != null) {
foreach (JObject system_faction in factions) {
Faction? f = Faction.FromJSON(system_faction);
if (f != null) {
SystemFactions.Add(f);
}
}
}
}
}