improve murder detection
This commit is contained in:
@@ -29,22 +29,23 @@ namespace EliteBGS.BGS {
|
||||
}
|
||||
|
||||
private bool IsRelevant(Entry e) {
|
||||
return e.Is(Events.MissionCompleted) ||
|
||||
e.Is(Events.MissionFailed) ||
|
||||
e.Is(Events.MissionAccepted) ||
|
||||
return e.Is(Events.CommitCrime) ||
|
||||
e.Is(Events.Docked) ||
|
||||
e.Is(Events.FactionKillBond) ||
|
||||
e.Is(Events.FSDJump) ||
|
||||
e.Is(Events.Location) ||
|
||||
e.Is(Events.MarketBuy) ||
|
||||
e.Is(Events.MarketSell) ||
|
||||
e.Is(Events.MissionAccepted) ||
|
||||
e.Is(Events.MissionFailed) ||
|
||||
e.Is(Events.MultiSellExplorationData) ||
|
||||
e.Is(Events.RedeemVoucher) ||
|
||||
e.Is(Events.SearchAndRescue) ||
|
||||
e.Is(Events.SellExplorationData) ||
|
||||
e.Is(Events.SellMicroResources) ||
|
||||
e.Is(Events.SellOrganicData) ||
|
||||
e.Is(Events.RedeemVoucher) ||
|
||||
e.Is(Events.FactionKillBond) ||
|
||||
e.Is(Events.MarketBuy) ||
|
||||
e.Is(Events.MarketSell) ||
|
||||
e.Is(Events.CommitCrime)
|
||||
e.Is(Events.ShipTargeted) ||
|
||||
e.Is(Events.MissionCompleted)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -61,10 +62,15 @@ namespace EliteBGS.BGS {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Entry> relevant = entries.Where(x => IsRelevant(x)).ToList();
|
||||
List<Entry> relevant = entries
|
||||
.Where(x => IsRelevant(x))
|
||||
.ToList()
|
||||
;
|
||||
|
||||
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
||||
Dictionary<string, long> buyCost = new Dictionary<string, long>();
|
||||
Dictionary<ulong, string> systems = new Dictionary<ulong, string>();
|
||||
Dictionary<string, string> npcfactions = new Dictionary<string, string>();
|
||||
|
||||
string current_system = null;
|
||||
ulong current_system_address = 0;
|
||||
@@ -73,7 +79,7 @@ namespace EliteBGS.BGS {
|
||||
|
||||
objectives.ForEach(x => x.Clear());
|
||||
|
||||
foreach (var e in relevant) {
|
||||
foreach (Entry e in relevant) {
|
||||
List<LogEntry> results = new List<LogEntry>();
|
||||
bool collate = false;
|
||||
|
||||
@@ -118,17 +124,39 @@ namespace EliteBGS.BGS {
|
||||
if (!string.IsNullOrEmpty(location.StationName)) {
|
||||
current_station = location.StationName;
|
||||
}
|
||||
} else if (e.Is(Events.ShipTargeted)) {
|
||||
ShipTargetedEntry targeted = e as ShipTargetedEntry;
|
||||
|
||||
if (string.IsNullOrEmpty(targeted.PilotName) ||
|
||||
string.IsNullOrEmpty(targeted.Faction)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
npcfactions.Add(targeted.PilotName, targeted.Faction);
|
||||
} else if (e.Is(Events.CommitCrime)) {
|
||||
CommitCrimeEntry crime = e as CommitCrimeEntry;
|
||||
string faction = crime.Faction;
|
||||
|
||||
if (!crime.IsMurder) {
|
||||
/* we don't care about anything but murder for now */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!npcfactions.ContainsKey(crime.Victim)) {
|
||||
/* The faction in the crime report is the faction that issues the bounty,
|
||||
* and not the faction of the victim.
|
||||
*/
|
||||
OnLog?.Invoke(string.Format(
|
||||
"No faction found for victim \"{0}\", using faction that issued the bounty instead.",
|
||||
crime.Victim, crime.Faction
|
||||
));
|
||||
} else {
|
||||
faction = npcfactions[crime.Victim];
|
||||
}
|
||||
|
||||
results.Add(new FoulMurder(crime) {
|
||||
System = current_system,
|
||||
Faction = crime.Faction,
|
||||
Faction = faction,
|
||||
});
|
||||
collate = true;
|
||||
} else if (e.Is(Events.MissionCompleted)) {
|
||||
|
||||
Reference in New Issue
Block a user