EDBGS/EDPlayerJournal/BGS/MissionFailed.cs

53 lines
1.3 KiB
C#

using System.Text;
using EDPlayerJournal.Entries;
namespace EDPlayerJournal.BGS;
public class MissionFailed : Transaction {
public MissionFailedEntry? Failed { get; set; }
public Mission? Mission { get; set; }
public MissionFailed() { }
public MissionFailed(MissionFailedEntry failed) {
Entries.Add(failed);
Failed = failed;
}
public override int CompareTo(Transaction? other) {
if (other == null || other.GetType() != typeof(MissionFailed)) {
return -1;
}
MissionFailed? failed = other as MissionFailed;
if (failed == null) {
return -1;
}
/* if it is the same mission name, the same faction and the same system,
* collate mission failures together
*/
if (string.Compare(failed.Failed?.Mission?.Name, Failed?.Mission?.Name) == 0 &&
failed.Faction == Faction &&
failed.System == System) {
return 0;
}
return -1;
}
public override string ToString() {
StringBuilder builder = new StringBuilder();
if (Failed == null || Mission == null) {
return "";
}
builder.AppendFormat(" Mission failed: \"{0}\"",
Mission?.FriendlyName
);
return builder.ToString();
}
}