private bool PiecesCanCheckmate(ChessPiece[] pieces)
{
var kings = pieces.Count(p => p.PieceType == PieceType.King);
var queens = pieces.Count(p => p.PieceType == PieceType.Queen);
var rooks = pieces.Count(p => p.PieceType == PieceType.Rook);
var bishops = pieces.Count(p => p.PieceType == PieceType.Bishop);
var knights = pieces.Count(p => p.PieceType == PieceType.Knight);
var pawns = pieces.Count(p => p.PieceType == PieceType.Pawn);
if (kings < 1)
throw new Exception("Your king is gone! Please report this error to an admin.");
if (pawns > 0 || queens > 0 || rooks > 0)
return true;
if (bishops > 1 || knights > 1) //Forcing a checkmate with 2 knights is near impossible
return true;
if (bishops > 0 && knights > 0)
return true;
return false;
}