2021-08-04 17:39:57 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Globalization;
|
2021-08-25 16:36:57 +02:00
|
|
|
|
using EDJournal;
|
2021-07-09 11:03:30 +02:00
|
|
|
|
|
2021-11-10 21:24:39 +01:00
|
|
|
|
namespace EliteBGS.BGS {
|
2021-07-09 11:03:30 +02:00
|
|
|
|
public class Vouchers : LogEntry {
|
2021-08-04 17:39:57 +02:00
|
|
|
|
private string type = null;
|
2021-07-09 11:03:30 +02:00
|
|
|
|
|
2022-01-21 20:03:17 +01:00
|
|
|
|
public Vouchers() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vouchers(RedeemVoucherEntry e) {
|
|
|
|
|
Entries.Add(e);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-12 19:50:26 +01:00
|
|
|
|
public long TotalSum {
|
2021-07-09 11:03:30 +02:00
|
|
|
|
get {
|
|
|
|
|
return Entries
|
2022-02-12 19:50:26 +01:00
|
|
|
|
.OfType<RedeemVoucherEntry>()
|
|
|
|
|
.Where(x => x.FactionBounties.ContainsKey(Faction))
|
|
|
|
|
.Sum(x => x.FactionBounties[Faction])
|
2021-07-09 11:03:30 +02:00
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Type {
|
|
|
|
|
get {
|
2021-08-04 17:39:57 +02:00
|
|
|
|
if (type == null) {
|
|
|
|
|
string v = Entries
|
|
|
|
|
.Where(x => x.GetType() == typeof(RedeemVoucherEntry))
|
|
|
|
|
.GroupBy(x => (x as RedeemVoucherEntry).Type)
|
|
|
|
|
.Select(x => x.Key)
|
|
|
|
|
.First();
|
2021-10-07 09:02:34 +02:00
|
|
|
|
if (v == "CombatBond") {
|
|
|
|
|
type = "Combat Bond";
|
|
|
|
|
} else if (v == "bounty") {
|
|
|
|
|
type = "Bounty";
|
|
|
|
|
} else {
|
|
|
|
|
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v);
|
|
|
|
|
}
|
2021-08-04 17:39:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return type;
|
2021-07-09 11:03:30 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-04 17:50:46 +02:00
|
|
|
|
public override int CompareTo(LogEntry other) {
|
2022-02-12 19:50:26 +01:00
|
|
|
|
if (other == null || other.GetType() != typeof(Vouchers)) {
|
2021-08-04 17:50:46 +02:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-12 19:50:26 +01:00
|
|
|
|
Vouchers b = other as Vouchers;
|
|
|
|
|
if (b.Type == Type &&
|
|
|
|
|
b.Faction == Faction &&
|
|
|
|
|
b.System == System &&
|
|
|
|
|
b.Station == Station) {
|
2021-08-04 17:50:46 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-09 11:03:30 +02:00
|
|
|
|
public override string ToString() {
|
2021-08-04 17:39:57 +02:00
|
|
|
|
return string.Format("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum));
|
2021-07-09 11:03:30 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|