
using EDPlayerJournal.Entries;

namespace EDPlayerJournal.BGS;

public class OrganicData : Transaction {
    public OrganicData() { }

    public OrganicData(SellOrganicDataEntry e) {
        Entries.Add(e);
    }

    public long TotalValue {
        get {
            return Entries.OfType<SellOrganicDataEntry>().Sum(x => x.TotalValue);
        }
    }

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

        if (other?.Faction == Faction && 
            other?.System == System && 
            other?.Station == Station) {
            return 0;
        }

        return -1;
    }

    public override string ToString() {
        return string.Format("Sold {0} worth of organic data to Vista Genomics", 
            Credits.FormatCredits(TotalValue)
            );
    }

    /* Selling organic data only helps the controlling faction, just like
     * selling cartographic data.
     * 
     * Right now: Organic data helps no one.
     */
    public override bool OnlyControllingFaction => true;
}
