detect trade profit, and allow adjusting it
This commit is contained in:
parent
3f1af39ff1
commit
411a0262c1
24
AdjustProfitWindow.xaml
Normal file
24
AdjustProfitWindow.xaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<Window x:Class="EliteBGS.AdjustProfitWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:EliteBGS"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Adjust Trade Profit" Height="130" Width="450">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Label Content="Use this dialog to adjust trade profits" Grid.Row="0" Grid.ColumnSpan="2" />
|
||||||
|
<TextBox x:Name="Profit" Grid.Row="1" Grid.ColumnSpan="2" Margin="10,10,10,10"/>
|
||||||
|
<Button x:Name="Cancel" Content="Cancel" Width="60" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" Margin="5,0,5,0" IsCancel="true" Click="Cancel_Click"/>
|
||||||
|
<Button x:Name="Accept" Content="Accept" Width="60" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" Margin="5,0,5,0" IsDefault="true" Click="Accept_Click" />
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
34
AdjustProfitWindow.xaml.cs
Normal file
34
AdjustProfitWindow.xaml.cs
Normal file
@ -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 {
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for AdjustProfitWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,8 @@ namespace EliteBGS.BGS {
|
|||||||
public class LogEntry : IComparable<LogEntry> {
|
public class LogEntry : IComparable<LogEntry> {
|
||||||
private List<Entry> entries = new List<Entry>();
|
private List<Entry> entries = new List<Entry>();
|
||||||
|
|
||||||
|
public bool IsExpanded { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controlling faction of the station this entry was made/turned into.
|
/// Controlling faction of the station this entry was made/turned into.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -39,6 +39,7 @@ namespace EliteBGS.BGS {
|
|||||||
e.Is(Events.SellMicroResources) ||
|
e.Is(Events.SellMicroResources) ||
|
||||||
e.Is(Events.RedeemVoucher) ||
|
e.Is(Events.RedeemVoucher) ||
|
||||||
e.Is(Events.FactionKillBond) ||
|
e.Is(Events.FactionKillBond) ||
|
||||||
|
e.Is(Events.MarketBuy) ||
|
||||||
e.Is(Events.MarketSell)
|
e.Is(Events.MarketSell)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -55,6 +56,8 @@ namespace EliteBGS.BGS {
|
|||||||
|
|
||||||
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
||||||
|
|
||||||
|
Dictionary<string, int> buyCost = new Dictionary<string, int>();
|
||||||
|
|
||||||
string current_system = null;
|
string current_system = null;
|
||||||
string current_station = null;
|
string current_station = null;
|
||||||
string controlling_faction = null;
|
string controlling_faction = null;
|
||||||
@ -149,11 +152,28 @@ namespace EliteBGS.BGS {
|
|||||||
};
|
};
|
||||||
|
|
||||||
entry.Entries.Add(e);
|
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)) {
|
} 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() {
|
entry = new SellCargo() {
|
||||||
Faction = controlling_faction,
|
Faction = controlling_faction,
|
||||||
Station = current_station,
|
Station = current_station,
|
||||||
System = current_system
|
System = current_system,
|
||||||
|
Profit = profit
|
||||||
};
|
};
|
||||||
|
|
||||||
entry.Entries.Add(e);
|
entry.Entries.Add(e);
|
||||||
|
@ -4,6 +4,7 @@ using EDJournal;
|
|||||||
|
|
||||||
namespace EliteBGS.BGS {
|
namespace EliteBGS.BGS {
|
||||||
public class SellCargo : LogEntry {
|
public class SellCargo : LogEntry {
|
||||||
|
public int Profit { get; set; }
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
var sold = Entries.OfType<MarketSellEntry>().ToArray();
|
var sold = Entries.OfType<MarketSellEntry>().ToArray();
|
||||||
@ -13,11 +14,18 @@ namespace EliteBGS.BGS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (MarketSellEntry sell in sold) {
|
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.Count,
|
||||||
sell.Type,
|
sell.Type,
|
||||||
sell.BlackMarket ? "Black Market" : "Commodity Market"
|
sell.BlackMarket ? "Black Market" : "Commodity Market"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (Profit != 0) {
|
||||||
|
builder.AppendFormat(" ({0} {1})",
|
||||||
|
Credits.FormatCredits(Profit),
|
||||||
|
Profit < 0 ? "loss" : "profit"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.ToString().Trim();
|
return builder.ToString().Trim();
|
||||||
|
@ -77,6 +77,9 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="AdjustProfitWindow.xaml.cs">
|
||||||
|
<DependentUpon>AdjustProfitWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="BGS\DiscordLogGenerator.cs" />
|
<Compile Include="BGS\DiscordLogGenerator.cs" />
|
||||||
<Compile Include="BGS\GenericDiscordLog.cs" />
|
<Compile Include="BGS\GenericDiscordLog.cs" />
|
||||||
<Compile Include="BGS\MissionFailed.cs" />
|
<Compile Include="BGS\MissionFailed.cs" />
|
||||||
@ -102,6 +105,10 @@
|
|||||||
<Compile Include="CombatZoneDialog.xaml.cs">
|
<Compile Include="CombatZoneDialog.xaml.cs">
|
||||||
<DependentUpon>CombatZoneDialog.xaml</DependentUpon>
|
<DependentUpon>CombatZoneDialog.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Page Include="AdjustProfitWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
<Button x:Name="AddFilter" Content="Add Objective" VerticalAlignment="Stretch" Click="AddFilter_Click" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505"/>
|
<Button x:Name="AddFilter" Content="Add Objective" VerticalAlignment="Stretch" Click="AddFilter_Click" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505"/>
|
||||||
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
|
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
|
||||||
<Button x:Name="AddCombatZone" Content="Add Combat Zone Win" VerticalAlignment="Stretch" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505" Click="AddCombatZone_Click"/>
|
<Button x:Name="AddCombatZone" Content="Add Combat Zone Win" VerticalAlignment="Stretch" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505" Click="AddCombatZone_Click"/>
|
||||||
|
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
|
||||||
|
<Button x:Name="AdjustProfit" Content="Adjust Trade Profit" Margin="0" VerticalAlignment="Stretch" Click="AdjustProfit_Click" />
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ToolBar VerticalAlignment="Top" Grid.Row="1" Width="Auto" Margin="0,0,0,0" Height="Auto" Grid.ColumnSpan="3" HorizontalAlignment="Left">
|
<ToolBar VerticalAlignment="Top" Grid.Row="1" Width="Auto" Margin="0,0,0,0" Height="Auto" Grid.ColumnSpan="3" HorizontalAlignment="Left">
|
||||||
<Button x:Name="ParseJournal" Content="Parse Journal" VerticalAlignment="Center" Click="ParseJournal_Click" HorizontalAlignment="Center"/>
|
<Button x:Name="ParseJournal" Content="Parse Journal" VerticalAlignment="Center" Click="ParseJournal_Click" HorizontalAlignment="Center"/>
|
||||||
|
@ -277,5 +277,25 @@ namespace EliteBGS {
|
|||||||
objective.LogEntries.Add(zone);
|
objective.LogEntries.Add(zone);
|
||||||
RefreshObjectives();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,20 @@ will check your Elite Dangerous player journal for completed missions. Currently
|
|||||||
recognises the following completed tasks:
|
recognises the following completed tasks:
|
||||||
|
|
||||||
* Completed missions
|
* Completed missions
|
||||||
|
* Failed missions
|
||||||
* Vouchers, including bounty vouchers, combat bonds, and settlement vouchers (aka intel packages)
|
* Vouchers, including bounty vouchers, combat bonds, and settlement vouchers (aka intel packages)
|
||||||
* Selling of micro resources (Odyssey only)
|
* Selling of micro resources (Odyssey only)
|
||||||
* Selling cartography data
|
* Selling cartography data
|
||||||
* Selling of cargo to stations
|
* 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
|
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
|
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.
|
controlled by the faction you specified in the objective.
|
||||||
|
BIN
main-entries.png
BIN
main-entries.png
Binary file not shown.
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 29 KiB |
Binary file not shown.
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue
Block a user