using EDPlayerJournal.Entries;

namespace EDPlayerJournal.BGS; 
public class FactionKillBonds : Transaction {
    public ulong TotalSum {
        get {
            return (ulong)Entries
                .OfType<FactionKillBondEntry>()
                .Sum(x => (decimal)x.Reward)
                ;
        }
    }

    public string? VictimFaction {
        get {
            return Entries
                .OfType<FactionKillBondEntry>()
                .First()
                .VictimFaction
                ;
        }
    }

    public override int CompareTo(Transaction? other) {
        if (other == null || other.GetType() != typeof(FactionKillBonds)) {
            return -1;
        }

        FactionKillBonds? b = other as FactionKillBonds;
        if (b == null || b.VictimFaction == VictimFaction) {
            return 0;
        }

        return -1;
    }

    public override string ToString() {
        return string.Format("Faction Kill Bonds: {0} against {1}", 
            Credits.FormatCredits(TotalSum),
            VictimFaction);
    }
}
