From 1d747756acb9d74735268104b2c85cf922a4cd73 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Tue, 28 Sep 2021 14:41:09 +0200 Subject: [PATCH] implement selling cargo to controlling faction --- BGS/NonaDiscordLog.cs | 23 +++++++++++++++++++++++ BGS/Report.cs | 11 ++++++++++- BGS/SellCargo.cs | 31 +++++++++++++++++++++++++++++++ nonabgs.csproj | 4 +++- 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 BGS/SellCargo.cs diff --git a/BGS/NonaDiscordLog.cs b/BGS/NonaDiscordLog.cs index 0d76a88..5550ca0 100644 --- a/BGS/NonaDiscordLog.cs +++ b/BGS/NonaDiscordLog.cs @@ -43,6 +43,26 @@ namespace NonaBGS.BGS { "(Total value: {1} CR)\n", pages, sum); } + private string BuildCargoSold(Objective objective) { + StringBuilder builder = new StringBuilder(); + SellCargo[] sold = objective.LogEntries + .OfType() + .ToArray() + ; + + if (sold == null && sold.Length > 0) { + return builder.ToString(); + } + + foreach (SellCargo sell in sold) { + builder.AppendFormat("{0}\n", sell.ToString()); + } + + builder.AppendFormat("\n"); + + return builder.ToString(); + } + private string BuildMicroResourcesSold(Objective objective) { var total = from entries in objective.LogEntries where entries.GetType() == typeof(SellMicroResources) @@ -199,6 +219,9 @@ namespace NonaBGS.BGS { var micro = BuildMicroResourcesSold(objective); entries.Append(micro); + var sold = BuildCargoSold(objective); + entries.Append(sold); + log.Append(entries.ToString().Trim()); log.Append("\n```\n"); } diff --git a/BGS/Report.cs b/BGS/Report.cs index e416d3d..e4a3742 100644 --- a/BGS/Report.cs +++ b/BGS/Report.cs @@ -35,7 +35,8 @@ namespace NonaBGS.BGS { e.Is(Events.MultiSellExplorationData) || e.Is(Events.SellMicroResources) || e.Is(Events.RedeemVoucher) || - e.Is(Events.FactionKillBond) + e.Is(Events.FactionKillBond) || + e.Is(Events.MarketSell) ; } @@ -105,6 +106,14 @@ namespace NonaBGS.BGS { collate = true; } else if (e.Is(Events.SellMicroResources)) { entry = new SellMicroResources(current_system, current_station); + entry.Entries.Add(e); + } else if (e.Is(Events.MarketSell)) { + entry = new SellCargo() { + Faction = controlling_faction, + Station = current_station, + System = current_system + }; + entry.Entries.Add(e); } diff --git a/BGS/SellCargo.cs b/BGS/SellCargo.cs new file mode 100644 index 0000000..940f7cf --- /dev/null +++ b/BGS/SellCargo.cs @@ -0,0 +1,31 @@ +using System.Text; +using System.Linq; +using EDJournal; + +namespace NonaBGS.BGS { + public class SellCargo : LogEntry { + public override string ToString() { + StringBuilder builder = new StringBuilder(); + var sold = Entries.OfType().ToArray(); + + if (sold == null || sold.Length == 0) { + return builder.ToString(); + } + + foreach (MarketSellEntry sell in sold) { + builder.AppendFormat("Sold {0} {1} to the {2}\n", + sell.Count, + sell.Type, + sell.BlackMarket ? "Black Market" : "Commodity Market" + ); + } + + return builder.ToString().Trim(); + } + + /// + /// Selling resources to a market only helps the controlling faction + /// + public override bool OnlyControllingFaction => true; + } +} diff --git a/nonabgs.csproj b/nonabgs.csproj index aa7e54b..d802eee 100644 --- a/nonabgs.csproj +++ b/nonabgs.csproj @@ -41,7 +41,8 @@ packages\AutoCompleteTextBox.1.1.1\lib\net472\AutoCompleteTextBox.dll - + + False ..\edjournal\bin\Debug\EDJournal.dll @@ -75,6 +76,7 @@ +