Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0203008202 | |||
| 03621721b8 | |||
| ccba55ac35 | |||
| 0708880284 | |||
| 18c3073635 | |||
| c43d2ff1d3 | |||
| a3b7623557 | |||
| 1c2fc1e2e6 | |||
| 53da6b4bc2 | |||
| bc44ceb205 | |||
| 4d3048a37d | |||
| 463598c779 | |||
| bf56f3a2d5 |
84
EDPlayerJournal/BGS/Parsers/RedeemVoucherParser.cs
Normal file
84
EDPlayerJournal/BGS/Parsers/RedeemVoucherParser.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS.Parsers;
|
||||
|
||||
internal class RedeemVoucherParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
RedeemVoucherEntry? entry = e as RedeemVoucherEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (context.CurrentSystem == null) {
|
||||
transactions.AddIncomplete(new Vouchers(),
|
||||
"Could not find out where the vouchers were redeemed", e
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Faction>? current_factions = context.GetFactions(context.CurrentSystem);
|
||||
if (current_factions == null) {
|
||||
transactions.AddIncomplete(new Vouchers(),
|
||||
"Current system factions are unknown, so vouchers were ineffective", e);
|
||||
}
|
||||
|
||||
foreach (string faction in entry.Factions) {
|
||||
bool relevantBond = false;
|
||||
string relevantFaction = faction;
|
||||
|
||||
if (string.Compare(faction, Factions.PilotsFederationVouchers) == 0) {
|
||||
// Target faction is pilots' federation, so we assume thargoid bonks
|
||||
// Also assign this combat bond to the Pilots Federation
|
||||
relevantFaction = Factions.PilotsFederation;
|
||||
relevantBond = true;
|
||||
}
|
||||
|
||||
if (current_factions != null && !relevantBond) {
|
||||
// If we have local factions, and it ain't thargoid bonds see if the bonds were
|
||||
// useful in the current system
|
||||
if (current_factions.Find(x => string.Compare(x.Name, faction, true) == 0) != null) {
|
||||
relevantBond = true;
|
||||
} else {
|
||||
transactions.AddIncomplete(new Vouchers(),
|
||||
string.Format("Vouchers for \"{0}\" had no effect in \"{1}\" since said " +
|
||||
"faction is not present there", faction, context.CurrentSystem), e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!relevantBond) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var voucher = new Vouchers(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = relevantFaction,
|
||||
ControllingFaction = context.ControllingFaction,
|
||||
IsLegacy = context.IsLegacy,
|
||||
};
|
||||
|
||||
if (options.FilterDoubleRedeemVouchers) {
|
||||
// To filter out doubly redeemed vouchers, find another redeem voucher
|
||||
// event that happened in the same system, same total sum, and also the
|
||||
// same faction. If there is one, filter this one out.
|
||||
var doubledEntry = transactions
|
||||
.OfType<Vouchers>()
|
||||
.Where(x => x.TotalSum == voucher.TotalSum &&
|
||||
x.System == voucher.System &&
|
||||
x.Faction == voucher.Faction)
|
||||
.ToList()
|
||||
;
|
||||
if (doubledEntry.Count > 0) {
|
||||
transactions.AddIncomplete(
|
||||
voucher,
|
||||
string.Format("A doubled redeem voucher for {0} valued {1} was detected",
|
||||
voucher.Faction, Credits.FormatMillions(voucher.TotalSum)),
|
||||
e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
transactions.Add(voucher);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,10 +49,11 @@ public class SellCargo : Transaction {
|
||||
}
|
||||
|
||||
foreach (MarketSellEntry sell in sold) {
|
||||
builder.AppendFormat("Sold {0} {1} to the {2}",
|
||||
builder.AppendFormat("Sold {0} {1} to the {2} of {3}",
|
||||
sell.Count,
|
||||
Cargo,
|
||||
Market
|
||||
Market,
|
||||
Station
|
||||
);
|
||||
|
||||
if (Profit != 0) {
|
||||
|
||||
@@ -28,6 +28,14 @@ public class TransactionParserOptions {
|
||||
/// Whether we should ignore things done for the fleet carrier faction.
|
||||
/// </summary>
|
||||
public bool IgnoreFleetCarrierFaction { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Filter out double redeem vouchers that happen when you redeem a specific
|
||||
/// voucher, and then redeem the rest of your vouchers (say from a KWS) in
|
||||
/// bulk. The bulk redeem will also list the first voucher redeem again in
|
||||
/// its bulk list.
|
||||
/// </summary>
|
||||
public bool FilterDoubleRedeemVouchers { get; set; } = true;
|
||||
}
|
||||
|
||||
public class TransactionList : List<Transaction> {
|
||||
@@ -422,63 +430,6 @@ internal class MissionFailedParser : ITransactionParserPart {
|
||||
}
|
||||
}
|
||||
|
||||
internal class RedeemVoucherParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
RedeemVoucherEntry? entry = e as RedeemVoucherEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (context.CurrentSystem == null) {
|
||||
transactions.AddIncomplete(new Vouchers(),
|
||||
"Could not find out where the vouchers were redeemed", e
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Faction>? current_factions = context.GetFactions(context.CurrentSystem);
|
||||
if (current_factions == null) {
|
||||
transactions.AddIncomplete(new Vouchers(),
|
||||
"Current system factions are unknown, so vouchers were ineffective", e);
|
||||
}
|
||||
|
||||
foreach (string faction in entry.Factions) {
|
||||
bool relevantBond = false;
|
||||
string relevantFaction = faction;
|
||||
|
||||
if (string.Compare(faction, Factions.PilotsFederationVouchers) == 0) {
|
||||
// Target faction is pilots' federation, so we assume thargoid bonks
|
||||
// Also assign this combat bond to the Pilots Federation
|
||||
relevantFaction = Factions.PilotsFederation;
|
||||
relevantBond = true;
|
||||
}
|
||||
|
||||
if (current_factions != null && !relevantBond) {
|
||||
// If we have local factions, and it ain't thargoid bonds see if the bonds were
|
||||
// useful in the current system
|
||||
if (current_factions.Find(x => string.Compare(x.Name, faction, true) == 0) != null) {
|
||||
relevantBond = true;
|
||||
} else {
|
||||
transactions.AddIncomplete(new Vouchers(),
|
||||
string.Format("Vouchers for \"{0}\" had no effect in \"{1}\" since said " +
|
||||
"faction is not present there", faction, context.CurrentSystem), e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (relevantBond) {
|
||||
transactions.Add(new Vouchers(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = relevantFaction,
|
||||
ControllingFaction = context.ControllingFaction,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class SellMicroResourcesParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
SellMicroResourcesEntry? entry = e as SellMicroResourcesEntry;
|
||||
|
||||
7
EDPlayerJournalTests/double-vouchers-2.txt
Normal file
7
EDPlayerJournalTests/double-vouchers-2.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
{"timestamp":"2024-04-27T13:27:08Z","event":"Fileheader","part":1,"language":"English/UK","Odyssey":true,"gameversion":"4.0.0.1803","build":"r301470/r0 "}
|
||||
{"timestamp":"2024-04-27T13:27:34Z","event":"Commander","FID":"F9183790","Name":"Jeremaya"}
|
||||
{"timestamp":"2024-04-27T15:06:31Z","event":"FSDJump","Taxi":false,"Multicrew":false,"StarSystem":"HIP 3318","SystemAddress":525890177387,"StarPos":[50.21875,-190.6875,37.5],"SystemAllegiance":"Empire","SystemEconomy":"$economy_Refinery;","SystemEconomy_Localised":"Refinery","SystemSecondEconomy":"$economy_Extraction;","SystemSecondEconomy_Localised":"Extraction","SystemGovernment":"$government_Patronage;","SystemGovernment_Localised":"Patronage","SystemSecurity":"$SYSTEM_SECURITY_high;","SystemSecurity_Localised":"High Security","Population":239484,"Body":"HIP 3318 A","BodyID":2,"BodyType":"Star","JumpDist":27.495,"FuelUsed":3.115176,"FuelLevel":13.228082,"Factions":[{"Name":"HIP 3318 Autocracy","FactionState":"None","Government":"Dictatorship","Influence":0.119192,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":0.0},{"Name":"Chakho Gold Galactic Limited","FactionState":"None","Government":"Corporate","Influence":0.09798,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":0.0},{"Name":"HIP 3318 Interstellar","FactionState":"None","Government":"Corporate","Influence":0.075758,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":0.0},{"Name":"HIP 3318 Values Party","FactionState":"None","Government":"Democracy","Influence":0.032323,"Allegiance":"Independent","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":0.0},{"Name":"Nationalists of HIP 3318","FactionState":"None","Government":"Dictatorship","Influence":0.035354,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":0.0},{"Name":"Nova Paresa","FactionState":"Boom","Government":"Patronage","Influence":0.434343,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","SquadronFaction":true,"MyReputation":100.0,"PendingStates":[{"State":"Expansion","Trend":0}]},{"Name":"Empire Consulate Ltd","FactionState":"None","Government":"Patronage","Influence":0.20505,"Allegiance":"Empire","Happiness":"$Faction_HappinessBand2;","Happiness_Localised":"Happy","MyReputation":94.474998}],"SystemFaction":{"Name":"Nova Paresa","FactionState":"Boom"}}
|
||||
{"timestamp":"2024-04-27T15:12:23Z","event":"ApproachSettlement","Name":"Koh Biological Installation","MarketID":3803792128,"StationFaction":{"Name":"Nova Paresa","FactionState":"Boom"},"StationGovernment":"$government_Patronage;","StationGovernment_Localised":"Patronage","StationAllegiance":"Empire","StationServices":["dock","autodock","commodities","contacts","exploration","missions","refuel","repair","engineer","missionsgenerated","flightcontroller","stationoperations","searchrescue","stationMenu"],"StationEconomy":"$economy_HighTech;","StationEconomy_Localised":"High Tech","StationEconomies":[{"Name":"$economy_HighTech;","Name_Localised":"High Tech","Proportion":1.0}],"SystemAddress":525890177387,"BodyID":26,"BodyName":"HIP 3318 D 3","Latitude":-0.893061,"Longitude":-62.928345}
|
||||
{"timestamp":"2024-04-27T15:14:08Z","event":"Docked","StationName":"Koh Biological Installation","StationType":"OnFootSettlement","Taxi":false,"Multicrew":false,"StarSystem":"HIP 3318","SystemAddress":525890177387,"MarketID":3803792128,"StationFaction":{"Name":"Nova Paresa","FactionState":"Boom"},"StationGovernment":"$government_Patronage;","StationGovernment_Localised":"Patronage","StationAllegiance":"Empire","StationServices":["dock","autodock","commodities","contacts","exploration","missions","refuel","repair","engineer","missionsgenerated","flightcontroller","stationoperations","searchrescue","stationMenu"],"StationEconomy":"$economy_HighTech;","StationEconomy_Localised":"High Tech","StationEconomies":[{"Name":"$economy_HighTech;","Name_Localised":"High Tech","Proportion":1.0}],"DistFromStarLS":11972.63409,"LandingPads":{"Small":1,"Medium":0,"Large":1}}
|
||||
{"timestamp":"2024-04-27T15:15:10Z","event":"RedeemVoucher","Type":"bounty","Amount":9449329,"Factions":[{"Faction":"Nova Paresa","Amount":9449329}]}
|
||||
{"timestamp":"2024-04-27T15:15:51Z","event":"RedeemVoucher","Type":"bounty","Amount":18780130,"Factions":[{"Faction":"","Amount":224449},{"Faction":"","Amount":730880},{"Faction":"","Amount":1272764},{"Faction":"","Amount":580384},{"Faction":"","Amount":10180261},{"Faction":"","Amount":1413153},{"Faction":"","Amount":1365934},{"Faction":"","Amount":202193},{"Faction":"Nova Paresa","Amount":9449329},{"Faction":"","Amount":104412},{"Faction":"","Amount":2453443},{"Faction":"","Amount":252257}]}
|
||||
@@ -1,5 +1,21 @@
|
||||
# EliteBGS changelog
|
||||
|
||||
## 0.4.2 on 02.05.2024
|
||||
|
||||
* Add a bot header for all generated logs that shows the tool version, as
|
||||
well as the name of of the log format used. This makes it easier for bots
|
||||
to parse these logs. Since the different formats have become popular, its
|
||||
always good to make it easier for bots to parse the logs.
|
||||
|
||||
## 0.4.1 on 28.04.2024
|
||||
|
||||
* Filter out vouchers that are redeemed twice, due to bulk turn-in. If you
|
||||
redeem a singular voucher for value X, and then redeem the rest of your
|
||||
vouchers - say KWS vouchers - in bulk, the first voucher of value X will
|
||||
appear again in the logs. It appears twice in the logs, but only counts
|
||||
once.
|
||||
* Add the market name to the trading log entries.
|
||||
|
||||
## 0.4.0 on 13.04.2024
|
||||
|
||||
* Change layout of the results into System -> Faction -> Transaction.
|
||||
|
||||
@@ -111,10 +111,6 @@ public class DiscordLogGenerator {
|
||||
|
||||
string summary = GenerateSummary(objective);
|
||||
|
||||
log.AppendFormat("**Log Generated:** {0} by {1}\n",
|
||||
DateTime.Now.ToString("dd/MM/yyyy"),
|
||||
GetToolVersion()
|
||||
);
|
||||
var earliest = GetDateOfEarliestEntry(objective);
|
||||
var latest = GetDateOfLatestEntry(objective);
|
||||
if (earliest != null && latest != null) {
|
||||
@@ -125,7 +121,7 @@ public class DiscordLogGenerator {
|
||||
}
|
||||
log.AppendFormat("**Target:** {0}\n", location);
|
||||
if (!string.IsNullOrEmpty(summary)) {
|
||||
log.AppendFormat("**Summary**: {0}\n", summary);
|
||||
log.AppendFormat("**Summary:** {0}\n", summary);
|
||||
}
|
||||
if (legacycount > 0) {
|
||||
log.AppendFormat("**Warning:** Some actions were performed on ED Legacy\n");
|
||||
@@ -149,6 +145,16 @@ public class DiscordLogGenerator {
|
||||
return log;
|
||||
}
|
||||
|
||||
public virtual string Name {
|
||||
get { return "GenericLog"; }
|
||||
}
|
||||
|
||||
protected virtual string BotHeader() {
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("**Bot-Header:** {0}; {1}\n", GetToolVersion(), this.Name);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public virtual string GenerateDiscordLog(Report report) {
|
||||
StringBuilder log = new StringBuilder();
|
||||
|
||||
@@ -164,6 +170,7 @@ public class DiscordLogGenerator {
|
||||
return "";
|
||||
}
|
||||
|
||||
log.AppendFormat("{0}", BotHeader());
|
||||
log.AppendFormat("{0}", GenerateHeader());
|
||||
|
||||
foreach (Objective objective in objectives) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<Version>0.4.0</Version>
|
||||
<Version>0.4.2</Version>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<UseWPF>true</UseWPF>
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
public class GenericDiscordLog : DiscordLogGenerator {
|
||||
public override string ToString() {
|
||||
return "Generic Log";
|
||||
return "Generic";
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
get { return "Generic"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public partial class MainWindow : MetroWindow {
|
||||
private LoadEntriesWindow loadentries = null;
|
||||
|
||||
private static readonly List<DiscordLogGenerator> logtypes = new List<DiscordLogGenerator>() {
|
||||
new NonaDiscordLog(),
|
||||
new GenericDiscordLog(),
|
||||
new NonaDiscordLog(),
|
||||
new OneLineDiscordLog(),
|
||||
};
|
||||
|
||||
@@ -109,6 +109,8 @@ public partial class MainWindow : MetroWindow {
|
||||
{ "NovaNavy", Color.FromRgb(0xA1, 0xA4, 0xDB) },
|
||||
// Official Red of the Polish Flag
|
||||
{ "PolskaGurom", Color.FromRgb(0xD4, 0x21, 0x3D) },
|
||||
// Official Blue in the Armenian Flag
|
||||
{ "ArmeniaBlue", Color.FromRgb(0x00, 0x33, 0xA0) },
|
||||
};
|
||||
|
||||
foreach (var colourtheme in colorThemes) {
|
||||
|
||||
@@ -7,6 +7,12 @@ using System.Linq;
|
||||
namespace EliteBGS.BGS;
|
||||
|
||||
public class NonaDiscordLog : DiscordLogGenerator {
|
||||
protected override string BotHeader() {
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat(":robot: `Bot-Header:` {0}; {1}\n", GetToolVersion(), this.Name);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string FormatDate() {
|
||||
CultureInfo cultureInfo = CultureInfo.InvariantCulture;
|
||||
StringBuilder date = new StringBuilder();
|
||||
@@ -79,6 +85,10 @@ public class NonaDiscordLog : DiscordLogGenerator {
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "Nova Navy Log";
|
||||
return "Nova Navy";
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
get { return "NovaNavy"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ public class OneLineDiscordLog : DiscordLogGenerator {
|
||||
return "";
|
||||
}
|
||||
|
||||
log.AppendFormat("{0}", BotHeader());
|
||||
|
||||
foreach (Objective objective in objectives) {
|
||||
log.AppendFormat("{0}", GenerateObjectiveHeader(objective));
|
||||
|
||||
@@ -60,6 +62,10 @@ public class OneLineDiscordLog : DiscordLogGenerator {
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "One Line Report";
|
||||
return "One Line";
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
get { return "OneLine"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.0.0")]
|
||||
[assembly: AssemblyVersion("0.4.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.2.0")]
|
||||
|
||||
Reference in New Issue
Block a user