Пример #1
0
        private static string ToRan(Move move, MoveGenerator moveGenerator)
        {
            var from = move.GetFromSquare();
            var to   = move.GetToSquare();

            var notation = new StringBuilder(12);

            if (move.IsCastlelingMove())
            {
                notation.Append(ECastlelingExtensions.GetCastlelingString(to, from));
            }
            else
            {
                var pt = move.GetMovingPieceType();

                if (pt != EPieceType.Pawn)
                {
                    notation.Append(pt.GetPieceChar());
                }

                notation.Append(from.ToString());

                if (move.IsEnPassantMove())
                {
                    notation.Append("ep");
                    notation.Append(from.FileChar());
                }
                else if (move.IsCaptureMove())
                {
                    if (pt == EPieceType.Pawn)
                    {
                        notation.Append(from.FileChar());
                    }

                    notation.Append('x');
                    notation.Append(move.GetCapturedPiece().Type().GetPieceChar());
                }
                else
                {
                    notation.Append('-');
                }

                notation.Append(to.ToString());

                if (move.IsPromotionMove())
                {
                    notation.Append('=');
                    notation.Append(move.GetPromotedPiece().GetUnicodeChar());
                }
            }

            if (moveGenerator.InCheck)
            {
                notation.Append(moveGenerator.GetCheckChar());
            }

            return(notation.ToString());
        }