Beispiel #1
0
        /* This method takes care of verifying if is possible to checkmate based on the color of the player,
         * checking for each piece whether with a move it is possible to "eat" the opposing king. */
        private bool IsCheckMate(bool isWhite)
        {
            bool result = false;

            if (isWhite)
            {
                foreach (Piece piece in blackPieces)
                {
                    if (piece.CheckMove(GetKingPosition()))
                    {
                        result = true;
                    }
                }
            }
            else
            {
                foreach (Piece piece in whitePieces)
                {
                    if (piece.CheckMove(GetKingPosition(false)))
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }