group cargo together in the final report
This commit is contained in:
parent
0fdd51a3ec
commit
8c7e67acc6
@ -59,8 +59,39 @@ namespace EliteBGS.BGS {
|
|||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SellCargo sell in sold) {
|
|
||||||
builder.AppendFormat("{0}\n", sell.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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.AppendFormat("\n");
|
builder.AppendFormat("\n");
|
||||||
|
@ -12,16 +12,10 @@ namespace EliteBGS.BGS {
|
|||||||
Entries.Add(e);
|
Entries.Add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() {
|
public string Cargo {
|
||||||
StringBuilder builder = new StringBuilder();
|
get {
|
||||||
var sold = Entries.OfType<MarketSellEntry>().ToArray();
|
|
||||||
|
|
||||||
if (sold == null || sold.Length == 0) {
|
|
||||||
return builder.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (MarketSellEntry sell in sold) {
|
|
||||||
string cargo;
|
string cargo;
|
||||||
|
var sell = Entries.OfType<MarketSellEntry>().First();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(sell.TypeLocalised)) {
|
if (!string.IsNullOrEmpty(sell.TypeLocalised)) {
|
||||||
cargo = sell.TypeLocalised;
|
cargo = sell.TypeLocalised;
|
||||||
@ -32,10 +26,34 @@ 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}",
|
builder.AppendFormat("Sold {0} {1} to the {2}",
|
||||||
sell.Count,
|
sell.Count,
|
||||||
cargo,
|
Cargo,
|
||||||
sell.BlackMarket ? "Black Market" : "Commodity Market"
|
Market
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Profit != 0) {
|
if (Profit != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user