using System.Linq; using System.Globalization; using EDJournal; namespace EliteBGS.BGS { public class Vouchers : LogEntry { private string type = null; public Vouchers() { } public Vouchers(RedeemVoucherEntry e) { Entries.Add(e); } public long TotalSum { get { return Entries .OfType() .Where(x => x.FactionBounties.ContainsKey(Faction)) .Sum(x => x.FactionBounties[Faction]) ; } } public string Type { get { if (type == null) { string v = Entries .Where(x => x.GetType() == typeof(RedeemVoucherEntry)) .GroupBy(x => (x as RedeemVoucherEntry).Type) .Select(x => x.Key) .First(); if (v == "CombatBond") { type = "Combat Bond"; } else if (v == "bounty") { type = "Bounty"; } else { type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v); } } return type; } } public override int CompareTo(LogEntry 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)); } } }