using System.Linq;
using System.Text;
using EDPlayerJournal;
using EDPlayerJournal.BGS;

namespace EliteBGS.LogGenerator;

public class VoucherFormat : LogFormatter {
    public string GenerateLog(Objective objective) {
        StringBuilder builder = new StringBuilder();
        var missions = objective.UITransactions
            .Where(x => x.IsEnabled)
            .Select(x => x.Transaction)
            .OfType<Vouchers>()
            ;

        if (missions == null || missions.Count() <= 0) {
            return "";
        }

        foreach (var m in missions) {
            builder.AppendFormat("Handed in {0} vouchers: {1}\n", m.Type, Credits.FormatCredits(m.TotalSum));
        }

        return builder.ToString().Trim();
    }
}
