Chessistics/chessistics-engine/Rules/VictoryChecker.cs

18 lines
566 B
C#
Raw Normal View History

using Chessistics.Engine.Model;
namespace Chessistics.Engine.Rules;
public static class VictoryChecker
{
public static bool AllDemandsMet(BoardState state)
=> state.Demands.Values.All(d => d.IsSatisfied);
public static bool AnyDeadlineExpired(BoardState state)
=> state.TurnNumber > state.MaxDeadline && !AllDemandsMet(state);
public static IReadOnlyList<DemandState> GetExpiredDemands(BoardState state)
=> state.Demands.Values
.Where(d => !d.IsSatisfied && state.TurnNumber > d.Deadline)
.ToList();
}