EliteBGS/BGS/Vouchers.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2021-08-04 17:39:57 +02:00
using System.Linq;
using System.Globalization;
2021-07-09 11:03:30 +02:00
using NonaBGS.Journal;
namespace NonaBGS.BGS {
public class Vouchers : LogEntry {
2021-08-04 17:39:57 +02:00
private string type = null;
2021-07-09 11:03:30 +02:00
public int TotalSum {
get {
return Entries
.Where(x => x.GetType() == typeof(RedeemVoucherEntry))
.Sum(x => (x as RedeemVoucherEntry).Amount)
;
}
}
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();
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v);
}
return type;
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
}
/// <summary>
/// Vouchers only help the controlling faction
/// </summary>
public override bool OnlyControllingFaction => true;
}
}