From 22d0bedf53f3c2f51e7904828fc926fbf3ad3ec5 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Sat, 3 Dec 2022 15:01:46 +0100 Subject: [PATCH] introduce the concept of system contributions --- EDPlayerJournal/BGS/MissionCompleted.cs | 17 +++++++++++++++++ EDPlayerJournal/BGS/Transaction.cs | 10 ++++++++++ EDPlayerJournal/Mission.cs | 2 +- EliteBGS/Objective.cs | 4 ++++ EliteBGS/Report.cs | 13 +++++++++++-- 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/EDPlayerJournal/BGS/MissionCompleted.cs b/EDPlayerJournal/BGS/MissionCompleted.cs index c31997c..a17f7c3 100644 --- a/EDPlayerJournal/BGS/MissionCompleted.cs +++ b/EDPlayerJournal/BGS/MissionCompleted.cs @@ -40,6 +40,23 @@ public class MissionCompleted : Transaction { } } + /// + /// Rescue missions contribute to the system. + /// + public override bool SystemContribution { + get { + if (AcceptedEntry == null || AcceptedEntry.Mission == null) { + return false; + } + + if (AcceptedEntry.Mission.IsRescueMission) { + return true; + } + + return false; + } + } + public override string ToString() { if (Faction == null || CompletedEntry == null || CompletedEntry.Mission == null) { return ""; diff --git a/EDPlayerJournal/BGS/Transaction.cs b/EDPlayerJournal/BGS/Transaction.cs index 9e43887..6048ff5 100644 --- a/EDPlayerJournal/BGS/Transaction.cs +++ b/EDPlayerJournal/BGS/Transaction.cs @@ -21,6 +21,16 @@ public class Transaction : IComparable { } } + /// + /// Whether the transaction helps the entire system. + /// While all transactions are related to one faction, sometimes their + /// overall effect on the system as a whole is more important, than to + /// their faction. For example, rescuing refugees helps the Thargoid war + /// effort in the system as a whole, not just for the faction. + /// So this is true for transactions that help the system as a whole. + /// + public virtual bool SystemContribution { get; } = false; + /// /// Returns true if this transaction was completed in legacy ED /// diff --git a/EDPlayerJournal/Mission.cs b/EDPlayerJournal/Mission.cs index 125cb41..7ee86c1 100644 --- a/EDPlayerJournal/Mission.cs +++ b/EDPlayerJournal/Mission.cs @@ -112,7 +112,7 @@ public class Mission : IComparable { /// /// Passenger type for refugees /// - public static readonly string PassengerTypeRefugee = "PassengerRefugee"; + public static readonly string PassengerTypeRefugee = "Refugee"; public ulong MissionID { get; set; } = 0; diff --git a/EliteBGS/Objective.cs b/EliteBGS/Objective.cs index 330ebfd..052b807 100644 --- a/EliteBGS/Objective.cs +++ b/EliteBGS/Objective.cs @@ -227,6 +227,10 @@ public class Objective : IComparable { 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; diff --git a/EliteBGS/Report.cs b/EliteBGS/Report.cs index beae447..e74bf7d 100644 --- a/EliteBGS/Report.cs +++ b/EliteBGS/Report.cs @@ -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); }