Ejemplo n.º 1
0
        public void FullMoveCount_should_count_pairwise_halfmoves()
        {
            var sut = new MoveTextEntryList {
                new HalfMoveEntry(new Move()), new HalfMoveEntry(new Move())
            };

            Assert.Equal(1, sut.FullMoveCount);
            Assert.Equal(2, sut.MoveCount);
        }
Ejemplo n.º 2
0
        public void FullMoveCount_should_not_count_single_halfmoves()
        {
            var sut = new MoveTextEntryList {
                new HalfMoveEntry(new Move())
            };

            Assert.Equal(0, sut.FullMoveCount);
            Assert.Equal(1, sut.MoveCount);
        }
Ejemplo n.º 3
0
        public void FullMoveCount_should_return_move_count_without_comments()
        {
            var sut = new MoveTextEntryList
            {
                new CommentEntry("foo"),
                new NAGEntry(1),
                new RAVEntry(new MoveTextEntryList {
                    new MovePairEntry(new Move(), new Move())
                }),
                new MovePairEntry(new Move(), new Move()),
                new MovePairEntry(new Move(), new Move()),
                new GameEndEntry(GameResult.Draw)
            };

            Assert.Equal(2, sut.FullMoveCount);
            Assert.Equal(4, sut.MoveCount);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a <see cref="RAVEntry"/>.
 /// </summary>
 /// <param name="moveText">The inner move text of the RAV.</param>
 public RAVEntry(MoveTextEntryList moveText)
     : base(MoveTextEntryType.RecursiveAnnotationVariation)
 {
     MoveText = moveText;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Game"/> class.
 /// </summary>
 public Game()
 {
     AdditionalInfo = new List<GameInfo>();
     MoveText = new MoveTextEntryList();
 }
        /// <summary>
        ///		Interpreta los movimientos
        /// </summary>
        private MovementModelCollection ParseMovements(VariationModel variation, MoveTextEntryList moveEntryList)
        {
            MovementModelCollection movements = new MovementModelCollection();

            PieceBaseModel.PieceColor actualColor    = PieceBaseModel.PieceColor.White;
            PieceBaseModelCollection  previousPieces = new PieceBaseModelCollection();

            // Inicializa el tablero
            variation.GameBoard.Reset();
            // Cambia el color inicial
            if (variation.Setup.HasSetup && !variation.Setup.IsWhiteMove)
            {
                actualColor = PieceBaseModel.PieceColor.Black;
            }
            // Interpreta la lista de movimientos
            try
            {
                foreach (MoveTextEntry moveEntry in moveEntryList)
                {
                    switch (moveEntry)
                    {
                    case RAVEntry rav:
                        MovementFigureModel lastMovement = movements.SearchLastPieceMovement();

                        if (lastMovement != null)
                        {
                            lastMovement.Variation = CreateVariation(actualColor, previousPieces, rav);
                        }
                        break;

                    case NAGEntry nag:
                        System.Diagnostics.Debug.WriteLine(moveEntry.GetType().ToString());
                        break;

                    case CommentEntry comment:
                        movements.Add(new MovementRemarksModel(comment.Comment));
                        break;

                    case MovePairEntry movement:
                        // Añade el movimiento de blancas
                        movements.Add(ParseMovement(variation.GameBoard, actualColor, (moveEntry as MovePairEntry).White));
                        actualColor = GetNextColor(actualColor);
                        // Clona la lista de piezas hasta el movimiento anterior
                        previousPieces = variation.GameBoard.Pieces.Clone();
                        // Añade el movimiento de negras
                        movements.Add(ParseMovement(variation.GameBoard, actualColor, (moveEntry as MovePairEntry).Black));
                        actualColor = GetNextColor(actualColor);
                        break;

                    case HalfMoveEntry movement:
                        // Clona la lista de piezas hasta el movimiento anterior
                        previousPieces = variation.GameBoard.Pieces.Clone();
                        // Añade el movimiento actual
                        movements.Add(ParseMovement(variation.GameBoard, actualColor, (moveEntry as HalfMoveEntry).Move));
                        actualColor = GetNextColor(actualColor);
                        break;

                    case GameEndEntry movement:
                        movements.Add(new MovementGameEndModel(ConvertResult(movement.Result)));
                        break;

                    default:
                        System.Diagnostics.Debug.WriteLine(moveEntry.GetType().ToString());
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                variation.ParseError = exception.Message;
            }
            // Devuelve la colección de movimientos
            return(movements);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Game"/> class.
 /// </summary>
 public Game()
 {
     AdditionalInfo = new List <GameInfo>();
     MoveText       = new MoveTextEntryList();
 }