add a Mission class for accepted missions

This commit is contained in:
2022-11-24 14:18:27 +01:00
parent 607171f050
commit 1d19a8f73c
9 changed files with 263 additions and 31 deletions

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Runtime.InteropServices;
namespace EDPlayerJournal.Entries;
@@ -55,11 +56,14 @@ public class Entry {
}
public static Entry? Parse(string journalline) {
var json = JObject.Parse(journalline);
if (json == null) {
return null;
using (JsonReader reader = new JsonTextReader(new StringReader(journalline))) {
reader.DateParseHandling = DateParseHandling.None;
var json = JObject.Load(reader);
if (json == null) {
return null;
}
return Parse(json);
}
return Parse(json);
}
public static Entry? Parse(JObject json) {

View File

@@ -1,22 +1,9 @@
namespace EDPlayerJournal.Entries;
public class MissionAcceptedEntry : Entry {
public string? Faction { get; set; }
public string? TargetFaction { get; set; }
public string? Name { get; set; }
public string? LocalisedName { get; set; }
public string? LocalisedTargetType { get; set; }
public int KillCount { get; set; }
public ulong MissionID { get; set; }
public long Reward { get; set; }
public Mission? Mission { get; set; }
protected override void Initialise() {
Faction = JSON.Value<string>("Faction");
TargetFaction = JSON.Value<string>("TargetFaction");
Name = JSON.Value<string>("Name");
LocalisedName = JSON.Value<string>("LocalisedName");
LocalisedTargetType = JSON.Value<string>("TargetType_Localised");
KillCount = JSON.Value<int?>("KillCount") ?? 0;
MissionID = JSON.Value<ulong?>("MissionID") ?? 0;
Reward = JSON.Value<long?>("Reward") ?? 0;
Mission = Mission.FromMissionAccepted(JSON);
}
}