EDBGS/EliteBGS/Report.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2022-11-24 19:38:19 +01:00
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;
if (t.SystemContribution) {
o = Objectives.Find(x => x.Matches(t.System));
} else {
o = Objectives.Find(x => x.Matches(t.System, t.Faction));
}
2022-11-24 19:38:19 +01:00
if (o == null) {
if (t.SystemContribution) {
o = new Objective() { System = t.System };
} else {
o = new Objective() { Faction = t.Faction, System = t.System };
}
2022-11-24 19:38:19 +01:00
Objectives.Add(o);
}
o.UITransactions.Add(new UITransaction(t));
}
}
}