EDBGS/EDPlayerJournal/BGS/MissionCompleted.cs

80 lines
2.2 KiB
C#
Raw 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-11-01 18:01:28 +01:00
public MissionCompleted() { }
2022-12-03 14:16:45 +01:00
public override string CompletedAt {
get {
if (CompletedEntry == null) {
return "";
}
return CompletedEntry.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
}
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 "";
}
2022-12-03 14:16:45 +01:00
return (CompletedEntry.Mission.GetInfluenceForFaction(Faction, SystemAddress) ?? "");
2022-11-01 18:01:28 +01:00
}
}
/// <summary>
/// Rescue missions contribute to the system.
/// </summary>
public override bool SystemContribution {
get {
if (AcceptedEntry == null ||
AcceptedEntry.Mission == null ||
AcceptedEntry.Mission.Name == null) {
return false;
}
// If the mission starts with the name for thargoid war mission
// names, we assume its a system contribution
if (AcceptedEntry.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 != "") {
builder.AppendFormat(", Influence: {0}", influence);
}
return builder.ToString();
}
}