Exemplo n.º 1
0
        public void Format_should_format_a_RAVEntry()
        {
            var sut           = new MoveTextFormatter();
            var halfMoveEntry = new HalfMoveEntry(_move2)
            {
                MoveNumber = 6, IsContinued = true
            };
            var ravEntry = new RAVEntry(new MoveTextEntryList {
                halfMoveEntry
            });

            Assert.AreEqual("(6... Nd4)", sut.Format(ravEntry));
        }
Exemplo n.º 2
0
        public void Format_should_format_move_text()
        {
            var sut    = new MoveTextFormatter();
            var entry1 =
                new HalfMoveEntry(new Move
            {
                Type         = MoveType.Capture,
                Piece        = PieceType.Knight,
                TargetSquare = new Square(File.E, 5),
                Annotation   = MoveAnnotation.Good
            })
            {
                MoveNumber = 37
            };

            var entry2 = new NAGEntry(13);

            var rav1 = new CommentEntry("comment");
            var rav2 =
                new HalfMoveEntry(new Move
            {
                Type         = MoveType.Simple,
                Piece        = PieceType.Knight,
                TargetSquare = new Square(File.E, 3),
                Annotation   = MoveAnnotation.Blunder
            })
            {
                MoveNumber = 37
            };

            var entry3 = new RAVEntry(new MoveTextEntryList {
                rav1, rav2
            });

            var entry4 =
                new HalfMoveEntry(new Move
            {
                Type         = MoveType.Simple,
                Piece        = PieceType.Rook,
                TargetSquare = new Square(File.D, 8)
            })
            {
                MoveNumber = 37, IsContinued = true
            };

            var entry5 = new MovePairEntry(
                new Move {
                Type = MoveType.Simple, TargetSquare = new Square(File.H, 4)
            },
                new Move {
                Type = MoveType.Simple, Piece = PieceType.Rook, TargetSquare = new Square(File.D, 5)
            })
            {
                MoveNumber = 38
            };

            var entry6 = new GameEndEntry(GameResult.Draw);
            var entry7 = new CommentEntry("game ends in draw, whooot");

            var moveText = new List <MoveTextEntry> {
                entry1, entry2, entry3, entry4, entry5, entry6, entry7
            };

            Assert.AreEqual("37. Nxe5! $13 ({comment} 37. Ne3??) 37... Rd8 38. h4 Rd5 ½-½ {game ends in draw, whooot}", sut.Format(moveText));
        }
        /// <summary>
        ///		Crea una variación
        /// </summary>
        private VariationModel CreateVariation(PieceBaseModel.PieceColor actualColor, PieceBaseModelCollection previousPieces, RAVEntry rav)
        {
            VariationModel variation = new VariationModel();

            // Asigna las piezas
            variation.Setup = CreateBoardSetup(actualColor, previousPieces);
            // Interpreta la lista de movimiento
            variation.Movements.AddRange(ParseMovements(variation, rav.MoveText));
            // Devuelve la variación
            return(variation);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Formats the a RAV (Recursive Annotation Variations) entry.
 /// </summary>
 /// <param name="entry">The RAV entry.</param>
 /// <param name="writer">The writer.</param>
 private void FormatRAVEntry(RAVEntry entry, TextWriter writer)
 {
     writer.Write("(");
     this.Format(entry.MoveText, writer);
     writer.Write(")");
 }
Exemplo n.º 5
0
 /// <summary>
 /// Formats the a RAV (Recursive Annotation Variations) entry.
 /// </summary>
 /// <param name="entry">The RAV entry.</param>
 /// <param name="writer">The writer.</param>
 private void FormatRAVEntry(RAVEntry entry, TextWriter writer)
 {
     writer.Write("(");
     this.Format(entry.MoveText, writer);
     writer.Write(")");
 }
Exemplo n.º 6
0
        public void Format_should_format_move_text()
        {
            var sut = new MoveTextFormatter();
            var entry1 =
                new HalfMoveEntry(new Move
                    {
                        Type = MoveType.Capture,
                        Piece = PieceType.Knight,
                        TargetSquare = new Square(File.E, 5),
                        Annotation = MoveAnnotation.Good
                    }) { MoveNumber = 37 };

            var entry2 = new NAGEntry(13);

            var rav1 = new CommentEntry("comment");
            var rav2 =
                new HalfMoveEntry(new Move
                    {
                        Type = MoveType.Simple,
                        Piece = PieceType.Knight,
                        TargetSquare = new Square(File.E, 3),
                        Annotation = MoveAnnotation.Blunder
                    }) { MoveNumber = 37 };

            var entry3 = new RAVEntry(new MoveTextEntryList { rav1, rav2 });

            var entry4 =
                new HalfMoveEntry(new Move
                    {
                        Type = MoveType.Simple,
                        Piece = PieceType.Rook,
                        TargetSquare = new Square(File.D, 8)
                    }) { MoveNumber = 37, IsContinued = true };

            var entry5 = new MovePairEntry(
                new Move { Type = MoveType.Simple, TargetSquare = new Square(File.H, 4) },
                new Move { Type = MoveType.Simple, Piece = PieceType.Rook, TargetSquare = new Square(File.D, 5) }) { MoveNumber = 38 };

            var entry6 = new GameEndEntry(GameResult.Draw);
            var entry7 = new CommentEntry("game ends in draw, whooot");

            var moveText = new List<MoveTextEntry> { entry1, entry2, entry3, entry4, entry5, entry6, entry7 };

            Assert.AreEqual("37. Nxe5! $13 ({comment} 37. Ne3??) 37... Rd8 38. h4 Rd5 ½-½ {game ends in draw, whooot}", sut.Format(moveText));
        }
Exemplo n.º 7
0
 public void Format_should_format_a_RAVEntry()
 {
     var sut = new MoveTextFormatter();
     var halfMoveEntry = new HalfMoveEntry(_move2) { MoveNumber = 6, IsContinued = true };
     var ravEntry = new RAVEntry(new MoveTextEntryList { halfMoveEntry });
     Assert.AreEqual("(6... Nd4)", sut.Format(ravEntry));
 }