introduce the concept of system contributions

This commit is contained in:
2022-12-03 15:01:46 +01:00
parent 1e73c6b7eb
commit 22d0bedf53
5 changed files with 43 additions and 3 deletions

View File

@@ -227,6 +227,10 @@ public class Objective : IComparable<Objective> {
string.Compare(faction, Faction) == 0;
}
public bool Matches(string system) {
return string.Compare(system, System) == 0;
}
public int CompareTo(Objective other) {
return (other.System == System &&
other.Faction == Faction) ? 0 : -1;

View File

@@ -18,10 +18,19 @@ public class Report {
}
foreach (Transaction t in transactions) {
Objective o = Objectives.Find(x => x.Matches(t.System, t.Faction));
Objective o;
if (t.SystemContribution) {
o = Objectives.Find(x => x.Matches(t.System));
} else {
o = Objectives.Find(x => x.Matches(t.System, t.Faction));
}
if (o == null) {
o = new Objective() { Faction = t.Faction, System = t.System };
if (t.SystemContribution) {
o = new Objective() { System = t.System };
} else {
o = new Objective() { Faction = t.Faction, System = t.System };
}
Objectives.Add(o);
}