provide system address for lookup of system specific influence gains
This commit is contained in:
parent
325e9ad1a7
commit
41a7782a7c
@ -4,11 +4,13 @@ namespace EDJournal {
|
||||
public class DockedEntry : Entry {
|
||||
public string StationName { get; set; }
|
||||
public string StarSystem { get; set; }
|
||||
public ulong SystemAddress { get; set; }
|
||||
public string StationFaction { get; set; }
|
||||
|
||||
protected override void Initialise() {
|
||||
StationName = JSON.Value<string>("StationName") ?? "";
|
||||
StarSystem = JSON.Value<string>("StarSystem") ?? "";
|
||||
SystemAddress = JSON.Value<ulong?>("SystemAddress") ?? 0;
|
||||
JObject faction = JSON.Value<JObject>("StationFaction");
|
||||
if (faction != null) {
|
||||
StationFaction = faction.Value<string>("Name") ?? "";
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
namespace EDJournal {
|
||||
public class FSDJumpEntry : Entry {
|
||||
private string starsystem = null;
|
||||
private string systemfaction = null;
|
||||
protected override void Initialise() {
|
||||
starsystem = JSON.Value<string>("StarSystem");
|
||||
SystemAddress = JSON.Value<ulong?>("SystemAddress") ?? 0;
|
||||
StarSystem = JSON.Value<string>("StarSystem");
|
||||
var faction = JSON.Value<JObject>("SystemFaction");
|
||||
if (faction != null) {
|
||||
systemfaction = faction.Value<string>("Name");
|
||||
SystemFaction = faction.Value<string>("Name");
|
||||
}
|
||||
}
|
||||
public string StarSystem => starsystem;
|
||||
public string StarSystem { get; set; }
|
||||
|
||||
public string SystemFaction => systemfaction;
|
||||
public string SystemFaction { get; set; }
|
||||
|
||||
public ulong SystemAddress { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace EDJournal {
|
||||
public class MissionCompletedEntry : Entry {
|
||||
private Dictionary<string, string> influences = new Dictionary<string, string>();
|
||||
private Dictionary<string, Dictionary<ulong, string>> influences = new Dictionary<string, Dictionary<ulong, string>>();
|
||||
private List<string> affected = new List<string>();
|
||||
private string readable_name = null;
|
||||
private bool readable_name_generated = false;
|
||||
|
||||
public Dictionary<string, Dictionary<ulong, string>> Influences => influences;
|
||||
|
||||
protected override void Initialise() {
|
||||
MissionID = JSON.Value<int?>("MissionID") ?? 0;
|
||||
Name = JSON.Value<string>("Name");
|
||||
@ -38,12 +41,23 @@ namespace EDJournal {
|
||||
var influence = effect.Value<JArray>("Influence");
|
||||
if (influence == null || influence.Count == 0) {
|
||||
// No influence reward, happens sometimes, but we have to accept it
|
||||
influences.Add(faction, "");
|
||||
influences.Add(faction, new Dictionary<ulong, string>());
|
||||
} else {
|
||||
foreach (var infl in influence.Children<JObject>()) {
|
||||
infl.TryGetValue("Influence", out JToken result);
|
||||
if (result != null && result.Type == JTokenType.String) {
|
||||
influences.Add(faction, result.ToString());
|
||||
infl.TryGetValue("SystemAddress", out JToken systemaddr);
|
||||
if (result != null && result.Type == JTokenType.String &&
|
||||
systemaddr != null && systemaddr.Type == JTokenType.Integer) {
|
||||
ulong system = systemaddr.ToObject<ulong?>() ?? 0;
|
||||
string inf = result.ToString();
|
||||
|
||||
if (!influences.ContainsKey(faction)) {
|
||||
influences.Add(faction, new Dictionary<ulong, string>());
|
||||
}
|
||||
|
||||
if (!influences[faction].ContainsKey(system)) {
|
||||
influences[faction].Add(system, inf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,11 +124,24 @@ namespace EDJournal {
|
||||
public string[] AffectedFactions => affected.ToArray();
|
||||
|
||||
public string GetInfluenceForFaction(string faction) {
|
||||
if (influences.ContainsKey(faction)) {
|
||||
return influences[faction];
|
||||
if (!influences.ContainsKey(faction)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "";
|
||||
var inf = influences[faction];
|
||||
return string.Join("", inf.Values);
|
||||
}
|
||||
|
||||
public string GetInfluenceForFaction(string faction, ulong systemaddr) {
|
||||
if (!influences.ContainsKey(faction)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!influences[faction].ContainsKey(systemaddr)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return influences[faction][systemaddr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user