add code to detect which captain/correspondent it was
This commit is contained in:
parent
6b09ec4db3
commit
f490d4ba4d
65
EDPlayerJournal/BGS/Parsers/ShipTargetedParser.cs
Normal file
65
EDPlayerJournal/BGS/Parsers/ShipTargetedParser.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -137,41 +137,6 @@ internal class DockedParser : ITransactionParserPart {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Commit crime can result in a transaction, especially if the crime committed is
|
||||
/// murder.
|
||||
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 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<bool>() { HaveSeenCaptain, HaveSeenCorrespondent, HaveSeenSpecOps }
|
||||
.Where(x => x == true)
|
||||
.Count()
|
||||
;
|
||||
int warzoneNpcs = new List<bool>() {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user