diff --git a/BGS/GenericDiscordLog.cs b/BGS/GenericDiscordLog.cs index a1e9c4f..2a5de10 100644 --- a/BGS/GenericDiscordLog.cs +++ b/BGS/GenericDiscordLog.cs @@ -9,8 +9,10 @@ using EliteBGS.BGS.LogGenerator; namespace EliteBGS.BGS { public class GenericDiscordLog : IDiscordLogGenerator { private List formatters = new List() { - new VistaGenomics(), + new VistaGenomicsFormat(), + new SearchAndRescueFormat(), }; + private string FormatDate() { DateTime today = DateTime.Now; return today.ToString("dd/MM/yyyy"); diff --git a/BGS/LogGenerator/GenericFormat.cs b/BGS/LogGenerator/GenericFormat.cs new file mode 100644 index 0000000..079437e --- /dev/null +++ b/BGS/LogGenerator/GenericFormat.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EliteBGS.BGS.LogGenerator { + /// + /// Creates a generic log block, that is simply all LogEntries of type "Type" + /// per line + /// + /// LogEntry subtype to work on + public class GenericFormat : LogFormatter { + public string GenerateLog(Objective objective) { + IEnumerable logs = objective.LogEntries.OfType(); + StringBuilder builder = new StringBuilder(); + + if (logs == null || logs.Count() <= 0) { + return ""; + } + + foreach (Type log in logs) { + builder.AppendLine(log.ToString()); + } + + return builder.ToString(); + } + } +} diff --git a/BGS/LogGenerator/SearchAndRescueFormat.cs b/BGS/LogGenerator/SearchAndRescueFormat.cs new file mode 100644 index 0000000..77ce374 --- /dev/null +++ b/BGS/LogGenerator/SearchAndRescueFormat.cs @@ -0,0 +1,4 @@ +namespace EliteBGS.BGS.LogGenerator { + public class SearchAndRescueFormat : GenericFormat { + } +} diff --git a/BGS/LogGenerator/VistaGenomics.cs b/BGS/LogGenerator/VistaGenomics.cs deleted file mode 100644 index 23381c8..0000000 --- a/BGS/LogGenerator/VistaGenomics.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace EliteBGS.BGS.LogGenerator { - class VistaGenomics : LogFormatter { - public string GenerateLog(Objective objective) { - IEnumerable logs = objective.LogEntries.OfType(); - StringBuilder builder = new StringBuilder(); - - if (logs == null || logs.Count() < 0) { - return ""; - } - - foreach(OrganicData log in logs) { - builder.AppendLine(log.ToString()); - } - - return builder.ToString(); - } - } -} diff --git a/BGS/LogGenerator/VistaGenomicsFormat.cs b/BGS/LogGenerator/VistaGenomicsFormat.cs new file mode 100644 index 0000000..64385cb --- /dev/null +++ b/BGS/LogGenerator/VistaGenomicsFormat.cs @@ -0,0 +1,4 @@ +namespace EliteBGS.BGS.LogGenerator { + class VistaGenomicsFormat : GenericFormat { + } +} diff --git a/BGS/NonaDiscordLog.cs b/BGS/NonaDiscordLog.cs index f777495..a80fa2e 100644 --- a/BGS/NonaDiscordLog.cs +++ b/BGS/NonaDiscordLog.cs @@ -9,7 +9,8 @@ using EliteBGS.BGS.LogGenerator; namespace EliteBGS.BGS { public class NonaDiscordLog : IDiscordLogGenerator { private List formatters = new List() { - new VistaGenomics(), + new VistaGenomicsFormat(), + new SearchAndRescueFormat(), }; private string FormatDate() { @@ -346,7 +347,10 @@ namespace EliteBGS.BGS { entries.Append(sold); foreach (LogFormatter formatter in formatters) { - entries.AppendFormat("{0}\n", formatter.GenerateLog(objective)); + string text = formatter.GenerateLog(objective); + if (!string.IsNullOrEmpty(text)) { + entries.AppendFormat("{0}\n", text); + } } log.Append(entries.ToString().Trim()); diff --git a/BGS/Report.cs b/BGS/Report.cs index 23473d7..3b47678 100644 --- a/BGS/Report.cs +++ b/BGS/Report.cs @@ -36,6 +36,7 @@ namespace EliteBGS.BGS { e.Is(Events.FSDJump) || e.Is(Events.Location) || e.Is(Events.MultiSellExplorationData) || + e.Is(Events.SearchAndRescue) || e.Is(Events.SellExplorationData) || e.Is(Events.SellMicroResources) || e.Is(Events.SellOrganicData) || @@ -246,6 +247,14 @@ namespace EliteBGS.BGS { System = current_system, }); + collate = true; + } else if (e.Is(Events.SearchAndRescue)) { + results.Add(new SearchAndRescue(e as SearchAndRescueEntry) { + Faction = controlling_faction, + Station = current_station, + System = current_system, + }); + collate = true; } else if (e.Is(Events.MarketSell)) { MarketSellEntry sell = e as MarketSellEntry; diff --git a/BGS/SearchAndRescue.cs b/BGS/SearchAndRescue.cs new file mode 100644 index 0000000..1795841 --- /dev/null +++ b/BGS/SearchAndRescue.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EDJournal; + +namespace EliteBGS.BGS { + public class SearchAndRescue : LogEntry { + public SearchAndRescue (SearchAndRescueEntry e) { + Entries.Add(e); + } + + public long Count { + get { + return Entries.OfType().Sum(x => x.Count); + } + } + + public string NameLocalised { + get { + return Entries.OfType().First().NameLocalised; + } + } + + public override int CompareTo(LogEntry o) { + if (o == null || o.GetType() != typeof(SearchAndRescue)) { + return -1; + } + + SearchAndRescue other = o as SearchAndRescue; + + if (other.System == System && + other.Station == Station && + other.Faction == Faction && + other.NameLocalised == NameLocalised) { + return 0; + } + + return -1; + } + + public override string ToString() { + return string.Format("Contributed {0} {1} to Search and Rescue", Count, NameLocalised); + } + + public override bool OnlyControllingFaction => true; + } +} diff --git a/EliteBGS.csproj b/EliteBGS.csproj index 36e8bb6..e1099ec 100644 --- a/EliteBGS.csproj +++ b/EliteBGS.csproj @@ -85,12 +85,15 @@ + - + + +