using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EDJournal;

namespace EliteBGS.BGS {
    public class OrganicData : LogEntry {
        public OrganicData(SellOrganicDataEntry e) {
            Entries.Add(e);
        }

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

        public override int CompareTo(LogEntry 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.
         */
        public override bool OnlyControllingFaction => true;
    }
}