diff --git a/EDPlayerJournal/BGS/Parsers/ShipTargetedParser.cs b/EDPlayerJournal/BGS/Parsers/ShipTargetedParser.cs
new file mode 100644
index 0000000..7463b3e
--- /dev/null
+++ b/EDPlayerJournal/BGS/Parsers/ShipTargetedParser.cs
@@ -0,0 +1,65 @@
+using EDPlayerJournal.Entries;
+
+namespace EDPlayerJournal.BGS;
+
+///
+/// With ship targeted we might find out to which faction a given NPC belonged. This is
+/// useful later when said NPC gets killed or murdered.
+///
+internal class ShipTargetedParser : ITransactionParserPart {
+ public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
+ ShipTargetedEntry? entry = e as ShipTargetedEntry;
+ if (entry == null) {
+ throw new NotImplementedException();
+ }
+
+ // Scan happens in stages, and sometimes this information is not known
+ // yet. Do now throw an error, this is expected behaviour.
+ if (!string.IsNullOrEmpty(entry.PilotNameLocalised) &&
+ !string.IsNullOrEmpty(entry.Faction)) {
+ context.NPCFaction.TryAdd(entry.PilotNameLocalised, entry.Faction);
+ }
+
+ string? faction = context.LastRecordedAwardingFaction;
+
+ // We have seen a captain?
+ if (NPCs.IsWarzoneCaptain(entry.PilotName)) {
+ // if we have faction information, we can compare it to figure out
+ // whether it is the enemy or allied faction. but this is not always
+ // possible. In such a case we assume we have seen the enemy captain.
+ if (!string.IsNullOrEmpty(entry.Faction) &&
+ !string.IsNullOrEmpty(faction)) {
+ if (string.Compare(faction, entry.Faction) != 0) {
+ context.HaveSeenEnemyCaptain = true;
+ } else {
+ context.HaveSeenAlliedCaptain = true;
+ }
+ } else {
+ context.HaveSeenEnemyCaptain = true;
+ }
+ }
+
+ // Spec ops?
+ if (NPCs.IsSpecOps(entry.PilotName)) {
+ context.HaveSeenSpecOps = true;
+ }
+
+ // Correspondent?
+ if (NPCs.IsWarzoneCorrespondent(entry.PilotName)) {
+ // if we have faction information, we can compare it to figure out
+ // whether it is the enemy or allied faction. but this is not always
+ // possible. In such a case we assume we have seen the enemy
+ // correspondent.
+ if (!string.IsNullOrEmpty(entry.Faction) &&
+ !string.IsNullOrEmpty(faction)) {
+ if (string.Compare(faction, entry.Faction) != 0) {
+ context.HaveSeenEnemyCorrespondent = true;
+ } else {
+ context.HaveSeenAlliedCorrespondent = true;
+ }
+ } else {
+ context.HaveSeenEnemyCorrespondent = true;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/EDPlayerJournal/BGS/TransactionParser.cs b/EDPlayerJournal/BGS/TransactionParser.cs
index a6a3393..9064f85 100644
--- a/EDPlayerJournal/BGS/TransactionParser.cs
+++ b/EDPlayerJournal/BGS/TransactionParser.cs
@@ -137,41 +137,6 @@ internal class DockedParser : ITransactionParserPart {
}
}
-///
-/// With ship targeted we might find out to which faction a given NPC belonged. This is
-/// useful later when said NPC gets killed or murdered.
-///
-internal class ShipTargetedParser : ITransactionParserPart {
- public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
- ShipTargetedEntry? entry = e as ShipTargetedEntry;
- if (entry == null) {
- throw new NotImplementedException();
- }
-
- // Scan happens in stages, and sometimes this information is not known
- // yet. Do now throw an error, this is expected behaviour.
- if (!string.IsNullOrEmpty(entry.PilotNameLocalised) &&
- !string.IsNullOrEmpty(entry.Faction)) {
- context.NPCFaction.TryAdd(entry.PilotNameLocalised, entry.Faction);
- }
-
- // We have seen a captain?
- if (NPCs.IsWarzoneCaptain(entry.PilotName)) {
- context.HaveSeenCaptain = true;
- }
-
- // Spec ops?
- if (NPCs.IsSpecOps(entry.PilotName)) {
- context.HaveSeenSpecOps = true;
- }
-
- // Correspondent?
- if (NPCs.IsWarzoneCorrespondent(entry.PilotName)) {
- context.HaveSeenCorrespondent = true;
- }
- }
-}
-
///
/// Commit crime can result in a transaction, especially if the crime committed is
/// murder.
diff --git a/EDPlayerJournal/BGS/TransactionParserContext.cs b/EDPlayerJournal/BGS/TransactionParserContext.cs
index 0d64532..d7a7c50 100644
--- a/EDPlayerJournal/BGS/TransactionParserContext.cs
+++ b/EDPlayerJournal/BGS/TransactionParserContext.cs
@@ -51,9 +51,11 @@ internal class TransactionParserContext {
public ulong? HighestCombatBond { get; set; }
public bool HaveSeenCapShip { get; set; } = false;
- public bool HaveSeenCaptain { get; set; } = false;
+ public bool HaveSeenAlliedCaptain { get; set; } = false;
+ public bool HaveSeenEnemyCaptain { get; set; } = false;
public bool HaveSeenSpecOps { get; set; } = false;
- public bool HaveSeenCorrespondent { get; set; } = false;
+ public bool HaveSeenAlliedCorrespondent { get; set; } = false;
+ public bool HaveSeenEnemyCorrespondent { get; set; } = false;
///
/// Returns true if the current session is legacy
@@ -192,10 +194,14 @@ internal class TransactionParserContext {
if (HaveSeenCapShip) {
grade = CombatZones.DifficultyHigh;
} else {
- int warzoneNpcs = new List() { HaveSeenCaptain, HaveSeenCorrespondent, HaveSeenSpecOps }
- .Where(x => x == true)
- .Count()
- ;
+ int warzoneNpcs = new List() {
+ HaveSeenEnemyCaptain,
+ HaveSeenEnemyCorrespondent,
+ HaveSeenSpecOps
+ }
+ .Where(x => x == true)
+ .Count()
+ ;
if (warzoneNpcs >= 1 && grade == CombatZones.DifficultyLow) {
grade = CombatZones.DifficultyMedium;
@@ -222,8 +228,8 @@ internal class TransactionParserContext {
// Sad truth is, if HaveSeenXXX is false, we just don't know for certain
CapitalShip = HaveSeenCapShip ? true : null,
SpecOps = HaveSeenSpecOps ? true : null,
- EnemyCorrespondent = HaveSeenCorrespondent ? true : null,
- EnemyCaptain = HaveSeenCaptain ? true : null,
+ EnemyCorrespondent = HaveSeenEnemyCorrespondent ? true : null,
+ EnemyCaptain = HaveSeenEnemyCaptain ? true : null,
};
zone.Entries.Add(e);
transactions.Add(zone);
@@ -246,8 +252,10 @@ internal class TransactionParserContext {
public void ResetCombatZone() {
HighestCombatBond = null;
HaveSeenCapShip = false;
- HaveSeenCaptain = false;
- HaveSeenCorrespondent = false;
+ HaveSeenAlliedCaptain = false;
+ HaveSeenEnemyCaptain = false;
+ HaveSeenAlliedCorrespondent = false;
+ HaveSeenEnemyCorrespondent = false;
HaveSeenSpecOps = false;
LastRecordedAwardingFaction = null;
OnFootKills = 0;