For Pony's bot, implement a summary line that just shows the highlights of the log
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using EDPlayerJournal.BGS;
 | |
| using System.Collections.Generic;
 | |
| using System.Text;
 | |
| using System;
 | |
| using System.Linq;
 | |
| using EDPlayerJournal;
 | |
| 
 | |
| namespace EliteBGS.LogGenerator;
 | |
| 
 | |
| public class MurderFormat : LogFormatter {
 | |
|     public string GenerateLog(Objective objective) {
 | |
|         var logs = objective
 | |
|             .EnabledOfType<FoulMurder>()
 | |
|             .GroupBy(x => x.CrimeType)
 | |
|             .ToDictionary(x => x.Key, x => x.ToList())
 | |
|             ;
 | |
|         StringBuilder builder = new StringBuilder();
 | |
| 
 | |
|         if (logs == null || logs.Count() <= 0) {
 | |
|             return "";
 | |
|         }
 | |
| 
 | |
|         foreach (var log in logs) {
 | |
|             string type;
 | |
| 
 | |
|             if (string.Compare(log.Key, CrimeTypes.Murder) == 0) {
 | |
|                 if (log.Value.Count > 1) {
 | |
|                     type = "ships";
 | |
|                 } else {
 | |
|                     type = "ship";
 | |
|                 }
 | |
|             } else {
 | |
|                 if (log.Value.Count > 1) {
 | |
|                     type = "people";
 | |
|                 } else {
 | |
|                     type = "person";
 | |
|                 }
 | |
|             }
 | |
|             builder.AppendFormat("Murdered {0} {1} (Bounties: {2}, Fines: {3})",
 | |
|                 log.Value.Count, type,
 | |
|                 log.Value.Sum(x => x.Bounties),
 | |
|                 log.Value.Sum(x => x.Fines)
 | |
|                 );
 | |
|         }
 | |
| 
 | |
|         return builder.ToString();
 | |
|     }
 | |
| 
 | |
|     public string GenerateSummary(Objective objective) {
 | |
|         long murders = objective
 | |
|             .EnabledOfType<FoulMurder>()
 | |
|             .Where(x => x.CrimeType == CrimeTypes.Murder || x.CrimeType == CrimeTypes.OnFootMurder)
 | |
|             .Count()
 | |
|             ;
 | |
| 
 | |
|         if (murders <= 0) {
 | |
|             return "";
 | |
|         }
 | |
| 
 | |
|         return string.Format("Kills: {0}", murders);
 | |
|     }
 | |
| }
 |