add vista genomics to the tool
This commit is contained in:
@@ -4,9 +4,13 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using EDJournal;
|
||||
using EliteBGS.BGS.LogGenerator;
|
||||
|
||||
namespace EliteBGS.BGS {
|
||||
public class GenericDiscordLog : IDiscordLogGenerator {
|
||||
private List<LogFormatter> formatters = new List<LogFormatter>() {
|
||||
new VistaGenomics(),
|
||||
};
|
||||
private string FormatDate() {
|
||||
DateTime today = DateTime.Now;
|
||||
return today.ToString("dd/MM/yyyy");
|
||||
@@ -291,6 +295,10 @@ namespace EliteBGS.BGS {
|
||||
var sold = BuildCargoSold(objective);
|
||||
entries.Append(sold);
|
||||
|
||||
foreach (LogFormatter formatter in formatters) {
|
||||
entries.AppendFormat("{0}\n", formatter.GenerateLog(objective));
|
||||
}
|
||||
|
||||
log.Append(entries.ToString().Trim());
|
||||
log.Append("\n```\n");
|
||||
}
|
||||
|
||||
11
BGS/LogGenerator/LogFormatter.cs
Normal file
11
BGS/LogGenerator/LogFormatter.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EliteBGS.BGS.LogGenerator {
|
||||
public interface LogFormatter {
|
||||
string GenerateLog(Objective objective);
|
||||
}
|
||||
}
|
||||
22
BGS/LogGenerator/VistaGenomics.cs
Normal file
22
BGS/LogGenerator/VistaGenomics.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace EliteBGS.BGS.LogGenerator {
|
||||
class VistaGenomics : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
IEnumerable<OrganicData> logs = objective.LogEntries.OfType<OrganicData>();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (logs == null || logs.Count() < 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach(OrganicData log in logs) {
|
||||
builder.AppendLine(log.ToString());
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using EDJournal;
|
||||
using EliteBGS.BGS.LogGenerator;
|
||||
|
||||
namespace EliteBGS.BGS {
|
||||
public class NonaDiscordLog : IDiscordLogGenerator {
|
||||
private List<LogFormatter> formatters = new List<LogFormatter>() {
|
||||
new VistaGenomics(),
|
||||
};
|
||||
|
||||
private string FormatDate() {
|
||||
CultureInfo cultureInfo = CultureInfo.InvariantCulture;
|
||||
StringBuilder date = new StringBuilder();
|
||||
@@ -340,6 +345,10 @@ namespace EliteBGS.BGS {
|
||||
var sold = BuildCargoSold(objective);
|
||||
entries.Append(sold);
|
||||
|
||||
foreach (LogFormatter formatter in formatters) {
|
||||
entries.AppendFormat("{0}\n", formatter.GenerateLog(objective));
|
||||
}
|
||||
|
||||
log.Append(entries.ToString().Trim());
|
||||
log.Append("\n```\n");
|
||||
}
|
||||
|
||||
45
BGS/OrganicData.cs
Normal file
45
BGS/OrganicData.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EDJournal;
|
||||
|
||||
namespace EliteBGS.BGS {
|
||||
public class OrganicData : LogEntry {
|
||||
public OrganicData(SellOrganicDataEntry e) {
|
||||
Entries.Add(e);
|
||||
}
|
||||
|
||||
public long TotalValue {
|
||||
get {
|
||||
return Entries.OfType<SellOrganicDataEntry>().Sum(x => x.TotalValue);
|
||||
}
|
||||
}
|
||||
|
||||
public override int CompareTo(LogEntry other) {
|
||||
if (other == null || other.GetType() != typeof(OrganicData)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (other.Faction == Faction &&
|
||||
other.System == System &&
|
||||
other.Station == Station) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("Sold {0} worth of organic data to Vista Genomics",
|
||||
Credits.FormatCredits(TotalValue)
|
||||
);
|
||||
}
|
||||
|
||||
/* Selling organic data only helps the controlling faction, just like
|
||||
* selling cartographic data.
|
||||
*/
|
||||
public override bool OnlyControllingFaction => true;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ namespace EliteBGS.BGS {
|
||||
e.Is(Events.MultiSellExplorationData) ||
|
||||
e.Is(Events.SellExplorationData) ||
|
||||
e.Is(Events.SellMicroResources) ||
|
||||
e.Is(Events.SellOrganicData) ||
|
||||
e.Is(Events.RedeemVoucher) ||
|
||||
e.Is(Events.FactionKillBond) ||
|
||||
e.Is(Events.MarketBuy) ||
|
||||
@@ -195,6 +196,15 @@ namespace EliteBGS.BGS {
|
||||
});
|
||||
|
||||
/* colate single cartographic selling into one */
|
||||
collate = true;
|
||||
} else if (e.Is(Events.SellOrganicData)) {
|
||||
/* organic data sold to Vista Genomics */
|
||||
results.Add(new OrganicData(e as SellOrganicDataEntry) {
|
||||
System = current_system,
|
||||
Station = current_station,
|
||||
Faction = controlling_faction,
|
||||
});
|
||||
|
||||
collate = true;
|
||||
} else if (e.Is(Events.MultiSellExplorationData)) {
|
||||
/* For multi-sell-exploraton-data only the controlling faction of the station sold to matters.
|
||||
|
||||
Reference in New Issue
Block a user