EDBGS/EDPlayerJournal/Mission.cs

190 lines
5.5 KiB
C#
Raw Normal View History

using Newtonsoft.Json.Linq;
namespace EDPlayerJournal;
public class Mission : IComparable<Mission> {
public ulong MissionID { get; set; } = 0;
/// <summary>
/// Name of the mission, in machine readable format.
/// </summary>
public string? Name { get; set; }
/// <summary>
/// Localised, human readable mission name.
/// </summary>
public string? LocalisedName { get; set; }
/// <summary>
/// Target of the mission. Optional.
/// </summary>
public string? Target { get; set; }
/// <summary>
/// Target of the mission as a localised human readable string.
/// </summary>
public string? TargetLocalised { get; set; }
/// <summary>
/// Target system of the mission
/// </summary>
public string? DestinationSystem { get; set; }
/// <summary>
/// Destination station.
/// </summary>
public string? DestinationStation { get; set; }
/// <summary>
/// Destination settlement
/// </summary>
public string? DestinationSettlement { get; set; }
/// <summary>
/// In case of redirection, these values denote the new system.
/// </summary>
public string? NewDestinationSystem { get; set; }
/// <summary>
/// In case of redirection, these values denote the new station.
/// </summary>
public string? NewDestinationStation { get; set; }
/// <summary>
/// Faction offering the mission.
/// </summary>
public string? Faction { get; set; }
/// <summary>
/// Target faction (for example for courier missions).
/// </summary>
public string? TargetFaction { get; set; }
/// <summary>
/// Whether the mission is a wing message.
/// </summary>
public bool Wing { get; set; } = false;
/// <summary>
/// Expiry date for the mission.
/// </summary>
public string? Expiry { get; set; }
/// <summary>
/// Influence reward offered. This is for accepting missions only, see the
/// mission effects for actual effects once the mission is complete.
/// </summary>
public string? Influence { get; set; }
/// <summary>
/// Reputation reward offered.
/// </summary>
public string? Reputation { get; set; }
/// <summary>
/// Number of kills required for massacre missions.
/// </summary>
public ulong? KillCount { get; set; }
/// <summary>
/// Monatery reward offered for the mission. Optional, as donate missions don't give
/// a monatery reward.
/// </summary>
public ulong? Reward { get; set; }
/// <summary>
/// Amount donated for donation missions, optional. If this is null, then
/// the mission was not a donation mission.
/// </summary>
public ulong? Donation { get; set; }
/// <summary>
/// Actual amount donated.
/// </summary>
public ulong? Donated { get; set; }
/// <summary>
/// Commodity delivered, or donated. Optional, if this is null, then no
/// commodity was donated or delivered.
/// </summary>
public string? Commodity { get; set; }
/// <summary>
/// Amount of the commodity donated or delivered. Optional.
/// </summary>
public ulong? Count { get; set; }
/// <summary>
/// How many passengers are being transported.
/// </summary>
public ulong? PassengerCount { get; set; }
/// <summary>
/// If the passengers are VIPs.
/// </summary>
public bool? PassengerVIPs { get; set; }
/// <summary>
/// If the passengers are wanted.
/// </summary>
public bool? PassengerWanted { get; set; }
/// <summary>
/// What sort of passengers are being transported.
/// </summary>
public string? PassengerType { get; set; }
public int CompareTo(Mission? other) {
if (other == null) {
return 1;
}
return MissionID.CompareTo(other.MissionID);
}
private static Mission FromJSON(JObject o) {
Mission mission = new Mission();
mission.MissionID = o.Value<ulong?>("MissionID") ?? 0;
mission.Reputation = o.Value<string>("Reputation");
mission.Influence = o.Value<string>("Influence");
mission.DestinationSystem = o.Value<string>("DestinationSystem");
mission.DestinationSettlement = o.Value<string>("DestinationSettlement");
mission.DestinationStation = o.Value<string>("DestinationStation");
mission.NewDestinationSystem = o.Value<string>("NewDestinationSystem");
mission.NewDestinationStation = o.Value<string>("NewDestinationSystem");
mission.Reward = o.Value<ulong?>("Reward");
mission.Target = o.Value<string>("Target");
mission.TargetLocalised = o.Value<string>("Target_Localised");
mission.Expiry = o.Value<JToken>("Expiry")?.ToString();
mission.Wing = o.Value<bool?>("Wing") ?? false;
mission.Name = o.Value<string>("Name");
mission.LocalisedName = o.Value<string>("LocalisedName");
mission.Faction = o.Value<string?>("Faction");
mission.Donation = o.Value<ulong?>("Donation");
mission.Donated = o.Value<ulong?>("Donated");
mission.PassengerCount = o.Value<ulong?>("PassengerCount");
mission.PassengerVIPs = o.Value<bool?>("PassengerVIPs");
mission.PassengerWanted = o.Value<bool?>("PassengerWanted");
mission.PassengerType = o.Value<string>("PassengerType");
mission.KillCount = o.Value<ulong?>("KillCount");
return mission;
}
public static Mission FromMissionAccepted(JObject o) {
return FromJSON(o);
}
}