26 lines
828 B
C#
26 lines
828 B
C#
|
|
using Chessistics.Engine.Model;
|
||
|
|
|
||
|
|
namespace Chessistics.Engine.Rules;
|
||
|
|
|
||
|
|
public static class MissionChecker
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// Check if all demands for the current mission are satisfied.
|
||
|
|
/// In campaign mode, only checks the current mission's demands.
|
||
|
|
/// In legacy level mode, checks all demands.
|
||
|
|
/// </summary>
|
||
|
|
public static bool AllCurrentDemandsMet(BoardState state)
|
||
|
|
{
|
||
|
|
var missionIndex = state.Campaign?.CurrentMissionIndex ?? 0;
|
||
|
|
return state.Demands.Values
|
||
|
|
.Where(d => d.MissionIndex == missionIndex)
|
||
|
|
.All(d => d.IsSatisfied);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Check if all demands on the board are satisfied (all missions).
|
||
|
|
/// </summary>
|
||
|
|
public static bool AllDemandsMet(BoardState state)
|
||
|
|
=> state.Demands.Values.All(d => d.IsSatisfied);
|
||
|
|
}
|