2021-09-28 14:41:09 +02:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using EDJournal;
|
|
|
|
|
|
2021-11-10 21:24:39 +01:00
|
|
|
|
namespace EliteBGS.BGS {
|
2021-09-28 14:41:09 +02:00
|
|
|
|
public class SellCargo : LogEntry {
|
2022-01-26 09:58:23 +01:00
|
|
|
|
public long Profit { get; set; }
|
2022-01-21 20:03:17 +01:00
|
|
|
|
|
|
|
|
|
public SellCargo() { }
|
|
|
|
|
|
|
|
|
|
public SellCargo(MarketSellEntry e) {
|
|
|
|
|
Entries.Add(e);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-23 16:26:58 +01:00
|
|
|
|
public string Cargo {
|
|
|
|
|
get {
|
2022-01-21 20:47:37 +01:00
|
|
|
|
string cargo;
|
2022-01-23 16:26:58 +01:00
|
|
|
|
var sell = Entries.OfType<MarketSellEntry>().First();
|
2022-01-21 20:47:37 +01:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sell.TypeLocalised)) {
|
|
|
|
|
cargo = sell.TypeLocalised;
|
|
|
|
|
} else {
|
|
|
|
|
cargo = sell.Type;
|
|
|
|
|
if (cargo.Length >= 2) {
|
|
|
|
|
cargo = cargo[0].ToString().ToUpper() + cargo.Substring(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-23 16:26:58 +01:00
|
|
|
|
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) {
|
2022-01-12 17:29:58 +01:00
|
|
|
|
builder.AppendFormat("Sold {0} {1} to the {2}",
|
2021-09-28 14:41:09 +02:00
|
|
|
|
sell.Count,
|
2022-01-23 16:26:58 +01:00
|
|
|
|
Cargo,
|
|
|
|
|
Market
|
2021-09-28 14:41:09 +02:00
|
|
|
|
);
|
2022-01-12 17:29:58 +01:00
|
|
|
|
|
|
|
|
|
if (Profit != 0) {
|
|
|
|
|
builder.AppendFormat(" ({0} {1})",
|
|
|
|
|
Credits.FormatCredits(Profit),
|
|
|
|
|
Profit < 0 ? "loss" : "profit"
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-09-28 14:41:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return builder.ToString().Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Selling resources to a market only helps the controlling faction
|
|
|
|
|
/// </summary>
|
|
|
|
|
public override bool OnlyControllingFaction => true;
|
|
|
|
|
}
|
|
|
|
|
}
|