93 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			93 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using EDPlayerJournal;
 | 
						|
using EDPlayerJournal.BGS;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
 | 
						|
namespace EliteBGS.LogGenerator;
 | 
						|
 | 
						|
class CombatZoneFormat : LogFormatter {
 | 
						|
    public string GenerateLog(Objective objective) {
 | 
						|
        var logs = objective
 | 
						|
            .EnabledOfType<CombatZone>()
 | 
						|
            .OrderBy(x => CombatZones.DifficultyRank(x.Grade))
 | 
						|
            .GroupBy(x => new { x.Type, x.Grade })
 | 
						|
            .ToDictionary(x => x.Key, x => x.ToList())
 | 
						|
            ;
 | 
						|
        StringBuilder builder = new StringBuilder();
 | 
						|
 | 
						|
        if (logs == null || logs.Count() <= 0) {
 | 
						|
            return "";
 | 
						|
        }
 | 
						|
 | 
						|
        foreach (var log in logs) {
 | 
						|
            int optionals = log.Value
 | 
						|
                                .Sum(x => x.OptionalObjectivesCompleted)
 | 
						|
                                ;
 | 
						|
            if (!string.IsNullOrEmpty(log.Key.Grade)) {
 | 
						|
                builder.AppendFormat("Won {0}x {1} {2} Combat Zone(s)",
 | 
						|
                    log.Value.Count,
 | 
						|
                    log.Key.Grade,
 | 
						|
                    log.Key.Type
 | 
						|
                    );
 | 
						|
            } else {
 | 
						|
                builder.AppendFormat("Won {0}x {1} Combat Zone(s)",
 | 
						|
                    log.Value.Count,
 | 
						|
                    log.Key.Type
 | 
						|
                    );
 | 
						|
            }
 | 
						|
 | 
						|
            if (optionals > 0) {
 | 
						|
                builder.AppendFormat(" (with {0} optional objectives)", optionals);
 | 
						|
            }
 | 
						|
            builder.Append("\n");
 | 
						|
        }
 | 
						|
 | 
						|
        return builder.ToString().Trim();
 | 
						|
    }
 | 
						|
 | 
						|
    public string GenerateSummary(Objective objective) {
 | 
						|
        var logs = objective
 | 
						|
            .EnabledOfType<CombatZone>()
 | 
						|
            .OrderBy(x => CombatZones.DifficultyRank(x.Grade))
 | 
						|
            .GroupBy(x => new { x.Type, x.Grade })
 | 
						|
            .ToDictionary(x => x.Key, x => x.ToList())
 | 
						|
            ;
 | 
						|
        StringBuilder builder = new StringBuilder();
 | 
						|
 | 
						|
        if (logs == null || logs.Count() <= 0) {
 | 
						|
            return "";
 | 
						|
        }
 | 
						|
 | 
						|
        foreach (var log in logs) {
 | 
						|
            int optionals = log.Value
 | 
						|
                                .Sum(x => x.OptionalObjectivesCompleted)
 | 
						|
                                ;
 | 
						|
            if (builder.Length > 0) {
 | 
						|
                builder.Append(", ");
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(log.Key.Grade)) {
 | 
						|
                string grade = log.Key.Grade.Substring(0, 1);
 | 
						|
                if (log.Key.Grade == CombatZones.DifficultyVeryHigh) {
 | 
						|
                    grade = "VH";
 | 
						|
                }
 | 
						|
                builder.AppendFormat("CZ: {0}x{1}{2}",
 | 
						|
                    log.Value.Count,
 | 
						|
                    log.Key.Grade.Substring(0, 1),
 | 
						|
                    log.Key.Type.Substring(0, 1)
 | 
						|
                    );
 | 
						|
            } else {
 | 
						|
                builder.AppendFormat("CZ: {0}x?{1}",
 | 
						|
                    log.Value.Count,
 | 
						|
                    log.Key.Type.Substring(0, 1)
 | 
						|
                    );
 | 
						|
            }
 | 
						|
 | 
						|
            if (optionals > 0) {
 | 
						|
                builder.AppendFormat("+ {0} OPTS", optionals);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        return builder.ToString().Trim();
 | 
						|
    }
 | 
						|
}
 |