refactor missions a bit
This commit is contained in:
@@ -10,8 +10,17 @@ namespace EDPlayerJournal.BGS;
|
||||
/// </summary>
|
||||
public class InfluenceSupport : Transaction {
|
||||
public string Influence { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Relevant mission completed entry
|
||||
/// </summary>
|
||||
public MissionCompletedEntry? RelevantMission { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mission accepted entry
|
||||
/// </summary>
|
||||
public MissionAcceptedEntry? AcceptedEntry { get; set; }
|
||||
|
||||
public override string CompletedAt {
|
||||
get {
|
||||
if (RelevantMission == null) {
|
||||
|
||||
@@ -1,50 +1,52 @@
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
|
||||
public class MissionCompleted : Transaction {
|
||||
public MissionCompletedEntry? CompletedEntry { get; set; }
|
||||
|
||||
public MissionAcceptedEntry? AcceptedEntry { get; set; }
|
||||
|
||||
public MissionCompleted() { }
|
||||
public MissionCompleted(MissionCompletedEntry e) {
|
||||
Entries.Add(e);
|
||||
|
||||
public override string CompletedAt {
|
||||
get {
|
||||
if (CompletedEntry == null) {
|
||||
return "";
|
||||
}
|
||||
return CompletedEntry.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
|
||||
}
|
||||
}
|
||||
|
||||
public string MissionName {
|
||||
get {
|
||||
MissionCompletedEntry? c = Entries[0] as MissionCompletedEntry;
|
||||
if (c == null || c.Mission == null) {
|
||||
if (CompletedEntry == null || CompletedEntry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return c.Mission.FriendlyName;
|
||||
return CompletedEntry.Mission.FriendlyName;
|
||||
}
|
||||
}
|
||||
|
||||
public string Influence {
|
||||
get {
|
||||
MissionCompletedEntry? e = (Entries[0] as MissionCompletedEntry);
|
||||
|
||||
if (e == null || Faction == null || e.Mission == null) {
|
||||
if (CompletedEntry == null || Faction == null || CompletedEntry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return (e.Mission.GetInfluenceForFaction(Faction, SystemAddress) ?? "");
|
||||
return (CompletedEntry.Mission.GetInfluenceForFaction(Faction, SystemAddress) ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
if (Faction == null || Entries.Count <= 0) {
|
||||
if (Faction == null || CompletedEntry == null || CompletedEntry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var entry = Entries[0] as MissionCompletedEntry;
|
||||
|
||||
if (entry == null || entry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var influence = entry.Mission.GetInfluenceForFaction(Faction, SystemAddress);
|
||||
var influence = CompletedEntry.Mission.GetInfluenceForFaction(Faction, SystemAddress);
|
||||
|
||||
builder.AppendFormat("{0}", MissionName);
|
||||
if (influence != "") {
|
||||
|
||||
@@ -360,7 +360,9 @@ public class Report {
|
||||
if (faction.Equals(source_faction_name) && system_address == accepted_address) {
|
||||
/* This is the influence block for the origin of the mission.
|
||||
*/
|
||||
main_mission = new MissionCompleted(completed) {
|
||||
main_mission = new MissionCompleted() {
|
||||
CompletedEntry = completed,
|
||||
AcceptedEntry = accepted,
|
||||
System = accepted_system,
|
||||
Faction = source_faction_name,
|
||||
SystemAddress = accepted_address,
|
||||
|
||||
@@ -499,7 +499,9 @@ internal class MissionCompletedParser : TransactionParserPart {
|
||||
system_address == accepted_location.SystemAddress) {
|
||||
// Source and target faction are the same, and this is the block
|
||||
// for the source system. So we make a full mission completed entry.
|
||||
transactions.Add(new MissionCompleted(entry) {
|
||||
transactions.Add(new MissionCompleted() {
|
||||
CompletedEntry = entry,
|
||||
AcceptedEntry = accepted,
|
||||
System = accepted_location.StarSystem,
|
||||
Faction = source_faction_name,
|
||||
SystemAddress = accepted_location.SystemAddress,
|
||||
@@ -513,6 +515,7 @@ internal class MissionCompletedParser : TransactionParserPart {
|
||||
// differs. Sometimes missions go to different systems but to
|
||||
// the same faction.
|
||||
transactions.Add(new InfluenceSupport() {
|
||||
AcceptedEntry = accepted,
|
||||
Faction = faction,
|
||||
Influence = influences.Value,
|
||||
System = system,
|
||||
|
||||
Reference in New Issue
Block a user