Archived
1
0
This repository has been archived on 2021-10-19. You can view files and clone it, but cannot push or open issues or pull requests.
nonabgs/BGS/Vouchers.cs

56 lines
1.6 KiB
C#

using System.Linq;
using System.Globalization;
using NonaBGS.Journal;
namespace NonaBGS.BGS {
public class Vouchers : LogEntry {
private string type = null;
public int TotalSum {
get {
return Entries
.Where(x => x.GetType() == typeof(RedeemVoucherEntry))
.Sum(x => (x as RedeemVoucherEntry).Amount)
;
}
}
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();
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v);
}
return type;
}
}
public override int CompareTo(LogEntry other) {
if (other.GetType() != typeof(Vouchers)) {
return -1;
}
var b = other as Vouchers;
if (b.Type == Type) {
return 0;
}
return -1;
}
public override string ToString() {
return string.Format("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum));
}
/// <summary>
/// Vouchers only help the controlling faction
/// </summary>
public override bool OnlyControllingFaction => true;
}
}