2022-11-01 18:01:28 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
using EDPlayerJournal.Entries;
|
|
|
|
|
|
|
|
|
|
namespace EDPlayerJournal.BGS;
|
|
|
|
|
public class MissionFailed : Transaction {
|
|
|
|
|
public MissionFailedEntry? Failed { get; set; }
|
2022-12-20 18:33:09 +01:00
|
|
|
|
public Mission? Mission { get; set; }
|
2022-11-01 18:01:28 +01:00
|
|
|
|
|
|
|
|
|
public MissionFailed() { }
|
|
|
|
|
|
2022-12-20 18:33:09 +01:00
|
|
|
|
public MissionFailed(MissionFailedEntry failed) {
|
|
|
|
|
Entries.Add(failed);
|
|
|
|
|
Failed = failed;
|
2022-11-01 18:01:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-08 11:43:05 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the amount of influence generated by failing this mission. The
|
|
|
|
|
/// system returns no influence for one INF missions, but sadly also for
|
|
|
|
|
/// when the influence had no affect at all (i.e. during a war).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public long InfluenceAmount {
|
|
|
|
|
get {
|
|
|
|
|
if (Mission == null || string.IsNullOrEmpty(Mission.Influence)) {
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
return Mission.Influence.Length * -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 18:01:28 +01:00
|
|
|
|
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,
|
2022-11-24 14:25:31 +01:00
|
|
|
|
* collate mission failures together
|
|
|
|
|
*/
|
|
|
|
|
if (string.Compare(failed.Failed?.Mission?.Name, Failed?.Mission?.Name) == 0 &&
|
2022-11-01 18:01:28 +01:00
|
|
|
|
failed.Faction == Faction &&
|
|
|
|
|
failed.System == System) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString() {
|
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
|
|
2022-12-20 18:33:09 +01:00
|
|
|
|
if (Failed == null || Mission == null) {
|
2022-11-01 18:01:28 +01:00
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-28 10:43:45 +01:00
|
|
|
|
builder.AppendFormat(" Mission failed: \"{0}\"",
|
2022-12-20 18:33:09 +01:00
|
|
|
|
Mission?.FriendlyName
|
2022-11-01 18:01:28 +01:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return builder.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|