55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace EDJournal {
|
|
public class Killer {
|
|
private string name;
|
|
private string rank;
|
|
private string ship;
|
|
|
|
public string Name {
|
|
get => name;
|
|
set => name = value;
|
|
}
|
|
public string Rank {
|
|
get => rank;
|
|
set => rank = value;
|
|
}
|
|
public string Ship {
|
|
get => ship;
|
|
set => ship = value;
|
|
}
|
|
}
|
|
|
|
public class DiedEntry : Entry {
|
|
private readonly List<Killer> killers = new List<Killer>();
|
|
|
|
public List<Killer> Killers => killers;
|
|
public Killer Killer => killers.Count > 0 ? killers[0] : null;
|
|
public bool WasWing => killers.Count > 1;
|
|
|
|
protected override void Initialise() {
|
|
var wing = JSON.Value<JArray>("Killers");
|
|
if (wing != null) {
|
|
/* a wing killed us */
|
|
foreach (JObject child in wing.Children<JObject>()) {
|
|
Killer killer = new Killer {
|
|
Name = child.Value<string>("Name") ?? "",
|
|
Rank = child.Value<string>("Rank") ?? "",
|
|
Ship = child.Value<string>("Ship") ?? ""
|
|
};
|
|
killers.Add(killer);
|
|
}
|
|
} else {
|
|
/* a single ship killed us */
|
|
Killer killer = new Killer {
|
|
Name = JSON.Value<string>("KillerName") ?? "",
|
|
Rank = JSON.Value<string>("KillerRank") ?? "",
|
|
Ship = JSON.Value<string>("KillerShip") ?? ""
|
|
};
|
|
killers.Add(killer);
|
|
}
|
|
}
|
|
}
|
|
}
|