Esempio n. 1
0
    public static ulong ParseLongAlgebraic(string longAlgebraic, Color colorToMove)
    {
        var fromSquare = Board.GetSquare(longAlgebraic.Substring(0, 2));
        var toSquare   = Board.GetSquare(longAlgebraic.Substring(2, 2));
        // Set case of promoted piece character based on side to move.
        var promotedPiece = longAlgebraic.Length == 5
            ? PieceHelper.ParseChar(colorToMove == Color.White ? char.ToUpper(longAlgebraic[4]) : char.ToLower(longAlgebraic[4]))
            : Game.Piece.None;
        var move = Null;

        SetFrom(ref move, fromSquare);
        SetTo(ref move, toSquare);
        SetPromotedPiece(ref move, promotedPiece);
        return(move);
    }