initial include of an avalonia version of EDBGS
This commit is contained in:
77
Avalonia.EliteBGS/LogGenerator/CargoSoldFormatter.cs
Normal file
77
Avalonia.EliteBGS/LogGenerator/CargoSoldFormatter.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Documents;
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class CargoSoldFormatter : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
SellCargo[] sold = objective.EnabledOfType<SellCargo>().ToArray();
|
||||
|
||||
if (sold == null || sold.Length <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// This groups everything together by cargo sold, and then by market sold to.
|
||||
// Dictionary<string Cargo, Dictionary<string Market, { Market, Amount, Profit }> >
|
||||
var entries = sold.GroupBy(x => x.Cargo,
|
||||
(key, cargos) => new {
|
||||
Cargo = key,
|
||||
Markets = cargos.GroupBy(y => y.Market,
|
||||
(market, markets) => new {
|
||||
Market = market,
|
||||
Amount = markets.Sum(x => x.Amount),
|
||||
Profit = markets.Sum(x => x.Profit)
|
||||
})
|
||||
}
|
||||
)
|
||||
;
|
||||
|
||||
foreach (var cargo in entries) {
|
||||
foreach (var market in cargo.Markets) {
|
||||
builder.AppendFormat("Sold {0} {1} to the {2}",
|
||||
market.Amount,
|
||||
cargo.Cargo,
|
||||
market.Market
|
||||
);
|
||||
|
||||
if (market.Profit != 0) {
|
||||
builder.AppendFormat(" ({0} {1})",
|
||||
Credits.FormatCredits(market.Profit),
|
||||
market.Profit < 0 ? "loss" : "profit"
|
||||
);
|
||||
}
|
||||
|
||||
builder.Append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendFormat("\n");
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
SellCargo[] sold = objective.EnabledOfType<SellCargo>().ToArray();
|
||||
long totalProfit = sold.Sum(x => x.Profit);
|
||||
long tons = sold.Sum(x => x.Amount);
|
||||
|
||||
if (tons <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder builder = new();
|
||||
|
||||
builder.Append("Sold: ");
|
||||
builder.AppendFormat("{0}t", tons);
|
||||
if (totalProfit >= 100000) {
|
||||
builder.AppendFormat(", {0} profit", Credits.FormatMillions(totalProfit));
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
33
Avalonia.EliteBGS/LogGenerator/CartographicsFormat.cs
Normal file
33
Avalonia.EliteBGS/LogGenerator/CartographicsFormat.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Linq;
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class CartographicsFormat : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
var total = objective.EnabledOfType<Cartographics>();
|
||||
var pages = total.Count();
|
||||
long sum = total.Sum(x => x.TotalSum);
|
||||
|
||||
if (pages <= 0 || sum <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return string.Format("Sold {0} page(s) worth of universal cartographics\n" +
|
||||
"(Total value: {1})\n\n",
|
||||
pages, Credits.FormatCredits(sum)
|
||||
);
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
Cartographics[] sold = objective.EnabledOfType<Cartographics>().ToArray();
|
||||
long totalProfit = sold.Sum(x => x.TotalSum);
|
||||
|
||||
if (totalProfit >= 100000) {
|
||||
return string.Format("Explo: {0}", Credits.FormatMillions(totalProfit));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
100
Avalonia.EliteBGS/LogGenerator/CombatZoneFormat.cs
Normal file
100
Avalonia.EliteBGS/LogGenerator/CombatZoneFormat.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
class CombatZoneFormat : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
var logs = objective
|
||||
.EnabledOfType<CombatZone>()
|
||||
.OrderBy(x => (CombatZones.DifficultyRank(x.Grade) ?? 0))
|
||||
.GroupBy(x => new { x.Type, x.Grade, x.Settlement })
|
||||
.ToDictionary(x => x.Key, x => x.ToList())
|
||||
;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (logs == null || logs.Count() <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (var log in logs) {
|
||||
int optionals = log.Value
|
||||
.Sum(x => x.OptionalObjectivesCompleted)
|
||||
;
|
||||
var settlements = log.Value
|
||||
.Select(x => x.Settlement)
|
||||
.Distinct()
|
||||
;
|
||||
string settl = string.Join(", ", settlements);
|
||||
if (!string.IsNullOrEmpty(log.Key.Grade)) {
|
||||
builder.AppendFormat("Won {0}x {1} {2} Combat Zone(s)",
|
||||
log.Value.Count,
|
||||
log.Key.Grade,
|
||||
log.Key.Type
|
||||
);
|
||||
} else {
|
||||
builder.AppendFormat("Won {0}x {1} Combat Zone(s)",
|
||||
log.Value.Count,
|
||||
log.Key.Type
|
||||
);
|
||||
}
|
||||
|
||||
if (optionals > 0) {
|
||||
builder.AppendFormat(" (with {0} optional objectives)", optionals);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(settl)) {
|
||||
builder.AppendFormat(" (at {0})", settl);
|
||||
}
|
||||
builder.Append("\n");
|
||||
}
|
||||
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
var logs = objective
|
||||
.EnabledOfType<CombatZone>()
|
||||
.OrderBy(x => (CombatZones.DifficultyRank(x.Grade) ?? 0))
|
||||
.GroupBy(x => new { x.Type, x.Grade })
|
||||
.ToDictionary(x => x.Key, x => x.ToList())
|
||||
;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (logs == null || logs.Count() <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (var log in logs) {
|
||||
int optionals = log.Value
|
||||
.Sum(x => x.OptionalObjectivesCompleted)
|
||||
;
|
||||
if (builder.Length > 0) {
|
||||
builder.Append(", ");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(log.Key.Grade)) {
|
||||
string grade = log.Key.Grade.Substring(0, 1);
|
||||
if (log.Key.Grade == CombatZones.DifficultyVeryHigh) {
|
||||
grade = "VH";
|
||||
}
|
||||
builder.AppendFormat("CZ: {0}x{1}{2}",
|
||||
log.Value.Count,
|
||||
grade,
|
||||
log.Key.Type.Substring(0, 1)
|
||||
);
|
||||
} else {
|
||||
builder.AppendFormat("CZ: {0}x?{1}",
|
||||
log.Value.Count,
|
||||
log.Key.Type.Substring(0, 1)
|
||||
);
|
||||
}
|
||||
|
||||
if (optionals > 0) {
|
||||
builder.AppendFormat("+ {0} OPTS", optionals);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
}
|
||||
32
Avalonia.EliteBGS/LogGenerator/GenericFormat.cs
Normal file
32
Avalonia.EliteBGS/LogGenerator/GenericFormat.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using EDPlayerJournal.BGS;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a generic log block, that is simply all LogEntries of type "Type"
|
||||
/// per line
|
||||
/// </summary>
|
||||
/// <typeparam name="Type">LogEntry subtype to work on</typeparam>
|
||||
public class GenericFormat<Type> : LogFormatter where Type : Transaction {
|
||||
public string GenerateLog(Objective objective) {
|
||||
IEnumerable<Type> logs = objective.EnabledOfType<Type>();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (logs == null || logs.Count() <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (Type log in logs) {
|
||||
builder.AppendLine(log.ToString());
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public virtual string GenerateSummary(Objective objective) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
38
Avalonia.EliteBGS/LogGenerator/KillBondsFormat.cs
Normal file
38
Avalonia.EliteBGS/LogGenerator/KillBondsFormat.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class KillBondsFormat : GenericFormat<FactionKillBonds> {
|
||||
public override string GenerateSummary(Objective objective) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
var bonds = objective
|
||||
.EnabledOfType<FactionKillBonds>()
|
||||
.GroupBy(x => x.VictimFaction)
|
||||
.ToDictionary(x => x.Key, x => x.ToList())
|
||||
;
|
||||
|
||||
if (bonds.Count <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
builder.Append("Killbonds: ");
|
||||
foreach (var entry in bonds) {
|
||||
long sum = (long)entry.Value.Sum(x => (decimal)x.TotalSum);
|
||||
builder.AppendFormat("{0} against {1}, ",
|
||||
Credits.FormatMillions(sum),
|
||||
entry.Key
|
||||
);
|
||||
}
|
||||
|
||||
if (builder.Length > 2) {
|
||||
// Remove trailing comma
|
||||
builder.Remove(builder.Length - 2, 2);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
6
Avalonia.EliteBGS/LogGenerator/LogFormatter.cs
Normal file
6
Avalonia.EliteBGS/LogGenerator/LogFormatter.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public interface LogFormatter {
|
||||
string GenerateLog(Objective objective);
|
||||
string GenerateSummary(Objective objective);
|
||||
}
|
||||
17
Avalonia.EliteBGS/LogGenerator/MarketBuyFormat.cs
Normal file
17
Avalonia.EliteBGS/LogGenerator/MarketBuyFormat.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using EDPlayerJournal.BGS;
|
||||
using System.Linq;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class MarketBuyFormat : GenericFormat<BuyCargo> {
|
||||
public override string GenerateSummary(Objective objective) {
|
||||
long tons = objective
|
||||
.EnabledOfType<BuyCargo>()
|
||||
.Sum(x => x.Amount)
|
||||
;
|
||||
if (tons <= 0) {
|
||||
return "";
|
||||
}
|
||||
return string.Format("Bought: {0}t", tons);
|
||||
}
|
||||
}
|
||||
23
Avalonia.EliteBGS/LogGenerator/MicroResourcesFormat.cs
Normal file
23
Avalonia.EliteBGS/LogGenerator/MicroResourcesFormat.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Linq;
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class MicroResourcesFormat : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
var total = objective.EnabledOfType<SellMicroResources>();
|
||||
long sum = total.Sum(x => x.TotalSum);
|
||||
|
||||
if (total == null || total.Count() <= 0 || sum <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return string.Format("Sold {0} worth of Micro Resources\n",
|
||||
Credits.FormatCredits(sum));
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
170
Avalonia.EliteBGS/LogGenerator/MissionFormat.cs
Normal file
170
Avalonia.EliteBGS/LogGenerator/MissionFormat.cs
Normal file
@@ -0,0 +1,170 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using EDPlayerJournal.BGS;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class MissionFormat : LogFormatter {
|
||||
private string GenerateFailedLog(Objective objective) {
|
||||
var missions = objective.EnabledOfType<MissionFailed>();
|
||||
|
||||
if (missions.Count <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
var grouping = missions
|
||||
.GroupBy(x => x.Mission.IsOnFoot)
|
||||
;
|
||||
|
||||
foreach (var group in grouping) {
|
||||
int amount = group.Count();
|
||||
|
||||
if (group.Key) {
|
||||
builder.AppendFormat("Failed {0} On Foot Mission(s)\n", amount);
|
||||
} else {
|
||||
builder.AppendFormat("Failed {0} Ship Mission(s)\n", amount);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
private string GenerateFailedSummary(Objective objective) {
|
||||
var missions = objective.EnabledOfType<MissionFailed>();
|
||||
|
||||
if (missions.Count <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder sb = new();
|
||||
|
||||
int onFootFails = missions.Where(x => x.Mission.IsOnFoot).Count();
|
||||
int shipFails = missions.Where(x => !x.Mission.IsOnFoot).Count();
|
||||
|
||||
sb.Append("Fails: ");
|
||||
if (onFootFails > 0) {
|
||||
sb.AppendFormat("{0} Ground", onFootFails);
|
||||
}
|
||||
|
||||
if (shipFails > 0) {
|
||||
if (onFootFails > 0) {
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.AppendFormat("{0} Ship", shipFails);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string GenerateLog(Objective objective) {
|
||||
Dictionary<string, Dictionary<string, int>> collated = new();
|
||||
Dictionary<string, ulong> passengers = new();
|
||||
StringBuilder output = new StringBuilder();
|
||||
long total_influence = 0;
|
||||
|
||||
var missions = objective.EnabledOfType<MissionCompleted>();
|
||||
var support = objective.EnabledOfType<InfluenceSupport>();
|
||||
var failed = objective.EnabledOfType<MissionFailed>();
|
||||
|
||||
if ((missions == null || missions.Count == 0) &&
|
||||
(support == null || support.Count == 0) &&
|
||||
(failed == null || failed.Count == 0)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (MissionCompleted m in missions) {
|
||||
if (!collated.ContainsKey(m.MissionName)) {
|
||||
collated[m.MissionName] = new Dictionary<string, int>();
|
||||
}
|
||||
if (!collated[m.MissionName].ContainsKey(m.Influence)) {
|
||||
collated[m.MissionName][m.Influence] = 0;
|
||||
}
|
||||
|
||||
++collated[m.MissionName][m.Influence];
|
||||
|
||||
total_influence += m.Influence.Length;
|
||||
|
||||
if (m.AcceptedEntry != null &&
|
||||
m.AcceptedEntry.Mission != null &&
|
||||
m.AcceptedEntry.Mission.IsPassengerMission) {
|
||||
if (!passengers.ContainsKey(m.MissionName)) {
|
||||
passengers[m.MissionName] = 0;
|
||||
}
|
||||
passengers[m.MissionName] += (m.AcceptedEntry.Mission.PassengerCount ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mission in collated) {
|
||||
output.AppendFormat("{0}: ", mission.Key);
|
||||
output.Append("(");
|
||||
foreach (var influence in mission.Value.OrderBy(x => x.Key.Length)) {
|
||||
output.AppendFormat("Inf{0} x{1}, ", influence.Key, influence.Value);
|
||||
}
|
||||
output.Remove(output.Length - 2, 2); // remove last ", "
|
||||
output.Append(")");
|
||||
|
||||
if (passengers.ContainsKey(mission.Key)) {
|
||||
output.AppendFormat(" ({0} Passengers)", passengers[mission.Key]);
|
||||
}
|
||||
|
||||
output.Append("\n");
|
||||
}
|
||||
|
||||
output.Append("\n");
|
||||
|
||||
// Handle failed missions, and add them to the log and influence tally
|
||||
string failedlog = GenerateFailedLog(objective);
|
||||
if (!string.IsNullOrEmpty(failedlog)) {
|
||||
output.Append(failedlog);
|
||||
output.Append("\n");
|
||||
}
|
||||
total_influence += failed.Sum(x => x.InfluenceAmount);
|
||||
|
||||
foreach (InfluenceSupport inf in support) {
|
||||
output.Append(inf.ToString());
|
||||
output.Append("\n");
|
||||
total_influence += inf.Influence.InfluenceAmount;
|
||||
}
|
||||
|
||||
if (support.Count() > 0) {
|
||||
output.Append("\n");
|
||||
}
|
||||
|
||||
if (total_influence != 0) {
|
||||
output.AppendFormat("Total Influence: {0}", total_influence);
|
||||
}
|
||||
|
||||
return output.ToString().Trim();
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
long influence = objective
|
||||
.EnabledOfType<MissionCompleted>()
|
||||
.Sum(x => x.Influence.Length)
|
||||
;
|
||||
long support = objective
|
||||
.EnabledOfType<InfluenceSupport>()
|
||||
.Sum(x => x.Influence.InfluenceAmount)
|
||||
;
|
||||
long failed = objective
|
||||
.EnabledOfType<MissionFailed>()
|
||||
.Sum(x => x.InfluenceAmount)
|
||||
;
|
||||
|
||||
if (influence == 0 && support == 0 && failed == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
string failedsummary = GenerateFailedSummary(objective);
|
||||
string summary = string.Format("INF: {0}", influence + support + failed);
|
||||
|
||||
if (!string.IsNullOrEmpty(failedsummary)) {
|
||||
string.Join("; ", summary, failedsummary);
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
}
|
||||
60
Avalonia.EliteBGS/LogGenerator/MurderFormat.cs
Normal file
60
Avalonia.EliteBGS/LogGenerator/MurderFormat.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class MurderFormat : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
var logs = objective
|
||||
.EnabledOfType<FoulMurder>()
|
||||
.GroupBy(x => x.CrimeType)
|
||||
.ToDictionary(x => x.Key, x => x.ToList())
|
||||
;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (logs == null || logs.Count() <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (var log in logs) {
|
||||
string type;
|
||||
|
||||
if (string.Compare(log.Key, CrimeTypes.Murder) == 0) {
|
||||
if (log.Value.Count > 1) {
|
||||
type = "ships";
|
||||
} else {
|
||||
type = "ship";
|
||||
}
|
||||
} else {
|
||||
if (log.Value.Count > 1) {
|
||||
type = "people";
|
||||
} else {
|
||||
type = "person";
|
||||
}
|
||||
}
|
||||
long bounties = log.Value.Sum(x => x.Bounties);
|
||||
builder.AppendFormat("Murdered {0} {1} (Bounties: {2})\n",
|
||||
log.Value.Count, type,
|
||||
Credits.FormatMillions(bounties)
|
||||
);
|
||||
}
|
||||
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
long murders = objective
|
||||
.EnabledOfType<FoulMurder>()
|
||||
.Where(x => x.CrimeType == CrimeTypes.Murder || x.CrimeType == CrimeTypes.OnFootMurder)
|
||||
.Count()
|
||||
;
|
||||
|
||||
if (murders <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return string.Format("Kills: {0}", murders);
|
||||
}
|
||||
}
|
||||
22
Avalonia.EliteBGS/LogGenerator/SearchAndRescueFormat.cs
Normal file
22
Avalonia.EliteBGS/LogGenerator/SearchAndRescueFormat.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
using System.Linq;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class SearchAndRescueFormat : GenericFormat<SearchAndRescue> {
|
||||
public override string GenerateSummary(Objective objective) {
|
||||
long tons = objective
|
||||
.EnabledOfType<SearchAndRescue>()
|
||||
.Sum(x => x.Count)
|
||||
;
|
||||
long profit = objective
|
||||
.EnabledOfType<SearchAndRescue>()
|
||||
.Sum(x => x.Reward)
|
||||
;
|
||||
if (tons <= 0) {
|
||||
return "";
|
||||
}
|
||||
return string.Format("S&R: {0}t, {1} profit", tons, Credits.FormatMillions(profit));
|
||||
}
|
||||
}
|
||||
65
Avalonia.EliteBGS/LogGenerator/ThargoidFormatter.cs
Normal file
65
Avalonia.EliteBGS/LogGenerator/ThargoidFormatter.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class ThargoidFormatter : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
List<ThargoidKill> kills = objective.EnabledOfType<ThargoidKill>().ToList();
|
||||
|
||||
if (kills.Count == 0 ) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Dictionary<ThargoidVessel, List<ThargoidKill>> sorted = kills
|
||||
.GroupBy(x => x.ThargoidType)
|
||||
.ToDictionary(x => x.Key, x => x.ToList())
|
||||
;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
foreach (var k in sorted) {
|
||||
string name = Thargoid.GetVesselName(k.Key);
|
||||
builder.AppendFormat("{0}x {1}(s) killed\n", k.Value.Count, name);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
List<ThargoidKill> kills = objective.EnabledOfType<ThargoidKill>().ToList();
|
||||
|
||||
if (kills.Count == 0 ) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int drones = kills.Where(x => x.ThargoidType == ThargoidVessel.Revenant).Count();
|
||||
int scouts = kills.Where(x => x.ThargoidType == ThargoidVessel.Scout).Count();
|
||||
int interceptors = kills.Count - scouts - drones;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.Append("AX: ");
|
||||
if (interceptors > 0) {
|
||||
builder.AppendFormat("{0} INT", interceptors);
|
||||
}
|
||||
if (scouts > 0) {
|
||||
if (interceptors > 0) {
|
||||
builder.Append(", ");
|
||||
}
|
||||
builder.AppendFormat("{0} SCT", scouts);
|
||||
}
|
||||
if (drones > 0) {
|
||||
if (interceptors > 0 || scouts > 0) {
|
||||
builder.Append(", ");
|
||||
}
|
||||
builder.AppendFormat("{0} DRN", drones);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
18
Avalonia.EliteBGS/LogGenerator/VistaGenomicsFormat.cs
Normal file
18
Avalonia.EliteBGS/LogGenerator/VistaGenomicsFormat.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
using System.Linq;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
class VistaGenomicsFormat : GenericFormat<OrganicData> {
|
||||
public override string GenerateSummary(Objective objective) {
|
||||
long profit = objective
|
||||
.EnabledOfType<OrganicData>()
|
||||
.Sum(x => x.TotalValue)
|
||||
;
|
||||
if (profit <= 0) {
|
||||
return "";
|
||||
}
|
||||
return string.Format("Organic: {0} Profit", Credits.FormatMillions(profit));
|
||||
}
|
||||
}
|
||||
56
Avalonia.EliteBGS/LogGenerator/VoucherFormat.cs
Normal file
56
Avalonia.EliteBGS/LogGenerator/VoucherFormat.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using EDPlayerJournal;
|
||||
using EDPlayerJournal.BGS;
|
||||
|
||||
namespace EliteBGS.LogGenerator;
|
||||
|
||||
public class VoucherFormat : LogFormatter {
|
||||
public string GenerateLog(Objective objective) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var missions = objective
|
||||
.EnabledOfType<Vouchers>()
|
||||
.GroupBy(x => x.Type)
|
||||
.ToDictionary(x => x.Key, x => x.ToList())
|
||||
;
|
||||
|
||||
if (missions == null || missions.Count() <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (var m in missions) {
|
||||
long total = (long)m.Value.Sum(x => (decimal)x.TotalSum);
|
||||
builder.AppendFormat("Handed in {0} vouchers: {1}\n", m.Key, Credits.FormatMillions(total));
|
||||
}
|
||||
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
public string GenerateSummary(Objective objective) {
|
||||
long bounties = objective
|
||||
.EnabledOfType<Vouchers>()
|
||||
.Where(x => x.Type == "Bounty")
|
||||
.Sum(x => x.TotalSum)
|
||||
;
|
||||
long bonds = objective
|
||||
.EnabledOfType<Vouchers>()
|
||||
.Where(x => x.Type == "Combat Bond")
|
||||
.Sum(x => x.TotalSum)
|
||||
;
|
||||
|
||||
StringBuilder sb = new();
|
||||
|
||||
if (bounties > 0) {
|
||||
sb.AppendFormat("Bounties: {0}", Credits.FormatMillions(bounties));
|
||||
}
|
||||
|
||||
if (bonds > 0) {
|
||||
if (sb.Length > 0) {
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.AppendFormat("Bonds: {0}", Credits.FormatMillions(bonds));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user