diff --git a/BGS/GenericDiscordLog.cs b/BGS/GenericDiscordLog.cs index f865dbc..191aae8 100644 --- a/BGS/GenericDiscordLog.cs +++ b/BGS/GenericDiscordLog.cs @@ -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 formatters = new List() { + 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"); } diff --git a/BGS/LogGenerator/LogFormatter.cs b/BGS/LogGenerator/LogFormatter.cs new file mode 100644 index 0000000..2de2ca1 --- /dev/null +++ b/BGS/LogGenerator/LogFormatter.cs @@ -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); + } +} diff --git a/BGS/LogGenerator/VistaGenomics.cs b/BGS/LogGenerator/VistaGenomics.cs new file mode 100644 index 0000000..23381c8 --- /dev/null +++ b/BGS/LogGenerator/VistaGenomics.cs @@ -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 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/NonaDiscordLog.cs b/BGS/NonaDiscordLog.cs index 45f7a36..2e5acc0 100644 --- a/BGS/NonaDiscordLog.cs +++ b/BGS/NonaDiscordLog.cs @@ -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 formatters = new List() { + 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"); } diff --git a/BGS/OrganicData.cs b/BGS/OrganicData.cs new file mode 100644 index 0000000..2ee2c49 --- /dev/null +++ b/BGS/OrganicData.cs @@ -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().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; + } +} diff --git a/BGS/Report.cs b/BGS/Report.cs index efad997..23473d7 100644 --- a/BGS/Report.cs +++ b/BGS/Report.cs @@ -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. diff --git a/EliteBGS.csproj b/EliteBGS.csproj index cb6ab75..36e8bb6 100644 --- a/EliteBGS.csproj +++ b/EliteBGS.csproj @@ -85,9 +85,12 @@ + + + @@ -186,6 +189,7 @@ Always + diff --git a/TestData/SellOrganicData.txt b/TestData/SellOrganicData.txt new file mode 100644 index 0000000..1d3f8c2 --- /dev/null +++ b/TestData/SellOrganicData.txt @@ -0,0 +1,25 @@ +{ "timestamp":"2022-02-06T16:36:53Z", "event":"Fileheader", "part":1, "language":"English/UK", "Odyssey":true, "gameversion":"4.0.0.1102", "build":"r280672/r0 " } +{ "timestamp":"2022-02-06T18:10:13Z", "event":"Music", "MusicTrack":"NoTrack" } +{ "timestamp":"2022-02-06T18:10:26Z", "event":"ReceiveText", "From":"", "Message":"$COMMS_entered:#name=Akualanu;", "Message_Localised":"Entered Channel: Akualanu", "Channel":"npc" } +{ "timestamp":"2022-02-06T18:10:26Z", "event":"FSDJump", "Taxi":false, "Multicrew":false, "StarSystem":"Akualanu", "SystemAddress":5069805856169, "StarPos":[63.78125,-128.50000,3.00000], "SystemAllegiance":"Empire", "SystemEconomy":"$economy_Tourism;", "SystemEconomy_Localised":"Tourism", "SystemSecondEconomy":"$economy_HighTech;", "SystemSecondEconomy_Localised":"High Tech", "SystemGovernment":"$government_Patronage;", "SystemGovernment_Localised":"Patronage", "SystemSecurity":"$SYSTEM_SECURITY_low;", "SystemSecurity_Localised":"Low Security", "Population":787019, "Body":"Akualanu A", "BodyID":1, "BodyType":"Star", "Powers":[ "A. Lavigny-Duval" ], "PowerplayState":"Exploited", "JumpDist":40.001, "FuelUsed":4.849240, "FuelLevel":22.573641, "Factions":[ { "Name":"Akualanu United & Co", "FactionState":"War", "Government":"Corporate", "Influence":0.158000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":100.000000, "RecoveringStates":[ { "State":"InfrastructureFailure", "Trend":0 } ], "ActiveStates":[ { "State":"Lockdown" }, { "State":"Famine" }, { "State":"War" } ] }, { "Name":"Alacagui Holdings", "FactionState":"War", "Government":"Corporate", "Influence":0.086000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":55.000000, "RecoveringStates":[ { "State":"PirateAttack", "Trend":0 } ], "ActiveStates":[ { "State":"War" } ] }, { "Name":"Left Party of Akualanu", "FactionState":"War", "Government":"Communism", "Influence":0.086000, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":95.899399, "RecoveringStates":[ { "State":"InfrastructureFailure", "Trend":0 } ], "ActiveStates":[ { "State":"Lockdown" }, { "State":"Famine" }, { "State":"War" } ] }, { "Name":"Cartel of Akualanu", "FactionState":"Famine", "Government":"Anarchy", "Influence":0.028000, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":29.040001, "RecoveringStates":[ { "State":"InfrastructureFailure", "Trend":0 } ], "ActiveStates":[ { "State":"Famine" } ] }, { "Name":"Revolutionary Akualanu Liberals", "FactionState":"Bust", "Government":"Democracy", "Influence":0.085000, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":43.093700, "PendingStates":[ { "State":"Lockdown", "Trend":0 } ], "ActiveStates":[ { "State":"InfrastructureFailure" }, { "State":"Bust" } ] }, { "Name":"Conservatives of Cockaigne", "FactionState":"War", "Government":"Dictatorship", "Influence":0.138000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand3;", "Happiness_Localised":"Discontented", "MyReputation":70.000000, "ActiveStates":[ { "State":"CivilUnrest" }, { "State":"InfrastructureFailure" }, { "State":"War" } ] }, { "Name":"Nova Paresa", "FactionState":"Investment", "Government":"Patronage", "Influence":0.419000, "Allegiance":"Empire", "Happiness":"$Faction_HappinessBand1;", "Happiness_Localised":"Elated", "SquadronFaction":true, "MyReputation":100.000000, "ActiveStates":[ { "State":"Investment" }, { "State":"CivilLiberty" } ] } ], "SystemFaction":{ "Name":"Nova Paresa", "FactionState":"Investment" }, "Conflicts":[ { "WarType":"war", "Status":"active", "Faction1":{ "Name":"Akualanu United & Co", "Stake":"Konig Institution", "WonDays":0 }, "Faction2":{ "Name":"Conservatives of Cockaigne", "Stake":"", "WonDays":1 } }, { "WarType":"war", "Status":"active", "Faction1":{ "Name":"Alacagui Holdings", "Stake":"Ware Cultivation Facility", "WonDays":2 }, "Faction2":{ "Name":"Left Party of Akualanu", "Stake":"", "WonDays":2 } } ] } +{ "timestamp":"2022-02-06T18:10:26Z", "event":"Music", "MusicTrack":"DestinationFromHyperspace" } +{ "timestamp":"2022-02-06T18:10:31Z", "event":"Music", "MusicTrack":"Supercruise" } +{ "timestamp":"2022-02-06T18:12:18Z", "event":"FSSSignalDiscovered", "SystemAddress":5069805856169, "SignalName":"P.T.N. RACKMOBILE H0H-W6T", "IsStation":true } +{ "timestamp":"2022-02-06T18:12:18Z", "event":"FSSSignalDiscovered", "SystemAddress":5069805856169, "SignalName":"BARON VON ZOOMSKI K8L-04G", "IsStation":true } +{ "timestamp":"2022-02-06T18:12:18Z", "event":"FSSSignalDiscovered", "SystemAddress":5069805856169, "SignalName":"Hughes Vista", "IsStation":true } +{ "timestamp":"2022-02-06T18:12:18Z", "event":"FSSSignalDiscovered", "SystemAddress":5069805856169, "SignalName":"GOTHAM CITY J8T-1VM", "IsStation":true } +{ "timestamp":"2022-02-06T18:12:18Z", "event":"FSSSignalDiscovered", "SystemAddress":5069805856169, "SignalName":"NAUVOO JNB-BHF", "IsStation":true } +{ "timestamp":"2022-02-06T18:12:18Z", "event":"SupercruiseExit", "Taxi":false, "Multicrew":false, "StarSystem":"Akualanu", "SystemAddress":5069805856169, "Body":"Hughes Vista", "BodyID":29, "BodyType":"Station" } +{ "timestamp":"2022-02-06T18:12:18Z", "event":"Music", "MusicTrack":"DestinationFromSupercruise" } +{ "timestamp":"2022-02-06T18:12:23Z", "event":"Music", "MusicTrack":"NoTrack" } +{ "timestamp":"2022-02-06T18:12:23Z", "event":"ReceiveText", "From":"Hughes Vista", "Message":"$STATION_NoFireZone_entered;", "Message_Localised":"No fire zone entered.", "Channel":"npc" } +{ "timestamp":"2022-02-06T18:12:23Z", "event":"DockingRequested", "MarketID":3222969088, "StationName":"Hughes Vista", "StationType":"Coriolis", "LandingPads":{ "Small":13, "Medium":16, "Large":8 } } +{ "timestamp":"2022-02-06T18:12:24Z", "event":"ReceiveText", "From":"Hughes Vista", "Message":"$DockingChatter_Allied;", "Message_Localised":"An ally like you is always welcome here.", "Channel":"npc" } +{ "timestamp":"2022-02-06T18:12:24Z", "event":"ReceiveText", "From":"Hughes Vista", "Message":"$STATION_docking_granted;", "Message_Localised":"Docking request granted.", "Channel":"npc" } +{ "timestamp":"2022-02-06T18:12:24Z", "event":"DockingGranted", "LandingPad":37, "MarketID":3222969088, "StationName":"Hughes Vista", "StationType":"Coriolis" } +{ "timestamp":"2022-02-06T18:12:26Z", "event":"Music", "MusicTrack":"DockingComputer" } +{ "timestamp":"2022-02-06T18:13:30Z", "event":"Docked", "StationName":"Hughes Vista", "StationType":"Coriolis", "Taxi":false, "Multicrew":false, "StarSystem":"Akualanu", "SystemAddress":5069805856169, "MarketID":3222969088, "StationFaction":{ "Name":"Nova Paresa", "FactionState":"Investment" }, "StationGovernment":"$government_Patronage;", "StationGovernment_Localised":"Patronage", "StationAllegiance":"Empire", "StationServices":[ "dock", "autodock", "commodities", "contacts", "exploration", "missions", "outfitting", "crewlounge", "rearm", "refuel", "repair", "shipyard", "tuning", "engineer", "missionsgenerated", "facilitator", "flightcontroller", "stationoperations", "powerplay", "searchrescue", "stationMenu", "shop", "livery", "socialspace", "bartender", "vistagenomics", "pioneersupplies", "apexinterstellar", "frontlinesolutions" ], "StationEconomy":"$economy_Tourism;", "StationEconomy_Localised":"Tourism", "StationEconomies":[ { "Name":"$economy_Tourism;", "Name_Localised":"Tourism", "Proportion":1.000000 } ], "DistFromStarLS":78.917615, "LandingPads":{ "Small":13, "Medium":16, "Large":8 } } +{ "timestamp":"2022-02-06T18:16:08Z", "event":"Disembark", "SRV":false, "Taxi":false, "Multicrew":false, "ID":65, "StarSystem":"Akualanu", "SystemAddress":5069805856169, "Body":"Hughes Vista", "BodyID":29, "OnStation":true, "OnPlanet":false, "StationName":"Hughes Vista", "StationType":"Coriolis", "MarketID":3222969088 } +{ "timestamp":"2022-02-06T18:16:12Z", "event":"ReceiveText", "From":"Hughes Vista", "Message":"$STATION_NoFireZone_entered;", "Message_Localised":"No fire zone entered.", "Channel":"npc" } +{ "timestamp":"2022-02-06T18:17:44Z", "event":"Promotion", "Exobiologist":1 } +{ "timestamp":"2022-02-06T18:17:44Z", "event":"SellOrganicData", "MarketID":3222969088, "BioData":[ { "Genus":"$Codex_Ent_Stratum_Genus_Name;", "Genus_Localised":"Stratum", "Species":"$Codex_Ent_Stratum_07_Name;", "Species_Localised":"Stratum Tectonicas", "Value":806300, "Bonus":0 }, { "Genus":"$Codex_Ent_Aleoids_Genus_Name;", "Genus_Localised":"Aleoida", "Species":"$Codex_Ent_Aleoids_05_Name;", "Species_Localised":"Aleoida Gravis", "Value":596500, "Bonus":0 } ] } \ No newline at end of file