Compare commits
No commits in common. "a2c4056979db65c9332cb58e4e209c52b7656ec9" and "607171f0503180dcc23551e436e5d7c546925cf8" have entirely different histories.
a2c4056979
...
607171f050
@ -25,8 +25,8 @@ public class InfluenceSupport : Transaction {
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
string? missionname;
|
string? missionname;
|
||||||
|
|
||||||
if (RelevantMission != null && RelevantMission.Mission != null) {
|
if (RelevantMission != null) {
|
||||||
missionname = RelevantMission.Mission.LocalisedName;
|
missionname = RelevantMission.HumanReadableName;
|
||||||
} else {
|
} else {
|
||||||
missionname = "UNKNOWN MISSION";
|
missionname = "UNKNOWN MISSION";
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,14 @@ public class MissionCompleted : Transaction {
|
|||||||
public string MissionName {
|
public string MissionName {
|
||||||
get {
|
get {
|
||||||
MissionCompletedEntry? c = Entries[0] as MissionCompletedEntry;
|
MissionCompletedEntry? c = Entries[0] as MissionCompletedEntry;
|
||||||
if (c == null || c.Mission == null) {
|
if (c == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(c.Mission.LocalisedName)) {
|
if (string.IsNullOrEmpty(c.HumanReadableName)) {
|
||||||
return (c.Mission.Name ?? "");
|
return (c.Name ?? "");
|
||||||
} else {
|
} else {
|
||||||
return c.Mission.LocalisedName;
|
return c.HumanReadableName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -28,11 +28,15 @@ public class MissionCompleted : Transaction {
|
|||||||
get {
|
get {
|
||||||
MissionCompletedEntry? e = (Entries[0] as MissionCompletedEntry);
|
MissionCompletedEntry? e = (Entries[0] as MissionCompletedEntry);
|
||||||
|
|
||||||
if (e == null || Faction == null || e.Mission == null) {
|
if (e == null || Faction == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (e.Mission.GetInfluenceForFaction(Faction, SystemAddress) ?? "");
|
if (SystemAddress == 0) {
|
||||||
|
return (e.GetInfluenceForFaction(Faction) ?? "");
|
||||||
|
} else {
|
||||||
|
return (e.GetInfluenceForFaction(Faction, SystemAddress) ?? "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,11 +48,11 @@ public class MissionCompleted : Transaction {
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
var entry = Entries[0] as MissionCompletedEntry;
|
var entry = Entries[0] as MissionCompletedEntry;
|
||||||
|
|
||||||
if (entry == null || entry.Mission == null) {
|
if (entry == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var influence = entry.Mission.GetInfluenceForFaction(Faction, SystemAddress);
|
var influence = entry.GetInfluenceForFaction(Faction, SystemAddress);
|
||||||
|
|
||||||
builder.AppendFormat("{0}", MissionName);
|
builder.AppendFormat("{0}", MissionName);
|
||||||
if (influence != "") {
|
if (influence != "") {
|
||||||
|
@ -9,11 +9,8 @@ public class MissionFailed : Transaction {
|
|||||||
public MissionFailed() { }
|
public MissionFailed() { }
|
||||||
|
|
||||||
public MissionFailed(MissionAcceptedEntry accepted) {
|
public MissionFailed(MissionAcceptedEntry accepted) {
|
||||||
if (accepted.Mission == null) {
|
|
||||||
throw new Exception("Mission cannot be null");
|
|
||||||
}
|
|
||||||
Accepted = accepted;
|
Accepted = accepted;
|
||||||
Faction = accepted.Mission.Faction;
|
Faction = accepted.Faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int CompareTo(Transaction? other) {
|
public override int CompareTo(Transaction? other) {
|
||||||
@ -28,9 +25,8 @@ public class MissionFailed : Transaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if it is the same mission name, the same faction and the same system,
|
/* if it is the same mission name, the same faction and the same system,
|
||||||
* collate mission failures together
|
* collate mission failures together */
|
||||||
*/
|
if (failed.Failed?.HumanReadableName == Failed?.HumanReadableName &&
|
||||||
if (string.Compare(failed.Failed?.Mission?.Name, Failed?.Mission?.Name) == 0 &&
|
|
||||||
failed.Faction == Faction &&
|
failed.Faction == Faction &&
|
||||||
failed.System == System) {
|
failed.System == System) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -51,8 +47,7 @@ public class MissionFailed : Transaction {
|
|||||||
|
|
||||||
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
|
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
|
||||||
Amount,
|
Amount,
|
||||||
Failed?.Mission?.LocalisedName != null ?
|
Failed.HumanReadableName != null ? Failed.HumanReadableName : Failed.Name
|
||||||
Failed?.Mission?.LocalisedName : Failed?.Mission?.Name
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
|
@ -231,7 +231,7 @@ public class Report {
|
|||||||
MissionCompletedEntry? completed = e as MissionCompletedEntry;
|
MissionCompletedEntry? completed = e as MissionCompletedEntry;
|
||||||
|
|
||||||
if (completed == null ||
|
if (completed == null ||
|
||||||
completed.Mission == null) {
|
completed.MissionID == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,38 +240,48 @@ public class Report {
|
|||||||
ulong accepted_address;
|
ulong accepted_address;
|
||||||
string? accepted_system;
|
string? accepted_system;
|
||||||
|
|
||||||
string? target_faction_name = completed.Mission.TargetFaction;
|
string? target_faction_name = completed.TargetFaction;
|
||||||
string? source_faction_name = completed.Mission.Faction;
|
string? source_faction_name = completed.Faction;
|
||||||
|
|
||||||
if (!acceptedMissions.TryGetValue(completed.Mission.MissionID, out accepted)) {
|
if (!acceptedMissions.TryGetValue(completed.MissionID.Value, out accepted)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to find mission acceptance for mission \"{0}\". " +
|
"Unable to find mission acceptance for mission \"{0}\". " +
|
||||||
"Please extend range to include the mission acceptance.", completed.Mission.LocalisedName
|
"Please extend range to include the mission acceptance.", completed.HumanReadableName
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acceptedSystems.TryGetValue(completed.Mission.MissionID, out accepted_address)) {
|
if (!acceptedSystems.TryGetValue(completed.MissionID.Value, out accepted_address)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.Mission.LocalisedName
|
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.HumanReadableName
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
|
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.Mission.LocalisedName
|
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.HumanReadableName
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var other in completed.Mission.Influences) {
|
if (completed.HumanReadableNameWasGenerated) {
|
||||||
|
/* If the human readable name was generated, we send a log message. Because the
|
||||||
|
* generated names all sort of suck, we should have more human readable names in
|
||||||
|
* in the lookup dictionary.
|
||||||
|
*/
|
||||||
|
OnLog?.Invoke("Human readable name for mission \"" +
|
||||||
|
completed.Name +
|
||||||
|
"\" was generated, please report this.");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var other in completed.Influences) {
|
||||||
string faction = other.Key;
|
string faction = other.Key;
|
||||||
if (string.IsNullOrEmpty(faction)) {
|
if (string.IsNullOrEmpty(faction)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Mission \"{0}\" has empty faction name in influence block, "+
|
"Mission \"{0}\" has empty faction name in influence block, "+
|
||||||
"so this influence support was ignored. " +
|
"so this influence support was ignored. " +
|
||||||
"Please check the README on why this happens.", completed.Mission.LocalisedName)
|
"Please check the README on why this happens.", completed.HumanReadableName)
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -284,7 +294,7 @@ public class Report {
|
|||||||
"Mission \"{0}\" gave no influence to \"{1}\", so we assume this is because the " +
|
"Mission \"{0}\" gave no influence to \"{1}\", so we assume this is because the " +
|
||||||
"faction is in a conflict and cannot gain influence right now. " +
|
"faction is in a conflict and cannot gain influence right now. " +
|
||||||
"If this assessment is wrong, just remove the entry from the objective list.",
|
"If this assessment is wrong, just remove the entry from the objective list.",
|
||||||
completed.Mission.LocalisedName, faction
|
completed.HumanReadableName, faction
|
||||||
));
|
));
|
||||||
|
|
||||||
if (string.Compare(target_faction_name, faction, true) == 0) {
|
if (string.Compare(target_faction_name, faction, true) == 0) {
|
||||||
@ -300,7 +310,7 @@ public class Report {
|
|||||||
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the target faction " +
|
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the target faction " +
|
||||||
"of the mission, we assume the influence was gained in \"{2}\". " +
|
"of the mission, we assume the influence was gained in \"{2}\". " +
|
||||||
"Please remove the entry if this assumption is wrong.",
|
"Please remove the entry if this assumption is wrong.",
|
||||||
completed.Mission.LocalisedName, faction, current_system
|
completed.HumanReadableName, faction, current_system
|
||||||
));
|
));
|
||||||
} else if (string.Compare(source_faction_name, faction, true) == 0) {
|
} else if (string.Compare(source_faction_name, faction, true) == 0) {
|
||||||
/* source faction of the mission is not getting any influence. This could be because
|
/* source faction of the mission is not getting any influence. This could be because
|
||||||
@ -314,7 +324,7 @@ public class Report {
|
|||||||
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the source faction " +
|
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the source faction " +
|
||||||
"of the mission, we assume the influence was gained in \"{2}\". " +
|
"of the mission, we assume the influence was gained in \"{2}\". " +
|
||||||
"Please remove the entry if this assumption is wrong.",
|
"Please remove the entry if this assumption is wrong.",
|
||||||
completed.Mission.LocalisedName, faction, accepted_system
|
completed.HumanReadableName, faction, accepted_system
|
||||||
));
|
));
|
||||||
|
|
||||||
/* check if source/target faction are equal, in which case we also need an entry
|
/* check if source/target faction are equal, in which case we also need an entry
|
||||||
@ -328,7 +338,7 @@ public class Report {
|
|||||||
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the source and target faction " +
|
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the source and target faction " +
|
||||||
"of the mission, we assume the influence was also gained in target system \"{2}\". " +
|
"of the mission, we assume the influence was also gained in target system \"{2}\". " +
|
||||||
"Please remove the entry if this assumption is wrong.",
|
"Please remove the entry if this assumption is wrong.",
|
||||||
completed.Mission.LocalisedName, faction, current_system
|
completed.HumanReadableName, faction, current_system
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,7 +349,7 @@ public class Report {
|
|||||||
string? system;
|
string? system;
|
||||||
string? accepted_station;
|
string? accepted_station;
|
||||||
|
|
||||||
if (completed.Mission == null) {
|
if (completed.MissionID == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,9 +360,9 @@ public class Report {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acceptedStations.TryGetValue(completed.Mission.MissionID, out accepted_station)) {
|
if (!acceptedStations.TryGetValue(completed.MissionID.Value, out accepted_station)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which station mission \"{0}\" was accepted.", completed.Mission.LocalisedName
|
"Unable to figure out in which station mission \"{0}\" was accepted.", completed.HumanReadableName
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -391,11 +401,7 @@ public class Report {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accepted.Mission == null) {
|
ulong id = accepted.MissionID;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong id = accepted.Mission.MissionID;
|
|
||||||
|
|
||||||
if (!acceptedMissions.ContainsKey(id)) {
|
if (!acceptedMissions.ContainsKey(id)) {
|
||||||
acceptedMissions[id] = accepted;
|
acceptedMissions[id] = accepted;
|
||||||
@ -413,37 +419,33 @@ public class Report {
|
|||||||
string? accepted_system;
|
string? accepted_system;
|
||||||
string? accepted_station;
|
string? accepted_station;
|
||||||
|
|
||||||
if (failed == null || failed.Mission == null) {
|
if (failed == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acceptedMissions.TryGetValue(failed.Mission.MissionID, out accepted)) {
|
if (!acceptedMissions.TryGetValue(failed.MissionID, out accepted)) {
|
||||||
OnLog?.Invoke("A mission failed which wasn't accepted in the given time frame. " +
|
OnLog?.Invoke("A mission failed which wasn't accepted in the given time frame. " +
|
||||||
"Please adjust start date to when the mission was accepted to include it in the list.");
|
"Please adjust start date to when the mission was accepted to include it in the list.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accepted.Mission == null) {
|
if (!acceptedSystems.TryGetValue(failed.MissionID, out accepted_address)) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!acceptedSystems.TryGetValue(failed.Mission.MissionID, out accepted_address)) {
|
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
|
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Name
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
|
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
|
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Name
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acceptedStations.TryGetValue(failed.Mission.MissionID, out accepted_station)) {
|
if (!acceptedStations.TryGetValue(failed.MissionID, out accepted_station)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Mission.Name
|
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Name
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -452,10 +454,16 @@ public class Report {
|
|||||||
Failed = failed,
|
Failed = failed,
|
||||||
System = accepted_system,
|
System = accepted_system,
|
||||||
Station = accepted_station,
|
Station = accepted_station,
|
||||||
Faction = accepted.Mission.Faction,
|
Faction = accepted.Faction,
|
||||||
SystemAddress = accepted_address,
|
SystemAddress = accepted_address,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (failed.HumanReadableName == null) {
|
||||||
|
OnLog?.Invoke("Human readable name for mission \"" +
|
||||||
|
failed.Name +
|
||||||
|
"\" was not recognised");
|
||||||
|
}
|
||||||
|
|
||||||
/* Mission failed should be collated if they are in the same system/station
|
/* Mission failed should be collated if they are in the same system/station
|
||||||
*/
|
*/
|
||||||
collate = true;
|
collate = true;
|
||||||
|
@ -53,11 +53,7 @@ internal class TransactionParserContext {
|
|||||||
throw new Exception("Mission accepted without knowing where.");
|
throw new Exception("Mission accepted without knowing where.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accepted.Mission == null) {
|
AcceptedMissions.TryAdd(accepted.MissionID, accepted);
|
||||||
throw new Exception("Mission is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
AcceptedMissions.TryAdd(accepted.Mission.MissionID, accepted);
|
|
||||||
|
|
||||||
Location location = new() {
|
Location location = new() {
|
||||||
StarSystem = CurrentSystem,
|
StarSystem = CurrentSystem,
|
||||||
@ -65,7 +61,7 @@ internal class TransactionParserContext {
|
|||||||
Station = (CurrentStation ?? ""),
|
Station = (CurrentStation ?? ""),
|
||||||
};
|
};
|
||||||
|
|
||||||
AcceptedMissionLocation.TryAdd(accepted.Mission.MissionID, location);
|
AcceptedMissionLocation.TryAdd(accepted.MissionID, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,34 +268,38 @@ internal class MissionAcceptedParser : TransactionParserPart {
|
|||||||
internal class MissionCompletedParser : TransactionParserPart {
|
internal class MissionCompletedParser : TransactionParserPart {
|
||||||
public void Parse(Entry e, TransactionParserContext context, TransactionList transactions) {
|
public void Parse(Entry e, TransactionParserContext context, TransactionList transactions) {
|
||||||
MissionCompletedEntry? entry = e as MissionCompletedEntry;
|
MissionCompletedEntry? entry = e as MissionCompletedEntry;
|
||||||
if (entry == null || entry.Mission == null) {
|
if (entry == null) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entry.MissionID == null) {
|
||||||
|
throw new InvalidJournalEntryException("mission completed has no mission ID");
|
||||||
|
}
|
||||||
|
|
||||||
MissionAcceptedEntry? accepted = null;
|
MissionAcceptedEntry? accepted = null;
|
||||||
Location? accepted_location = null;
|
Location? accepted_location = null;
|
||||||
string? target_faction_name = entry.Mission.TargetFaction;
|
string? target_faction_name = entry.TargetFaction;
|
||||||
string? source_faction_name = entry.Mission.Faction;
|
string? source_faction_name = entry.Faction;
|
||||||
|
|
||||||
// We did not find when the mission was accepted.
|
// We did not find when the mission was accepted.
|
||||||
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
|
if (!context.AcceptedMissions.TryGetValue(entry.MissionID.Value, out accepted)) {
|
||||||
transactions.AddIncomplete(new MissionCompleted(),
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
String.Format("Mission acceptance for mission id {0} was not found",
|
String.Format("Mission acceptance for mission id {0} was not found",
|
||||||
entry.Mission.MissionID));
|
entry.MissionID.Value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
|
if (!context.AcceptedMissionLocation.TryGetValue(entry.MissionID.Value, out accepted_location)) {
|
||||||
transactions.AddIncomplete(new MissionCompleted(),
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
String.Format("Location for acceptance for mission id {0} was not found",
|
String.Format("Location for acceptance for mission id {0} was not found",
|
||||||
entry.Mission.MissionID));
|
entry.MissionID.Value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This block does some preliminary "repairs" on the influences block of a completed
|
// This block does some preliminary "repairs" on the influences block of a completed
|
||||||
// mission. Sometimes these entries are broken, or are missing information for later
|
// mission. Sometimes these entries are broken, or are missing information for later
|
||||||
// parsing.
|
// parsing.
|
||||||
foreach (var other in entry.Mission.Influences) {
|
foreach (var other in entry.Influences) {
|
||||||
string faction = other.Key;
|
string faction = other.Key;
|
||||||
if (string.IsNullOrEmpty(faction)) {
|
if (string.IsNullOrEmpty(faction)) {
|
||||||
// Target faction might be empty string, in special cases. For example if you
|
// Target faction might be empty string, in special cases. For example if you
|
||||||
@ -385,18 +385,14 @@ internal class MissionFailedParser : TransactionParserPart {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.Mission == null) {
|
if (!context.AcceptedMissions.TryGetValue(entry.MissionID, out accepted)) {
|
||||||
throw new InvalidJournalEntryException("No mission specified in mission failure");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
|
|
||||||
transactions.AddIncomplete(new MissionFailed(),
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
"Mission acceptance was not found"
|
"Mission acceptance was not found"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
|
if (!context.AcceptedMissionLocation.TryGetValue(entry.MissionID, out accepted_location)) {
|
||||||
transactions.AddIncomplete(new MissionFailed(),
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
"Unable to figure out where failed mission was accepted"
|
"Unable to figure out where failed mission was accepted"
|
||||||
);
|
);
|
||||||
@ -412,7 +408,7 @@ internal class MissionFailedParser : TransactionParserPart {
|
|||||||
|
|
||||||
transactions.Add(new MissionFailed() {
|
transactions.Add(new MissionFailed() {
|
||||||
Accepted = accepted,
|
Accepted = accepted,
|
||||||
Faction = accepted.Mission?.Faction,
|
Faction = accepted.Faction,
|
||||||
Failed = entry,
|
Failed = entry,
|
||||||
Station = accepted_location.Station,
|
Station = accepted_location.Station,
|
||||||
System = accepted_location.StarSystem,
|
System = accepted_location.StarSystem,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace EDPlayerJournal.Entries;
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
@ -56,14 +55,11 @@ public class Entry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Entry? Parse(string journalline) {
|
public static Entry? Parse(string journalline) {
|
||||||
using (JsonReader reader = new JsonTextReader(new StringReader(journalline))) {
|
var json = JObject.Parse(journalline);
|
||||||
reader.DateParseHandling = DateParseHandling.None;
|
if (json == null) {
|
||||||
var json = JObject.Load(reader);
|
return null;
|
||||||
if (json == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Parse(json);
|
|
||||||
}
|
}
|
||||||
|
return Parse(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entry? Parse(JObject json) {
|
public static Entry? Parse(JObject json) {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
namespace EDPlayerJournal.Entries;
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
public class MissionAbandonedEntry : Entry {
|
public class MissionAbandonedEntry : Entry {
|
||||||
public Mission? Mission { get; set; }
|
public ulong MissionID { get; set; }
|
||||||
|
|
||||||
protected override void Initialise() {
|
protected override void Initialise() {
|
||||||
Mission = Mission.FromMissionAbandoned(JSON);
|
MissionID = JSON.Value<ulong?>("MissionID") ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,22 @@
|
|||||||
namespace EDPlayerJournal.Entries;
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
public class MissionAcceptedEntry : Entry {
|
public class MissionAcceptedEntry : Entry {
|
||||||
public Mission? Mission { get; set; }
|
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; }
|
||||||
|
|
||||||
protected override void Initialise() {
|
protected override void Initialise() {
|
||||||
Mission = Mission.FromMissionAccepted(JSON);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,159 @@
|
|||||||
namespace EDPlayerJournal.Entries;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
public class MissionCompletedEntry : Entry {
|
public class MissionCompletedEntry : Entry {
|
||||||
public Mission? Mission { get; set; }
|
public Dictionary<string, Dictionary<ulong, string>> Influences { get; set; } = new Dictionary<string, Dictionary<ulong, string>>();
|
||||||
|
private List<string> Affected { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
private string? readable_name = null;
|
||||||
|
private bool readable_name_generated = false;
|
||||||
|
|
||||||
protected override void Initialise() {
|
protected override void Initialise() {
|
||||||
Mission = Mission.FromMissionCompleted(JSON);
|
MissionID = JSON.Value<ulong?>("MissionID") ?? 0;
|
||||||
|
Name = JSON.Value<string>("Name");
|
||||||
|
Faction = JSON.Value<string>("Faction") ?? "";
|
||||||
|
TargetFaction = JSON.Value<string>("TargetFaction") ?? "";
|
||||||
|
if (JSON.ContainsKey("Commodity_Localised")) {
|
||||||
|
Commodity = JSON.Value<string>("Commodity_Localised");
|
||||||
|
}
|
||||||
|
if (JSON.ContainsKey("Count")) {
|
||||||
|
Count = JSON.Value<int>("Count");
|
||||||
|
}
|
||||||
|
if (JSON.ContainsKey("Donated")) {
|
||||||
|
Donated = JSON.Value<int>("Donated");
|
||||||
|
}
|
||||||
|
|
||||||
|
MakeHumanReadableName();
|
||||||
|
BuildInfluenceList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildInfluenceList() {
|
||||||
|
Influences.Clear();
|
||||||
|
Affected.Clear();
|
||||||
|
|
||||||
|
var effects = JSON.Value<JArray>("FactionEffects");
|
||||||
|
if (effects == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var effect in effects.Children<JObject>()) {
|
||||||
|
string? faction = effect.Value<string>("Faction");
|
||||||
|
|
||||||
|
if (faction == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Affected.Add(faction);
|
||||||
|
|
||||||
|
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, new Dictionary<ulong, string>());
|
||||||
|
} else {
|
||||||
|
foreach (var infl in influence.Children<JObject>()) {
|
||||||
|
infl.TryGetValue("Influence", out JToken? result);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? Commodity { get; set; }
|
||||||
|
public int? Count { get; set; }
|
||||||
|
public int? Donated { get; set; }
|
||||||
|
public ulong? MissionID { get; set; }
|
||||||
|
public string? Faction { get; set; }
|
||||||
|
public string? TargetFaction { get; set; }
|
||||||
|
|
||||||
|
private void MakeHumanReadableName() {
|
||||||
|
if (readable_name != null || Name == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? readable = HumanReadableMissionName.MakeHumanReadableName(Name);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (readable == null) {
|
||||||
|
builder = new StringBuilder(Name);
|
||||||
|
builder.Replace("Mission_", "");
|
||||||
|
builder.Replace("_name", "");
|
||||||
|
builder.Replace("_MB", "");
|
||||||
|
builder.Replace('_', ' ');
|
||||||
|
builder.Replace("Illegal", " (Illegal)");
|
||||||
|
builder.Replace("OnFoot", "On Foot");
|
||||||
|
builder.Replace(" BS", "");
|
||||||
|
builder.Replace("HackMegaship", "Hack Megaship");
|
||||||
|
builder.Replace("Boom", "");
|
||||||
|
builder.Replace("RebootRestore", "Reboot/Restore");
|
||||||
|
builder.Replace("CivilLiberty", "");
|
||||||
|
readable_name_generated = true;
|
||||||
|
} else {
|
||||||
|
builder.Append(readable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Count > 0 && Commodity != null) {
|
||||||
|
builder.AppendFormat(" ({0} {1})", Count, Commodity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Donated != null || Donated > 0) {
|
||||||
|
builder.AppendFormat(" ({0})", Credits.FormatCredits(Donated ?? 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
readable_name = builder.ToString().Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? HumanReadableName {
|
||||||
|
get {
|
||||||
|
MakeHumanReadableName();
|
||||||
|
return readable_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HumanReadableNameWasGenerated {
|
||||||
|
get {
|
||||||
|
MakeHumanReadableName();
|
||||||
|
return readable_name_generated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] AffectedFactions => Affected.ToArray();
|
||||||
|
|
||||||
|
public string? GetInfluenceForFaction(string faction) {
|
||||||
|
if (Influences == null || !Influences.ContainsKey(faction)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var inf = Influences[faction];
|
||||||
|
return string.Join("", inf.Values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? GetInfluenceForFaction(string faction, ulong systemaddr) {
|
||||||
|
if (!Influences.ContainsKey(faction)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Influences[faction].ContainsKey(systemaddr)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Influences[faction][systemaddr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
namespace EDPlayerJournal.Entries;
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
public class MissionFailedEntry : Entry {
|
public class MissionFailedEntry : Entry {
|
||||||
/// <summary>
|
public string? Name { get; set; }
|
||||||
/// Fine imposed for mission failure.
|
public ulong MissionID { get; set; }
|
||||||
/// </summary>
|
|
||||||
public int Fine { get; set; }
|
public int Fine { get; set; }
|
||||||
|
|
||||||
public Mission? Mission { get; set; }
|
public string? HumanReadableName {
|
||||||
|
get {
|
||||||
|
if (Name == null) return null;
|
||||||
|
return HumanReadableMissionName.MakeHumanReadableName(Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Initialise() {
|
protected override void Initialise() {
|
||||||
Mission = Mission.FromMissionFailed(JSON);
|
Name = JSON.Value<string>("Name");
|
||||||
|
MissionID = JSON.Value<ulong?>("MissionID") ?? 0;
|
||||||
Fine = JSON.Value<int?>("Fine") ?? 0;
|
Fine = JSON.Value<int?>("Fine") ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,373 +0,0 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using EDPlayerJournal.Entries;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
namespace EDPlayerJournal;
|
|
||||||
|
|
||||||
public class FactionEffect {
|
|
||||||
public string? Effect { get; set; }
|
|
||||||
public string? EffectLocalised { get; set; }
|
|
||||||
public string? Trend { get; set; }
|
|
||||||
|
|
||||||
public static FactionEffect FromJSON(JObject obj) {
|
|
||||||
FactionEffect effect = new FactionEffect();
|
|
||||||
|
|
||||||
effect.Effect = obj.Value<string?>("Effect");
|
|
||||||
effect.EffectLocalised = obj.Value<string?>("Effect_Localised");
|
|
||||||
effect.Trend = obj.Value<string?>("Trend");
|
|
||||||
|
|
||||||
return effect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MissionInfluence {
|
|
||||||
/// <summary>
|
|
||||||
/// System Address this influence happened in.
|
|
||||||
/// </summary>
|
|
||||||
public ulong? SystemAddress { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generic description of the trend (up or down)
|
|
||||||
/// </summary>
|
|
||||||
public string? Trend { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Influence gained in plusses
|
|
||||||
/// </summary>
|
|
||||||
public string Influence { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public static MissionInfluence FromJSON(JObject obj) {
|
|
||||||
MissionInfluence missionInfluence = new MissionInfluence();
|
|
||||||
|
|
||||||
missionInfluence.SystemAddress = obj.Value<ulong?>("SystemAddress");
|
|
||||||
missionInfluence.Trend = obj.Value<string?>("Trend");
|
|
||||||
missionInfluence.Influence = obj.Value<string?>("Influence") ?? "";
|
|
||||||
|
|
||||||
return missionInfluence;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MissionFactionEffects {
|
|
||||||
/// <summary>
|
|
||||||
/// Faction in question
|
|
||||||
/// </summary>
|
|
||||||
public string? Faction { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reputation trend
|
|
||||||
/// </summary>
|
|
||||||
public string? ReputationTrend { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reputation in pluses.
|
|
||||||
/// </summary>
|
|
||||||
public string Reputation { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of economic and security affects.
|
|
||||||
/// </summary>
|
|
||||||
public List<FactionEffect> Effects { get; set; } = new List<FactionEffect>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Influence gained.
|
|
||||||
/// </summary>
|
|
||||||
public List<MissionInfluence> Influences { get; set; } = new List<MissionInfluence>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether this affect is for an empty, or non-existant faction.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsEmptyFaction {
|
|
||||||
get { return string.IsNullOrEmpty(Faction); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MissionFactionEffects FromJSON(JObject j) {
|
|
||||||
MissionFactionEffects o = new MissionFactionEffects();
|
|
||||||
|
|
||||||
o.Faction = j.Value<string>("Faction");
|
|
||||||
|
|
||||||
o.ReputationTrend = j.Value<string?>("ReputationTrend");
|
|
||||||
o.Reputation = j.Value<string?>("Reputation") ?? string.Empty;
|
|
||||||
|
|
||||||
JArray? effects = j.Value<JArray?>("Effects");
|
|
||||||
if (effects != null) {
|
|
||||||
foreach (JObject effect in effects.Children().OfType<JObject>()) {
|
|
||||||
FactionEffect e = FactionEffect.FromJSON(effect);
|
|
||||||
o.Effects.Add(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JArray? influences = j.Value<JArray?>("Influence");
|
|
||||||
if (influences != null) {
|
|
||||||
foreach (JObject influence in influences.Children().OfType<JObject>()) {
|
|
||||||
MissionInfluence missionInfluence = MissionInfluence.FromJSON(influence);
|
|
||||||
o.Influences.Add(missionInfluence);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Affect this mission had on factions.
|
|
||||||
/// </summary>
|
|
||||||
public List<MissionFactionEffects> FactionEffects { get; set; } = new List<MissionFactionEffects>();
|
|
||||||
|
|
||||||
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.TargetFaction = o.Value<string?>("TargetFaction");
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
JArray? factionEffects = o.Value<JArray?>("FactionEffects");
|
|
||||||
if (factionEffects != null) {
|
|
||||||
foreach (JObject effect in factionEffects.Children().OfType<JObject>()) {
|
|
||||||
MissionFactionEffects factionEffect = MissionFactionEffects.FromJSON(effect);
|
|
||||||
mission.FactionEffects.Add(factionEffect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mission;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of all affected factions.
|
|
||||||
/// </summary>
|
|
||||||
public string[] AffectedFactions {
|
|
||||||
get {
|
|
||||||
return FactionEffects
|
|
||||||
.Where(x => !string.IsNullOrEmpty(x.Faction))
|
|
||||||
.Select(x => (x.Faction ?? string.Empty))
|
|
||||||
.ToArray()
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the influence for a given faction in a given star system.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="faction">Faction name in question.</param>
|
|
||||||
/// <param name="systemaddr">Star System address</param>
|
|
||||||
/// <returns>null if no entry was found, or a string denoting pluses for the amount influence gained.</returns>
|
|
||||||
public string? GetInfluenceForFaction(string faction, ulong systemaddr) {
|
|
||||||
var results = FactionEffects
|
|
||||||
.Where(x => string.Compare(x.Faction, faction) == 0)
|
|
||||||
.SelectMany(x => x.Influences)
|
|
||||||
.Where(x => (x.SystemAddress != null && x.SystemAddress == systemaddr))
|
|
||||||
.Select(x => x.Influence)
|
|
||||||
.ToArray()
|
|
||||||
;
|
|
||||||
|
|
||||||
if (results == null || results.Length == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Join("", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A convenient Dictionary containing all influences given out by faction,
|
|
||||||
/// then by system address and then by influence handed out.
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<string, Dictionary<ulong, string>> Influences {
|
|
||||||
get {
|
|
||||||
return FactionEffects
|
|
||||||
.Where(x => x.Faction != null)
|
|
||||||
.ToDictionary(
|
|
||||||
x => (x.Faction ?? string.Empty),
|
|
||||||
x => x.Influences
|
|
||||||
.Where(x => x.SystemAddress != null)
|
|
||||||
.ToDictionary(x => (x.SystemAddress ?? 0), x => x.Influence)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mission FromMissionAccepted(JObject o) {
|
|
||||||
return FromJSON(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mission FromMissionAbandoned(JObject o) {
|
|
||||||
return FromJSON(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mission FromMissionFailed(JObject o) {
|
|
||||||
return FromJSON(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mission FromMissionCompleted(JObject o) {
|
|
||||||
return FromJSON(o);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
using EDPlayerJournal;
|
|
||||||
using EDPlayerJournal.Entries;
|
|
||||||
using System.Diagnostics.Metrics;
|
|
||||||
|
|
||||||
namespace EDPlayerJournalTests;
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class MissionTest {
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMissionAccepted() {
|
|
||||||
string altruism = /*lang=json,strict*/ """{ "timestamp":"2022-11-23T08:05:54Z", "event":"MissionAccepted", "Faction":"HIP 6182 Federal Inc", "Name":"Mission_AltruismCredits", "LocalisedName":"Donate 1,000,000 Cr to the cause", "Donation":"1000000", "Expiry":"2022-11-23T11:50:52Z", "Wing":false, "Influence":"++", "Reputation":"++", "MissionID":901601358 }""";
|
|
||||||
|
|
||||||
Entry? entry = Entry.Parse(altruism);
|
|
||||||
|
|
||||||
Assert.IsNotNull(entry);
|
|
||||||
Assert.IsInstanceOfType(entry, typeof(MissionAcceptedEntry));
|
|
||||||
|
|
||||||
MissionAcceptedEntry? accepted = entry as MissionAcceptedEntry;
|
|
||||||
|
|
||||||
Assert.IsNotNull(accepted);
|
|
||||||
Assert.IsNotNull(accepted.Mission);
|
|
||||||
|
|
||||||
Assert.AreEqual(accepted.Mission.MissionID, 901601358UL);
|
|
||||||
Assert.AreEqual(accepted.Mission.Faction, "HIP 6182 Federal Inc");
|
|
||||||
Assert.AreEqual(accepted.Mission.Name, "Mission_AltruismCredits");
|
|
||||||
Assert.AreEqual(accepted.Mission.LocalisedName, "Donate 1,000,000 Cr to the cause");
|
|
||||||
Assert.AreEqual(accepted.Mission.Donation, 1000000UL);
|
|
||||||
Assert.AreEqual(accepted.Mission.Expiry, "2022-11-23T11:50:52Z");
|
|
||||||
Assert.AreEqual(accepted.Mission.Wing, false);
|
|
||||||
Assert.AreEqual(accepted.Mission.Reputation, "++");
|
|
||||||
Assert.AreEqual(accepted.Mission.Influence, "++");
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void NoInfluence() {
|
|
||||||
string noinfluence = """{ "timestamp":"2022-02-24T19:42:38Z", "event":"MissionCompleted", "Faction":"Social LHS 6103 Confederation", "Name":"Mission_Hack_BLOPS_Elections_name", "MissionID":849749964, "NewDestinationSystem":"Dewikum", "DestinationSystem":"LF 8 +16 41", "Target":"$MissionUtil_Settlement_Target_PostBox;", "Target_Localised":"Hub Access Terminal", "Reward":14266, "FactionEffects":[ { "Faction":"", "Effects":[ { "Effect":"$MISSIONUTIL_Interaction_Summary_EP_down;", "Effect_Localised":"The economic status of $#MinorFaction; has declined in the $#System; system.", "Trend":"DownBad" } ], "Influence":[ { "SystemAddress":251012319587, "Trend":"DownBad", "Influence":"+" } ], "ReputationTrend":"DownBad", "Reputation":"+" }, { "Faction":"Social LHS 6103 Confederation", "Effects":[ ], "Influence":[ ], "ReputationTrend":"UpGood", "Reputation":"+" } ] }""";
|
|
||||||
|
|
||||||
Entry? entry = Entry.Parse(noinfluence);
|
|
||||||
|
|
||||||
Assert.IsNotNull(entry);
|
|
||||||
Assert.IsInstanceOfType(entry, typeof(MissionCompletedEntry));
|
|
||||||
|
|
||||||
MissionCompletedEntry? completed = entry as MissionCompletedEntry;
|
|
||||||
|
|
||||||
Assert.IsNotNull(completed);
|
|
||||||
Assert.IsNotNull(completed.Mission);
|
|
||||||
|
|
||||||
Mission m = completed.Mission;
|
|
||||||
|
|
||||||
Assert.AreEqual(m.FactionEffects.Count, 2);
|
|
||||||
|
|
||||||
// Empty faction should not count towards affected factions
|
|
||||||
Assert.AreEqual(m.AffectedFactions.Length, 1);
|
|
||||||
|
|
||||||
MissionFactionEffects e;
|
|
||||||
|
|
||||||
e = m.FactionEffects[0];
|
|
||||||
Assert.IsTrue(e.IsEmptyFaction);
|
|
||||||
Assert.AreEqual(e.Faction, string.Empty);
|
|
||||||
|
|
||||||
string? influence = m.GetInfluenceForFaction("", 251012319587UL);
|
|
||||||
Assert.IsNotNull(influence);
|
|
||||||
Assert.AreEqual(influence, "+");
|
|
||||||
|
|
||||||
e = m.FactionEffects[1];
|
|
||||||
Assert.AreEqual(e.Faction, "Social LHS 6103 Confederation");
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMissionCompleted() {
|
|
||||||
string courier = /*lang=json,strict*/ """{ "timestamp":"2022-11-21T16:14:33Z", "event":"MissionCompleted", "Faction":"Salus Imperial Society", "Name":"Mission_Courier_Elections_name", "MissionID":901326396, "TargetFaction":"Salus Imperial Society", "DestinationSystem":"Saelishi", "DestinationStation":"Serrao Arsenal", "Reward":87404, "FactionEffects":[ { "Faction":"Salus Imperial Society", "Effects":[ { "Effect":"$MISSIONUTIL_Interaction_Summary_EP_up;", "Effect_Localised":"The economic status of $#MinorFaction; has improved in the $#System; system.", "Trend":"UpGood" }, { "Effect":"$MISSIONUTIL_Interaction_Summary_EP_up;", "Effect_Localised":"The economic status of $#MinorFaction; has improved in the $#System; system.", "Trend":"UpGood" } ], "Influence":[ { "SystemAddress":1865919973739, "Trend":"UpGood", "Influence":"++" }, { "SystemAddress":1733186884306, "Trend":"UpGood", "Influence":"++" } ], "ReputationTrend":"UpGood", "Reputation":"++" } ] }""";
|
|
||||||
|
|
||||||
Entry? entry = Entry.Parse(courier);
|
|
||||||
|
|
||||||
Assert.IsNotNull(entry);
|
|
||||||
Assert.IsInstanceOfType(entry, typeof(MissionCompletedEntry));
|
|
||||||
|
|
||||||
MissionCompletedEntry? completed = entry as MissionCompletedEntry;
|
|
||||||
|
|
||||||
Assert.IsNotNull(completed);
|
|
||||||
Assert.IsNotNull(completed.Mission);
|
|
||||||
|
|
||||||
Mission m = completed.Mission;
|
|
||||||
|
|
||||||
Assert.AreEqual(m.Faction, "Salus Imperial Society");
|
|
||||||
Assert.AreEqual(m.Name, "Mission_Courier_Elections_name");
|
|
||||||
Assert.AreEqual(m.MissionID, 901326396UL);
|
|
||||||
Assert.AreEqual(m.TargetFaction, "Salus Imperial Society");
|
|
||||||
Assert.AreEqual(m.DestinationSystem, "Saelishi");
|
|
||||||
Assert.AreEqual(m.DestinationStation, "Serrao Arsenal");
|
|
||||||
Assert.IsNull(m.DestinationSettlement);
|
|
||||||
Assert.AreEqual(m.Reward, 87404UL);
|
|
||||||
|
|
||||||
Assert.AreEqual(m.FactionEffects.Count, 1);
|
|
||||||
|
|
||||||
var effect = m.FactionEffects[0];
|
|
||||||
|
|
||||||
Assert.AreEqual(effect.Influences.Count, 2);
|
|
||||||
Assert.AreEqual(effect.Effects.Count, 2);
|
|
||||||
|
|
||||||
Assert.AreEqual(effect.Reputation, "++");
|
|
||||||
|
|
||||||
string? influence;
|
|
||||||
|
|
||||||
influence = m.GetInfluenceForFaction("Salus Imperial Society", 1865919973739UL);
|
|
||||||
Assert.AreEqual(influence, "++");
|
|
||||||
|
|
||||||
influence = m.GetInfluenceForFaction("Salus Imperial Society", 1733186884306UL);
|
|
||||||
Assert.AreEqual(influence, "++");
|
|
||||||
|
|
||||||
influence = m.GetInfluenceForFaction("Saelishi Saxons", 1733186884306UL);
|
|
||||||
Assert.IsNull(influence);
|
|
||||||
|
|
||||||
// Only one entry are we only have Salus
|
|
||||||
Assert.AreEqual(m.Influences.Count, 1);
|
|
||||||
Assert.AreEqual(m.Influences["Salus Imperial Society"].Count, 2);
|
|
||||||
Assert.AreEqual(m.Influences["Salus Imperial Society"][1865919973739UL], "++");
|
|
||||||
Assert.AreEqual(m.Influences["Salus Imperial Society"][1733186884306UL], "++");
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,23 +7,28 @@ namespace EDPlayerJournalTests;
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class TestTransactionParser {
|
public class TestTransactionParser {
|
||||||
private List<Entry>? LoadTestData(string filename) {
|
private List<Entry>? LoadTestData(string filename) {
|
||||||
string path = Path.GetFullPath("./" + filename);
|
try {
|
||||||
string[] lines = File.ReadAllLines(path);
|
string path = Path.GetFullPath("./" + filename);
|
||||||
List<Entry> entries = new();
|
string[] lines = File.ReadAllLines(path);
|
||||||
|
List<Entry> entries = new();
|
||||||
|
|
||||||
foreach (string line in lines) {
|
foreach (string line in lines) {
|
||||||
line.Trim();
|
line.Trim();
|
||||||
if (string.IsNullOrEmpty(line)) {
|
if (string.IsNullOrEmpty(line)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry? entry = Entry.Parse(line);
|
||||||
|
if (entry != null) {
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry? entry = Entry.Parse(line);
|
return entries;
|
||||||
if (entry != null) {
|
} catch (Exception) {
|
||||||
entries.Add(entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user