Compare commits
No commits in common. "8c7e67acc6f6000d3d4f8cdff49c9aa67c5d6b06" and "d19bef33d2acbb38f0c967528a944598184c9c56" have entirely different histories.
8c7e67acc6
...
d19bef33d2
@ -59,39 +59,8 @@ namespace EliteBGS.BGS {
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
|
||||
// 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");
|
||||
}
|
||||
foreach (SellCargo sell in sold) {
|
||||
builder.AppendFormat("{0}\n", sell.ToString());
|
||||
}
|
||||
|
||||
builder.AppendFormat("\n");
|
||||
|
@ -50,16 +50,13 @@ namespace EliteBGS.BGS {
|
||||
where file.NormalisedTimestamp >= start && file.NormalisedTimestamp <= end
|
||||
select file.Entries
|
||||
;
|
||||
Scan(entries.SelectMany(x => x).ToList());
|
||||
}
|
||||
var relevant = from log in entries.SelectMany(array => array)
|
||||
where IsRelevant(log)
|
||||
select log
|
||||
;
|
||||
|
||||
public void Scan(List<Entry> entries) {
|
||||
if (entries.Count <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Entry> relevant = entries.Where(x => IsRelevant(x)).ToList();
|
||||
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
||||
|
||||
Dictionary<string, int> buyCost = new Dictionary<string, int>();
|
||||
|
||||
string current_system = null;
|
||||
|
@ -12,10 +12,16 @@ namespace EliteBGS.BGS {
|
||||
Entries.Add(e);
|
||||
}
|
||||
|
||||
public string Cargo {
|
||||
get {
|
||||
public override string ToString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var sold = Entries.OfType<MarketSellEntry>().ToArray();
|
||||
|
||||
if (sold == null || sold.Length == 0) {
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
foreach (MarketSellEntry sell in sold) {
|
||||
string cargo;
|
||||
var sell = Entries.OfType<MarketSellEntry>().First();
|
||||
|
||||
if (!string.IsNullOrEmpty(sell.TypeLocalised)) {
|
||||
cargo = sell.TypeLocalised;
|
||||
@ -26,34 +32,10 @@ namespace EliteBGS.BGS {
|
||||
}
|
||||
}
|
||||
|
||||
return cargo;
|
||||
}
|
||||
}
|
||||
|
||||
public string Market {
|
||||
get {
|
||||
var sell = Entries.OfType<MarketSellEntry>().First();
|
||||
return sell.BlackMarket ? "Black Market" : "Commodity Market";
|
||||
}
|
||||
}
|
||||
|
||||
public long Amount {
|
||||
get { return Entries.OfType<MarketSellEntry>().Sum(x => x.Count); }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var sold = Entries.OfType<MarketSellEntry>().ToArray();
|
||||
|
||||
if (sold == null || sold.Length == 0) {
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
foreach (MarketSellEntry sell in sold) {
|
||||
builder.AppendFormat("Sold {0} {1} to the {2}",
|
||||
sell.Count,
|
||||
Cargo,
|
||||
Market
|
||||
cargo,
|
||||
sell.BlackMarket ? "Black Market" : "Commodity Market"
|
||||
);
|
||||
|
||||
if (Profit != 0) {
|
||||
|
@ -59,7 +59,6 @@
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -91,9 +90,6 @@
|
||||
<Compile Include="BGS\FactionKillBonds.cs" />
|
||||
<Compile Include="EDDB\PopulatedSystems.cs" />
|
||||
<Compile Include="EDDB\Stations.cs" />
|
||||
<Compile Include="LoadEntriesWindow.xaml.cs">
|
||||
<DependentUpon>LoadEntriesWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
@ -114,10 +110,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="LoadEntriesWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -1,22 +0,0 @@
|
||||
<Window x:Class="EliteBGS.LoadEntriesWindow"
|
||||
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="Load Entries" Height="450" Width="600">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="Lines" AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap" Grid.Row="0" Height="Auto" Grid.Column="0" Grid.ColumnSpan="3" VerticalScrollBarVisibility="Visible" />
|
||||
<Button x:Name="Load" Content="Load Entries" Grid.Row="1" Margin="5,5,5,5" Height="Auto" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Load_Click" />
|
||||
</Grid>
|
||||
</Window>
|
@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using EDJournal;
|
||||
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 LoadEntriesWindow.xaml
|
||||
/// </summary>
|
||||
public partial class LoadEntriesWindow : Window {
|
||||
public delegate void EntriesLoadedDelegate(List<Entry> entries);
|
||||
|
||||
public event EntriesLoadedDelegate EntriesLoaded;
|
||||
|
||||
public LoadEntriesWindow() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Load_Click(object sender, RoutedEventArgs e) {
|
||||
string lines = Lines.Text.Trim();
|
||||
if (lines.Length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
List<Entry> entries = new List<Entry>();
|
||||
|
||||
foreach (string line in lines.Split('\n')) {
|
||||
Entry entry = Entry.Parse(line);
|
||||
entries.Add(entry);
|
||||
}
|
||||
|
||||
if (entries.Count > 0) {
|
||||
EntriesLoaded?.Invoke(entries);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
MessageBox.Show(string.Format("There was an error while parsing the JSON: {0}",
|
||||
exception.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
xmlns:local="clr-namespace:EliteBGS"
|
||||
xmlns:BGS="clr-namespace:EliteBGS.BGS" xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow"
|
||||
mc:Ignorable="d"
|
||||
Title="Elite: Dangerous BGS Helper" Height="520" Width="890" Icon="EliteBGS.ico" Closing="window_Closing">
|
||||
Title="Elite: Dangerous BGS Helper" Height="520" Width="890" Icon="EliteBGS.ico">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@ -49,8 +49,6 @@
|
||||
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
||||
</ToolBar>
|
||||
<TreeView x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp">
|
||||
<TreeView.ItemTemplate>
|
||||
|
@ -29,8 +29,6 @@ namespace EliteBGS {
|
||||
|
||||
public Report Report => report;
|
||||
|
||||
private LoadEntriesWindow loadentries = new LoadEntriesWindow();
|
||||
|
||||
private static readonly List<IDiscordLogGenerator> logtypes = new List<IDiscordLogGenerator>() {
|
||||
new NonaDiscordLog(),
|
||||
new GenericDiscordLog(),
|
||||
@ -45,8 +43,6 @@ namespace EliteBGS {
|
||||
/* ignored */
|
||||
}
|
||||
|
||||
loadentries.EntriesLoaded += Loadentries_EntriesLoaded;
|
||||
|
||||
report.OnLog += Report_OnLog;
|
||||
|
||||
foreach (IDiscordLogGenerator type in logtypes) {
|
||||
@ -87,17 +83,6 @@ namespace EliteBGS {
|
||||
}
|
||||
}
|
||||
|
||||
private void Loadentries_EntriesLoaded(List<Entry> lines) {
|
||||
try {
|
||||
report.Scan(lines);
|
||||
RefreshObjectives();
|
||||
} catch (Exception exception) {
|
||||
Log("Something went terribly wrong while parsing the E:D player journal.");
|
||||
Log("Please send this to CMDR Hekateh:");
|
||||
Log(exception.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void Api_StationsAvailable() {
|
||||
try {
|
||||
stations_db = api.MakeStations();
|
||||
@ -336,13 +321,5 @@ namespace EliteBGS {
|
||||
string template = LogType.SelectedItem.ToString();
|
||||
config.Global.LastUsedDiscordTemplate = template;
|
||||
}
|
||||
|
||||
private void ManuallyParse_Click(object sender, RoutedEventArgs e) {
|
||||
loadentries.Show();
|
||||
}
|
||||
|
||||
private void window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
loadentries.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user