From 6e5f8f504fd9926303f2e31b5bac8020620fe04b Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Sat, 26 Nov 2022 00:30:42 +0100 Subject: [PATCH] factions for onfoot murders are right there --- EDPlayerJournal/BGS/TransactionParser.cs | 30 +++++++++++++++------ EDPlayerJournal/Entries/CommitCrimeEntry.cs | 8 ++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/EDPlayerJournal/BGS/TransactionParser.cs b/EDPlayerJournal/BGS/TransactionParser.cs index 699b68c..317a7ca 100644 --- a/EDPlayerJournal/BGS/TransactionParser.cs +++ b/EDPlayerJournal/BGS/TransactionParser.cs @@ -319,15 +319,29 @@ internal class CommitCrimeParser : TransactionParserPart { victim = "Unknown"; } - if (!context.NPCFaction.ContainsKey(victim)) { - transactions.AddIncomplete( - new FoulMurder(), - "Crime victim was not properly scanned." - ); - return; - } + string faction; - string faction = context.NPCFaction[victim]; + if (entry.IsCrime(CrimeTypes.OnFootMurder)) { + if (entry.Faction == null) { + transactions.AddIncomplete( + new FoulMurder(), + "On foot murder victim did not have a faction" + ); + return; + } + // On foot murders are different, there the faction is + // the faction the NPC belonged too + faction = entry.Faction; + } else { + if (!context.NPCFaction.ContainsKey(victim)) { + transactions.AddIncomplete( + new FoulMurder(), + "Crime victim was not properly scanned." + ); + return; + } + faction = context.NPCFaction[victim]; + } transactions.Add(new FoulMurder(entry) { System = context.CurrentSystem, diff --git a/EDPlayerJournal/Entries/CommitCrimeEntry.cs b/EDPlayerJournal/Entries/CommitCrimeEntry.cs index 1bb5e16..d74178b 100644 --- a/EDPlayerJournal/Entries/CommitCrimeEntry.cs +++ b/EDPlayerJournal/Entries/CommitCrimeEntry.cs @@ -19,4 +19,12 @@ public class CommitCrimeEntry : Entry { public bool IsMurder { get { return CrimeType?.CompareTo(CrimeTypes.Murder) == 0 || CrimeType?.CompareTo(CrimeTypes.OnFootMurder) == 0; } } + + public bool IsCrime(string crimetype) { + if (CrimeType == null) { + return false; + } + + return string.Compare(CrimeType, crimetype) == 0; + } }