18 lines
566 B
C#
18 lines
566 B
C#
|
|
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();
|
||
|
|
}
|