From 0fdd3e2c9a1a16a6f6cdb172b411ecf9467fa4ff Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Tue, 28 Sep 2021 14:14:16 +0200 Subject: [PATCH] implement combat zones and combat bonds --- BGS/CombatZone.cs | 31 +++++++++++++++++++++++--- BGS/NonaDiscordLog.cs | 46 ++++++++++++++++++++++++++++++++++++++ CombatZoneDialog.xaml | 48 ++++++++++++++++++++++++++++++++++++++++ CombatZoneDialog.xaml.cs | 47 +++++++++++++++++++++++++++++++++++++++ MainWindow.xaml | 2 ++ MainWindow.xaml.cs | 34 ++++++++++++++++++++++++++++ nonabgs.csproj | 7 ++++++ 7 files changed, 212 insertions(+), 3 deletions(-) create mode 100644 CombatZoneDialog.xaml create mode 100644 CombatZoneDialog.xaml.cs diff --git a/BGS/CombatZone.cs b/BGS/CombatZone.cs index 97abf21..9d9efb5 100644 --- a/BGS/CombatZone.cs +++ b/BGS/CombatZone.cs @@ -1,5 +1,30 @@ -namespace NonaBGS.BGS { - public class CombatZone { - private int level; +using System; + +namespace NonaBGS.BGS { + public class CombatZone : LogEntry, IComparable { + public string Type { get; set; } + public string Grade { get; set; } + public int Amount { get; set; } + + public int CompareTo(object obj) { + if (obj.GetType() != typeof(CombatZone)) { + return -1; + } + + var b = obj as CombatZone; + if (b.Faction != Faction || b.System != System) { + return -1; // System and faction don't match + } + + if (b.Type != b.Type || b.Grade != b.Grade) { + return -1; // grade and type don't match + } + + return 0; + } + + public override string ToString() { + return string.Format("Won {0} x {1} {2} Combat Zone(s)", Amount, Type, Grade); + } } } diff --git a/BGS/NonaDiscordLog.cs b/BGS/NonaDiscordLog.cs index b7772f3..0d76a88 100644 --- a/BGS/NonaDiscordLog.cs +++ b/BGS/NonaDiscordLog.cs @@ -57,6 +57,26 @@ namespace NonaBGS.BGS { return string.Format("Sold {0} CR worth of Micro Resources\n", sum); } + private string BuildKillBonds(Objective objective) { + StringBuilder builder = new StringBuilder(); + FactionKillBonds[] bonds = objective.LogEntries + .OfType() + .ToArray() + ; + + if (bonds == null || bonds.Length == 0) { + return builder.ToString(); + } + + foreach (FactionKillBonds bond in bonds) { + builder.AppendFormat("{0}\n", bond.ToString()); + } + + builder.AppendFormat("\n"); + + return builder.ToString(); + } + private string BuildVouchers(Objective objective) { StringBuilder builder = new StringBuilder(); var missions = from entries in objective.LogEntries @@ -126,6 +146,26 @@ namespace NonaBGS.BGS { return output.ToString(); } + private string BuildCombatZones(Objective objective) { + StringBuilder builder = new StringBuilder(); + CombatZone[] zones = objective.LogEntries + .OfType() + .ToArray() + ; + + if (zones == null || zones.Length == 0) { + return builder.ToString(); + } + + foreach (CombatZone zone in zones) { + builder.AppendFormat("{0}\n", zone.ToString()); + } + + builder.Append("\n"); + + return builder.ToString(); + } + public string GenerateDiscordLog(Report report) { StringBuilder log = new StringBuilder(); @@ -147,6 +187,12 @@ namespace NonaBGS.BGS { var vouchers = BuildVouchers(objective); entries.Append(vouchers); + var zones = BuildCombatZones(objective); + entries.Append(zones); + + var bonds = BuildKillBonds(objective); + entries.Append(bonds); + var carto = BuildCartoGraphics(objective); entries.Append(carto); diff --git a/CombatZoneDialog.xaml b/CombatZoneDialog.xaml new file mode 100644 index 0000000..7fc36f1 --- /dev/null +++ b/CombatZoneDialog.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +