using System.Linq;
using EDJournal;

namespace EliteBGS.BGS.LogGenerator {
    public class CartographicsFormat : LogFormatter {
        public string GenerateLog(Objective objective) {
            var total = objective.LogEntries
                .OfType<Cartographics>()
                .Where(x => x.IsEnabled)
                ;
            var pages = total.Count();
            long sum = total.Sum(x => x.TotalSum);

            if (pages <= 0 || sum <= 0) {
                return "";
            }

            return string.Format("Sold {0} page(s) worth of universal cartographics\n" +
                                 "(Total value: {1})\n\n",
                                 pages, Credits.FormatCredits(sum)
                                 );
        }
    }
}