EliteBGS/BGS/SellCargo.cs

58 lines
1.7 KiB
C#
Raw Normal View History

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