2022-11-01 18:01:28 +01:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using EDPlayerJournal.Entries;
|
|
|
|
|
|
|
|
|
|
namespace EDPlayerJournal.BGS;
|
|
|
|
|
|
|
|
|
|
public class Vouchers : Transaction {
|
|
|
|
|
private string? type = null;
|
|
|
|
|
|
|
|
|
|
public Vouchers() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vouchers(RedeemVoucherEntry e) {
|
|
|
|
|
Entries.Add(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long TotalSum {
|
|
|
|
|
get {
|
|
|
|
|
if (Faction == null) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return Entries
|
|
|
|
|
.OfType<RedeemVoucherEntry>()
|
2022-11-25 15:48:00 +01:00
|
|
|
|
.ToList()
|
|
|
|
|
.Sum(x => (long)x.GetBountyForFaction(Faction))
|
2022-11-01 18:01:28 +01:00
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string? Type {
|
|
|
|
|
get {
|
|
|
|
|
if (Entries == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (type == null) {
|
|
|
|
|
string? v = Entries
|
|
|
|
|
.OfType<RedeemVoucherEntry>()
|
|
|
|
|
.GroupBy(x => x.Type)
|
|
|
|
|
.Select(x => x.Key)
|
|
|
|
|
.First();
|
|
|
|
|
if (v == null) {
|
|
|
|
|
return null;
|
2022-12-15 22:52:50 +01:00
|
|
|
|
} else if (v == Bonds.CombatBond) {
|
2022-11-01 18:01:28 +01:00
|
|
|
|
type = "Combat Bond";
|
2022-12-15 22:52:50 +01:00
|
|
|
|
} else if (v == Bonds.Bounty) {
|
2022-11-01 18:01:28 +01:00
|
|
|
|
type = "Bounty";
|
|
|
|
|
} else {
|
|
|
|
|
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int CompareTo(Transaction? other) {
|
|
|
|
|
if (other == null || other.GetType() != typeof(Vouchers)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vouchers? b = other as Vouchers;
|
|
|
|
|
if (b?.Type == Type &&
|
|
|
|
|
b?.Faction == Faction &&
|
|
|
|
|
b?.System == System &&
|
|
|
|
|
b?.Station == Station) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString() {
|
|
|
|
|
return string.Format("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum));
|
|
|
|
|
}
|
|
|
|
|
}
|