EDBGS/EliteBGS/LogGenerator/FailedMissionFormat.cs

39 lines
1.2 KiB
C#
Raw Normal View History

2022-11-24 19:38:19 +01:00
using System.Linq;
using System.Text;
using EDPlayerJournal.Entries;
using EDPlayerJournal.BGS;
namespace EliteBGS.LogGenerator;
public class FailedMissionFormat : LogFormatter {
public string GenerateLog(Objective objective) {
var missions = objective.EnabledOfType<MissionFailed>();
StringBuilder builder = new StringBuilder();
if (missions.Count <= 0) {
return "";
}
2022-12-20 18:33:09 +01:00
foreach (var failed in missions) {
2022-11-24 19:38:19 +01:00
MissionFailedEntry f = failed.Failed;
2022-12-20 18:33:09 +01:00
string name;
if (!string.IsNullOrEmpty(f.Mission.FriendlyName)) {
name = f.Mission.FriendlyName;
} else if (!string.IsNullOrEmpty(f.Mission.LocalisedName)) {
name = f.Mission.LocalisedName;
} else {
name = f.Mission.Name;
}
if (!string.IsNullOrEmpty(failed.Faction)) {
builder.AppendFormat("Failed mission \"{0}\" targeting {1}\n", name, failed.Faction);
} else {
builder.AppendFormat("Failed mission \"{0}\"\n", name);
}
2022-11-24 19:38:19 +01:00
}
return builder.ToString().Trim();
}
}