EDBGS/EDPlayerJournal/BGS/MissionCompleted.cs

89 lines
2.4 KiB
C#
Raw Permalink Normal View History

2022-12-03 14:16:45 +01:00
using System.Collections.Generic;
using System.Text;
2022-11-01 18:01:28 +01:00
using EDPlayerJournal.Entries;
namespace EDPlayerJournal.BGS;
public class MissionCompleted : Transaction {
2022-12-03 14:16:45 +01:00
public MissionCompletedEntry? CompletedEntry { get; set; }
public MissionAcceptedEntry? AcceptedEntry { get; set; }
2022-12-20 18:33:09 +01:00
public Mission? Mission { get; set; }
2022-11-01 18:01:28 +01:00
public MissionCompleted() { }
2022-12-03 14:16:45 +01:00
public override DateTime? CompletedAtDateTime {
2022-12-03 14:16:45 +01:00
get {
if (CompletedEntry == null) {
return null;
2022-12-03 14:16:45 +01:00
}
return CompletedEntry.Timestamp;
2022-12-03 14:16:45 +01:00
}
2022-11-01 18:01:28 +01:00
}
public string MissionName {
get {
2022-12-03 14:16:45 +01:00
if (CompletedEntry == null || CompletedEntry.Mission == null) {
2022-11-01 18:01:28 +01:00
return "";
}
2022-12-03 14:16:45 +01:00
return CompletedEntry.Mission.FriendlyName;
2022-11-01 18:01:28 +01:00
}
}
public string Influence {
get {
2022-12-03 14:16:45 +01:00
if (CompletedEntry == null || Faction == null || CompletedEntry.Mission == null) {
2022-11-01 18:01:28 +01:00
return "";
}
return string.Join("",
CompletedEntry
.Mission
.GetInfluenceForFaction(Faction, SystemAddress)
.Select(x => x.Influence)
.ToArray()
)
;
2022-11-01 18:01:28 +01:00
}
}
/// <summary>
/// Rescue missions contribute to the system.
/// </summary>
public override bool SystemContribution {
get {
2022-12-20 18:33:09 +01:00
if (Mission == null || Mission.Name == null) {
return false;
}
// If the mission starts with the name for thargoid war mission
// names, we assume its a system contribution
2022-12-20 18:33:09 +01:00
if (Mission.Name.Contains("Mission_TW_")) {
return true;
}
return false;
}
}
2022-11-01 18:01:28 +01:00
public override string ToString() {
2022-12-03 14:16:45 +01:00
if (Faction == null || CompletedEntry == null || CompletedEntry.Mission == null) {
2022-11-01 18:01:28 +01:00
return "";
}
StringBuilder builder = new StringBuilder();
2022-12-03 14:16:45 +01:00
var influence = CompletedEntry.Mission.GetInfluenceForFaction(Faction, SystemAddress);
2022-11-01 18:01:28 +01:00
builder.AppendFormat("{0}", MissionName);
if (influence != null && influence.Length > 0) {
builder.AppendFormat(", Influence: {0}",
influence.Select(x => x.InfluenceAmount).Sum()
);
2022-11-01 18:01:28 +01:00
}
return builder.ToString();
}
}