Ejemplo n.º 1
0
        public override string ToString()
        {
            if (IsEndGameInfo)
            {
                return(EndGameInfo);
            }

            if (Tag == ChessMoveTag.KingSideCastle)
            {
                return("0-0");
            }
            if (Tag == ChessMoveTag.QueenSideCastle)
            {
                return("0-0-0");
            }

            string result = "";

            switch (MovingPiece.Type)
            {
            case PieceType.Pawn:
                result = "";
                break;

            case PieceType.Knight:
                result = "N";
                break;

            default:
                result = Enum.GetName(typeof(PieceType), MovingPiece.Type)[0] + "";
                break;
            }

            Point current = RankAndFileCurrent;

            result += ChessUtilities.ConvertIndicesToRankAndFile(current.X, current.Y);

            if (IsEat)
            {
                result += "x";
            }
            else
            {
                result += "->";
            }

            Point final = RankAndFileFinal;

            result += ChessUtilities.ConvertIndicesToRankAndFile(final.X, final.Y);

            if (Tag == ChessMoveTag.EnPassant)
            {
                result += "e.p.";
            }

            if (IsCheck)
            {
                result += "+";
            }

            if (IsDoubleCheck)
            {
                result += "+";
            }

            switch (PromotedTo)
            {
            case "K":
                result += "N";
                break;

            default:
                if (PromotedTo != "_")
                {
                    result += PromotedTo;
                }
                break;
            }
            return(result);
        }