provide station faction via Location entry

This commit is contained in:
Florian Stinglmayr 2023-04-19 08:37:22 +02:00
parent 5224dd4555
commit da3a355695

View File

@ -1,18 +1,47 @@
using System; using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq; namespace EDPlayerJournal.Entries;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace EDPlayerJournal.Entries;
public class LocationEntry : Entry { public class LocationEntry : Entry {
/// <summary>
/// Current star system.
/// </summary>
public string? StarSystem { get; set; } public string? StarSystem { get; set; }
/// <summary>
/// Faction in control of the current star system. Empty for unpopulated
/// systems.
/// </summary>
public string? SystemFaction { get; set; } public string? SystemFaction { get; set; }
public string? StationName { get; set; }
/// <summary>
/// 64bit system address.
/// </summary>
public ulong SystemAddress { get; set; } public ulong SystemAddress { get; set; }
/// <summary>
/// Station name if docked at a station.
/// </summary>
public string? StationName { get; set; }
/// <summary>
/// Faction in control of the current station, if docked.
/// </summary>
public string? StationFaction { get; set; }
/// <summary>
/// Body within the system, might be null.
/// </summary>
public string? Body { get; set; } public string? Body { get; set; }
/// <summary>
/// Returns true if the player is docked somewhere.
/// </summary>
public bool Docked { get; set; } public bool Docked { get; set; }
/// <summary>
/// Position of the star system.
/// </summary>
public long[]? StarPos { get; set; } public long[]? StarPos { get; set; }
public List<Faction> SystemFactions { get; set; } = new List<Faction>(); public List<Faction> SystemFactions { get; set; } = new List<Faction>();
@ -30,7 +59,12 @@ public class LocationEntry : Entry {
JObject? systemfaction = JSON.Value<JObject>("SystemFaction"); JObject? systemfaction = JSON.Value<JObject>("SystemFaction");
if (systemfaction != null) { if (systemfaction != null) {
SystemFaction = systemfaction.Value<string>("Name") ?? ""; SystemFaction = systemfaction.Value<string>("Name");
}
JObject? stationfaction = JSON.Value<JObject>("StationFaction");
if (stationfaction != null) {
StationFaction = stationfaction.Value<string>("Name");
} }
JArray? factions = JSON.Value<JArray>("Factions"); JArray? factions = JSON.Value<JArray>("Factions");