handle murders
This commit is contained in:
parent
8c7e67acc6
commit
30f8aa15f0
68
BGS/FoulMurder.cs
Normal file
68
BGS/FoulMurder.cs
Normal file
@ -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 {
|
||||||
|
/// <summary>
|
||||||
|
/// 36 Lessons of Vivec, Lesson 36
|
||||||
|
/// </summary>
|
||||||
|
public class FoulMurder : LogEntry {
|
||||||
|
public FoulMurder (CommitCrimeEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CrimeType {
|
||||||
|
get { return Entries.OfType<CommitCrimeEntry>().First().CrimeType; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Bounties => Entries.OfType<CommitCrimeEntry>().Sum(x => x.Bounty);
|
||||||
|
|
||||||
|
public long Fines => Entries.OfType<CommitCrimeEntry>().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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -203,6 +203,24 @@ namespace EliteBGS.BGS {
|
|||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string BuildMurders(Objective objective) {
|
||||||
|
FoulMurder[] murders = objective.LogEntries.OfType<FoulMurder>().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) {
|
public string GenerateDiscordLog(Report report) {
|
||||||
StringBuilder log = new StringBuilder();
|
StringBuilder log = new StringBuilder();
|
||||||
|
|
||||||
@ -229,6 +247,9 @@ namespace EliteBGS.BGS {
|
|||||||
var failed = BuildFailedMissions(objective);
|
var failed = BuildFailedMissions(objective);
|
||||||
entries.Append(failed);
|
entries.Append(failed);
|
||||||
|
|
||||||
|
var murders = BuildMurders(objective);
|
||||||
|
entries.Append(murders);
|
||||||
|
|
||||||
var vouchers = BuildVouchers(objective);
|
var vouchers = BuildVouchers(objective);
|
||||||
entries.Append(vouchers);
|
entries.Append(vouchers);
|
||||||
|
|
||||||
|
@ -253,6 +253,24 @@ namespace EliteBGS.BGS {
|
|||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string BuildMurders(Objective objective) {
|
||||||
|
FoulMurder[] murders = objective.LogEntries.OfType<FoulMurder>().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) {
|
public string GenerateDiscordLog(Report report) {
|
||||||
StringBuilder log = new StringBuilder();
|
StringBuilder log = new StringBuilder();
|
||||||
|
|
||||||
@ -278,6 +296,9 @@ namespace EliteBGS.BGS {
|
|||||||
var failed = BuildFailedMissions(objective);
|
var failed = BuildFailedMissions(objective);
|
||||||
entries.Append(failed);
|
entries.Append(failed);
|
||||||
|
|
||||||
|
var murders = BuildMurders(objective);
|
||||||
|
entries.Append(murders);
|
||||||
|
|
||||||
var vouchers = BuildVouchers(objective);
|
var vouchers = BuildVouchers(objective);
|
||||||
entries.Append(vouchers);
|
entries.Append(vouchers);
|
||||||
|
|
||||||
|
@ -41,7 +41,8 @@ namespace EliteBGS.BGS {
|
|||||||
e.Is(Events.RedeemVoucher) ||
|
e.Is(Events.RedeemVoucher) ||
|
||||||
e.Is(Events.FactionKillBond) ||
|
e.Is(Events.FactionKillBond) ||
|
||||||
e.Is(Events.MarketBuy) ||
|
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)) {
|
if (!string.IsNullOrEmpty(location.StationName)) {
|
||||||
current_station = 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)) {
|
} else if (e.Is(Events.MissionCompleted)) {
|
||||||
var completed = e as MissionCompletedEntry;
|
var completed = e as MissionCompletedEntry;
|
||||||
results.Add(new MissionCompleted(completed) {
|
results.Add(new MissionCompleted(completed) {
|
||||||
|
@ -82,6 +82,7 @@
|
|||||||
<DependentUpon>AdjustProfitWindow.xaml</DependentUpon>
|
<DependentUpon>AdjustProfitWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="BGS\DiscordLogGenerator.cs" />
|
<Compile Include="BGS\DiscordLogGenerator.cs" />
|
||||||
|
<Compile Include="BGS\FoulMurder.cs" />
|
||||||
<Compile Include="BGS\GenericDiscordLog.cs" />
|
<Compile Include="BGS\GenericDiscordLog.cs" />
|
||||||
<Compile Include="BGS\InfluenceSupport.cs" />
|
<Compile Include="BGS\InfluenceSupport.cs" />
|
||||||
<Compile Include="BGS\MissionFailed.cs" />
|
<Compile Include="BGS\MissionFailed.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user