diff --git a/AdjustProfitWindow.xaml b/AdjustProfitWindow.xaml
new file mode 100644
index 0000000..77ac184
--- /dev/null
+++ b/AdjustProfitWindow.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AdjustProfitWindow.xaml.cs b/AdjustProfitWindow.xaml.cs
new file mode 100644
index 0000000..2da7c5e
--- /dev/null
+++ b/AdjustProfitWindow.xaml.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace EliteBGS {
+ ///
+ /// Interaction logic for AdjustProfitWindow.xaml
+ ///
+ public partial class AdjustProfitWindow : Window {
+ public AdjustProfitWindow() {
+ InitializeComponent();
+ }
+
+ private void Cancel_Click(object sender, RoutedEventArgs e) {
+ DialogResult = false;
+ Close();
+ }
+
+ private void Accept_Click(object sender, RoutedEventArgs e) {
+ DialogResult = true;
+ Close();
+ }
+ }
+}
diff --git a/BGS/LogEntry.cs b/BGS/LogEntry.cs
index bf41007..c8ee55f 100644
--- a/BGS/LogEntry.cs
+++ b/BGS/LogEntry.cs
@@ -7,6 +7,8 @@ namespace EliteBGS.BGS {
public class LogEntry : IComparable {
private List entries = new List();
+ public bool IsExpanded { get; set; }
+
///
/// Controlling faction of the station this entry was made/turned into.
///
diff --git a/BGS/Report.cs b/BGS/Report.cs
index 491ea7f..01bb3fc 100644
--- a/BGS/Report.cs
+++ b/BGS/Report.cs
@@ -39,6 +39,7 @@ namespace EliteBGS.BGS {
e.Is(Events.SellMicroResources) ||
e.Is(Events.RedeemVoucher) ||
e.Is(Events.FactionKillBond) ||
+ e.Is(Events.MarketBuy) ||
e.Is(Events.MarketSell)
;
}
@@ -55,6 +56,8 @@ namespace EliteBGS.BGS {
Dictionary acceptedMissions = new Dictionary();
+ Dictionary buyCost = new Dictionary();
+
string current_system = null;
string current_station = null;
string controlling_faction = null;
@@ -91,9 +94,9 @@ namespace EliteBGS.BGS {
}
} else if (e.Is(Events.MissionCompleted)) {
var completed = e as MissionCompletedEntry;
- entry = new MissionCompleted(completed) {
- System = current_system,
- Station = current_station
+ entry = new MissionCompleted(completed) {
+ System = current_system,
+ Station = current_station
};
if (completed.HumanReadableNameWasGenerated) {
/* If the human readable name was generated, we send a log message. Because the
@@ -149,11 +152,28 @@ namespace EliteBGS.BGS {
};
entry.Entries.Add(e);
+ } else if (e.Is(Events.MarketBuy)) {
+ MarketBuyEntry buy = e as MarketBuyEntry;
+ if (string.IsNullOrEmpty(buy.Type) || buy.BuyPrice == 0) {
+ continue;
+ }
+ buyCost[buy.Type] = buy.BuyPrice;
} else if (e.Is(Events.MarketSell)) {
+ MarketSellEntry sell = e as MarketSellEntry;
+ int profit = 0;
+
+ if (!buyCost.ContainsKey(sell.Type)) {
+ OnLog?.Invoke("Could not find buy order for the given commodity. Please adjust profit manually.");
+ } else {
+ int avg = buyCost[sell.Type];
+ profit = sell.TotalSale - (avg * sell.Count);
+ }
+
entry = new SellCargo() {
Faction = controlling_faction,
Station = current_station,
- System = current_system
+ System = current_system,
+ Profit = profit
};
entry.Entries.Add(e);
diff --git a/BGS/SellCargo.cs b/BGS/SellCargo.cs
index 63c5615..fadaba1 100644
--- a/BGS/SellCargo.cs
+++ b/BGS/SellCargo.cs
@@ -4,6 +4,7 @@ using EDJournal;
namespace EliteBGS.BGS {
public class SellCargo : LogEntry {
+ public int Profit { get; set; }
public override string ToString() {
StringBuilder builder = new StringBuilder();
var sold = Entries.OfType().ToArray();
@@ -13,11 +14,18 @@ namespace EliteBGS.BGS {
}
foreach (MarketSellEntry sell in sold) {
- builder.AppendFormat("Sold {0} {1} to the {2}\n",
+ builder.AppendFormat("Sold {0} {1} to the {2}",
sell.Count,
sell.Type,
sell.BlackMarket ? "Black Market" : "Commodity Market"
);
+
+ if (Profit != 0) {
+ builder.AppendFormat(" ({0} {1})",
+ Credits.FormatCredits(Profit),
+ Profit < 0 ? "loss" : "profit"
+ );
+ }
}
return builder.ToString().Trim();
diff --git a/EliteBGS.csproj b/EliteBGS.csproj
index 55ca431..f0c7476 100644
--- a/EliteBGS.csproj
+++ b/EliteBGS.csproj
@@ -77,6 +77,9 @@
MSBuild:Compile
Designer
+
+ AdjustProfitWindow.xaml
+
@@ -102,6 +105,10 @@
CombatZoneDialog.xaml
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
diff --git a/MainWindow.xaml b/MainWindow.xaml
index c93af27..17f1462 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -39,6 +39,8 @@
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index eab830e..764acec 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -277,5 +277,25 @@ namespace EliteBGS {
objective.LogEntries.Add(zone);
RefreshObjectives();
}
+
+ private void AdjustProfit_Click(object sender, RoutedEventArgs e) {
+ if (entries.SelectedItem == null || entries.SelectedItem.GetType() != typeof(SellCargo)) {
+ return;
+ }
+
+ SellCargo sell = entries.SelectedItem as SellCargo;
+ AdjustProfitWindow adjust = new AdjustProfitWindow() { Owner = this };
+
+ adjust.Profit.Text = sell.Profit.ToString();
+
+ if (!(adjust.ShowDialog() ?? false)) {
+ return;
+ }
+
+ if (int.TryParse(adjust.Profit.Text, out int newprofit)) {
+ sell.Profit = newprofit;
+ RefreshObjectives();
+ }
+ }
}
}
diff --git a/README.md b/README.md
index 1a5d0dc..58494d7 100644
--- a/README.md
+++ b/README.md
@@ -24,11 +24,20 @@ will check your Elite Dangerous player journal for completed missions. Currently
recognises the following completed tasks:
* Completed missions
+* Failed missions
* Vouchers, including bounty vouchers, combat bonds, and settlement vouchers (aka intel packages)
* Selling of micro resources (Odyssey only)
* Selling cartography data
* Selling of cargo to stations
+Selling cargo attempts to discern the profit and/or loss, which is helpful to gauge BGS
+impact. But the player journal does not tell the amount of profit in the sell message.
+So the tool looks for a buy a message related to the same commodity, and calculates loss
+and/or profit from that. If the buy of the commodity is not within the time and date range,
+or some other shenanigans happen that the tool does not yet support the profit/loss could
+be wrong. You can use the "Adjust Trade Profit" button to manually adjust the trade profit,
+or you could simply edit the discord log manually.
+
Please note that cartography data, and micro resources only help the controlling faction
of a station. The tool is clever enough to exclude these if the station you turn them in at, is not
controlled by the faction you specified in the objective.
diff --git a/main-entries.png b/main-entries.png
index 6f0975c..102496e 100644
Binary files a/main-entries.png and b/main-entries.png differ
diff --git a/main-objectives.png b/main-objectives.png
index 2f4f725..9d1a5e4 100644
Binary files a/main-objectives.png and b/main-objectives.png differ