diff --git a/BGS/FoulMurder.cs b/BGS/FoulMurder.cs new file mode 100644 index 0000000..db825af --- /dev/null +++ b/BGS/FoulMurder.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EDJournal; + +namespace EliteBGS.BGS { + /// + /// 36 Lessons of Vivec, Lesson 36 + /// + public class FoulMurder : LogEntry { + public FoulMurder (CommitCrimeEntry e) { + Entries.Add(e); + } + + public string CrimeType { + get { return Entries.OfType().First().CrimeType; } + } + + public long Bounties => Entries.OfType().Sum(x => x.Bounty); + + public long Fines => Entries.OfType().Sum(x => x.Fine); + + public override int CompareTo(LogEntry other) { + if (other == null || other.GetType() != typeof(FoulMurder)) { + return -1; + } + + FoulMurder hortator = other as FoulMurder; + + if (Faction == other.Faction && CrimeType == hortator.CrimeType) { + return 0; + } + + return -1; + } + + public override string ToString() { + StringBuilder builder = new StringBuilder(); + string type; + + if (CrimeType == CrimeTypes.Murder) { + if (Entries.Count > 1) { + type = "ships"; + } else { + type = "ship"; + } + } else { + if (Entries.Count > 1) { + type = "people"; + } else { + type = "person"; + } + } + + builder.AppendFormat("Murdered {0} {1} of {2} (Bounties: {3}, Fines: {4})", + Entries.Count, + type, + Faction, + Credits.FormatCredits(Bounties), + Credits.FormatCredits(Fines) + ); + + return builder.ToString(); + } + } +} diff --git a/BGS/GenericDiscordLog.cs b/BGS/GenericDiscordLog.cs index fce520c..96e265a 100644 --- a/BGS/GenericDiscordLog.cs +++ b/BGS/GenericDiscordLog.cs @@ -203,6 +203,24 @@ namespace EliteBGS.BGS { return builder.ToString(); } + private string BuildMurders(Objective objective) { + FoulMurder[] murders = objective.LogEntries.OfType().ToArray(); + StringBuilder builder = new StringBuilder(); + + if (murders.Length <= 0) { + return ""; + } + + foreach (FoulMurder murder in murders) { + builder.Append(murder.ToString()); + builder.Append("\n"); + } + + builder.Append("\n"); + + return builder.ToString(); + } + public string GenerateDiscordLog(Report report) { StringBuilder log = new StringBuilder(); @@ -229,6 +247,9 @@ namespace EliteBGS.BGS { var failed = BuildFailedMissions(objective); entries.Append(failed); + var murders = BuildMurders(objective); + entries.Append(murders); + var vouchers = BuildVouchers(objective); entries.Append(vouchers); diff --git a/BGS/NonaDiscordLog.cs b/BGS/NonaDiscordLog.cs index 673738a..2a86d93 100644 --- a/BGS/NonaDiscordLog.cs +++ b/BGS/NonaDiscordLog.cs @@ -253,6 +253,24 @@ namespace EliteBGS.BGS { return builder.ToString(); } + private string BuildMurders(Objective objective) { + FoulMurder[] murders = objective.LogEntries.OfType().ToArray(); + StringBuilder builder = new StringBuilder(); + + if (murders.Length <= 0) { + return ""; + } + + foreach (FoulMurder murder in murders) { + builder.Append(murder.ToString()); + builder.Append("\n"); + } + + builder.Append("\n"); + + return builder.ToString(); + } + public string GenerateDiscordLog(Report report) { StringBuilder log = new StringBuilder(); @@ -278,6 +296,9 @@ namespace EliteBGS.BGS { var failed = BuildFailedMissions(objective); entries.Append(failed); + var murders = BuildMurders(objective); + entries.Append(murders); + var vouchers = BuildVouchers(objective); entries.Append(vouchers); diff --git a/BGS/Report.cs b/BGS/Report.cs index 5ebdba4..453a252 100644 --- a/BGS/Report.cs +++ b/BGS/Report.cs @@ -41,7 +41,8 @@ namespace EliteBGS.BGS { e.Is(Events.RedeemVoucher) || e.Is(Events.FactionKillBond) || e.Is(Events.MarketBuy) || - e.Is(Events.MarketSell) + e.Is(Events.MarketSell) || + e.Is(Events.CommitCrime) ; } @@ -96,6 +97,19 @@ namespace EliteBGS.BGS { if (!string.IsNullOrEmpty(location.StationName)) { current_station = location.StationName; } + } else if (e.Is(Events.CommitCrime)) { + CommitCrimeEntry crime = e as CommitCrimeEntry; + + if (!crime.IsMurder) { + /* we don't care about anything but murder for now */ + continue; + } + + results.Add(new FoulMurder(crime) { + System = current_system, + Faction = crime.Faction, + }); + collate = true; } else if (e.Is(Events.MissionCompleted)) { var completed = e as MissionCompletedEntry; results.Add(new MissionCompleted(completed) { diff --git a/EliteBGS.csproj b/EliteBGS.csproj index 023c2c6..211a1f5 100644 --- a/EliteBGS.csproj +++ b/EliteBGS.csproj @@ -82,6 +82,7 @@ AdjustProfitWindow.xaml +