ChessDotNet.Variants.Atomic.AtomicChessGame.WouldBeSuicideOrInvalidSelfMoveInCheck C# (CSharp) Method

WouldBeSuicideOrInvalidSelfMoveInCheck() protected method

protected WouldBeSuicideOrInvalidSelfMoveInCheck ( Move move, Player player ) : bool
move Move
player Player
return bool
        protected virtual bool WouldBeSuicideOrInvalidSelfMoveInCheck(Move move, Player player)
        {
            ChessUtilities.ThrowIfNull(move, "move");
            AtomicChessGame copy = new AtomicChessGame(Board, player);
            copy.ApplyMove(move, true);
            bool ownKingIsGone = copy.KingIsGone(player);
            bool otherKingIsGone = copy.KingIsGone(ChessUtilities.GetOpponentOf(player));
            if (ownKingIsGone)
            {
                return true;
            }
            else if (otherKingIsGone)
            {
                return false;
            }
            else
            {
                return copy.IsInCheck(player);
            }
        }
    }