2022-11-24 19:38:19 +01:00
|
|
|
|
using System.Collections.Generic;
|
2024-04-11 16:25:20 +02:00
|
|
|
|
using System.Linq;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
using EDPlayerJournal.BGS;
|
|
|
|
|
|
|
|
|
|
namespace EliteBGS;
|
|
|
|
|
|
2024-04-11 16:25:20 +02:00
|
|
|
|
public class SystemObjectives {
|
|
|
|
|
public bool IsEnabled { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public bool IsExpanded { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
public string SystemName { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public List<Objective> Objectives { get; set; } = new();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
public class Report {
|
2024-04-11 16:25:20 +02:00
|
|
|
|
public List<SystemObjectives> SystemObjectives { get; set; } = new();
|
2022-11-24 19:38:19 +01:00
|
|
|
|
|
|
|
|
|
public Report() { }
|
|
|
|
|
|
|
|
|
|
public Report(List<Transaction> transactions) {
|
|
|
|
|
Populate(transactions);
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 16:25:20 +02:00
|
|
|
|
public List<Objective> Objectives {
|
|
|
|
|
get {
|
|
|
|
|
return SystemObjectives
|
|
|
|
|
.Where(t => t.IsEnabled)
|
|
|
|
|
.SelectMany(x => x.Objectives)
|
|
|
|
|
.ToList()
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
private void Populate(List<Transaction> transactions) {
|
|
|
|
|
if (transactions == null || transactions.Count == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (Transaction t in transactions) {
|
2024-04-11 16:25:20 +02:00
|
|
|
|
var o = SystemObjectives.Find(x => string.Compare(x.SystemName, t.System) == 0);
|
2022-11-24 19:38:19 +01:00
|
|
|
|
if (o == null) {
|
2024-04-11 16:25:20 +02:00
|
|
|
|
o = new SystemObjectives() { SystemName = t.System };
|
|
|
|
|
SystemObjectives.Add(o);
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
2024-04-11 16:25:20 +02:00
|
|
|
|
var objective = o.Objectives.Find(x => x.Matches(t.System, t.Faction));
|
|
|
|
|
if (objective == null) {
|
|
|
|
|
objective = new Objective() { Faction = t.Faction, System = t.System };
|
|
|
|
|
o.Objectives.Add(objective);
|
|
|
|
|
}
|
|
|
|
|
objective.UITransactions.Add(new UITransaction(t));
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|