示例#1
0
        /// <summary>
        ///     Applies a move to the current board.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="san">Simple Algebraic Notation of move.</param>
        /// <param name="moveApplicationStrategy">Strategy for how move should be applied</param>
        /// <remarks>
        ///     After adding move to <see cref="NodeBase{T}.Continuations" />, <see cref="GameEnumerator.Current" /> is
        ///     adjusted to reflect new board state.
        /// </remarks>
        public static Game ApplyMove(this Game game, string san, MoveApplicationStrategy moveApplicationStrategy)
        {
            Debug.Assert(game?.Current != null);
            var move = sanToMove.GetMoveFromSAN(game.Current.Board, san);

            game.ApplyMove(move, moveApplicationStrategy);
            return(game);
        }
示例#2
0
        public static Game ApplyMove(this Game game, Move move, MoveApplicationStrategy moveApplicationStrategy)
        {
            Debug.Assert(game?.Current != null);
            var postMoveBoardNode = BoardNodeFactory.ApplyMoveToBoard(game.Current, move);

            game.Current.Node.AddNode(postMoveBoardNode.Node);
            game.Current = postMoveBoardNode;
            return(game);
        }