using System.Collections.Generic;
using EDPlayerJournal.BGS;

namespace EliteBGS;

public class Report {
    public List<Objective> Objectives { get; set; } = new List<Objective>();

    public Report() { }

    public Report(List<Transaction> transactions) {
        Populate(transactions);
    }

    private void Populate(List<Transaction> transactions) {
        if (transactions == null || transactions.Count == 0) {
            return;
        }

        foreach (Transaction t in transactions) {
            Objective o = Objectives.Find(x => x.Matches(t.System, t.Faction));

            if (o == null) {
                o = new Objective() { Faction = t.Faction, System = t.System };
                Objectives.Add(o);
            }

            o.UITransactions.Add(new UITransaction(t));
        }
    }
}