示例#1
0
    public static BoardState CheckForCheckAndMate(BoardState state, List <Promotion> promotions)
    {
        Team otherTeam = state.currentMove.Enemy();

        if (IsChecking(otherTeam, state, promotions))
        {
            var validMoves = MoveGenerator.GetAllValidMovesForTeam(state.currentMove, state, promotions);
            if (validMoves.Count == 0)
            {
                state.checkmate = state.currentMove;
            }
            else
            {
                state.check = state.currentMove;
            }
        }

        return(state);
    }