Add adjudicator logger

This commit is contained in:
Jaculabilis 2022-11-06 21:09:22 -08:00
parent 46c28a087c
commit 23a826c815
3 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,13 @@
namespace MultiversalDiplomacy.Adjudicate.Logging;
public class ConsoleLogger : IAdjudicatorLogger
{
public static ConsoleLogger Instance { get; } = new();
public void Log(int contextLevel, string message, params object[] args)
{
string spacing = string.Format($"{{0,{2 * contextLevel}}}", string.Empty);
string formattedMessage = string.Format(message, args);
Console.WriteLine(spacing + formattedMessage);
}
}

View File

@ -0,0 +1,6 @@
namespace MultiversalDiplomacy.Adjudicate.Logging;
public interface IAdjudicatorLogger
{
public void Log(int contextLevel, string message, params object[] args);
}

View File

@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using MultiversalDiplomacy.Adjudicate.Decision;
using MultiversalDiplomacy.Adjudicate.Logging;
using MultiversalDiplomacy.Model;
using MultiversalDiplomacy.Orders;
@ -11,7 +12,14 @@ namespace MultiversalDiplomacy.Adjudicate;
/// </summary>
public class MovementPhaseAdjudicator : IPhaseAdjudicator
{
public static IPhaseAdjudicator Instance { get; } = new MovementPhaseAdjudicator();
public static IPhaseAdjudicator Instance { get; } = new MovementPhaseAdjudicator(ConsoleLogger.Instance);
private IAdjudicatorLogger logger { get; }
public MovementPhaseAdjudicator(IAdjudicatorLogger logger)
{
this.logger = logger;
}
public List<OrderValidation> ValidateOrders(World world, List<Order> orders)
{