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 "";
        }

        foreach (MissionFailed failed in missions) {
            MissionFailedEntry f = failed.Failed;
            builder.AppendFormat("Failed {0} mission(s) \"{1}\" targeting {2}\n",
                failed.Amount,
                string.IsNullOrEmpty(f.Mission.LocalisedName) ? f.Mission.Name : f.Mission.LocalisedName,
                failed.Faction
                );
        }

        return builder.ToString().Trim();
    }
}
