jniemann66 / react-chessdiagram

Chess Diagram React Component
MIT License
26 stars 10 forks source link

Positional notation (piece@square) broken #10

Closed jniemann66 closed 7 years ago

jniemann66 commented 7 years ago

In the absence of fen and pgn props, chessdiagram should simply draw a blank board, or otherwise accept an array of piece@square values via the pieces prop.

However, internal movelist is being populated in the constructor (via the getFensFromPgn() function).

proposed fix (chessdiagram.js, starting line 38):

            // If FEN is present, and it is an array, use it for moves
        // If FEN is present, and it is a string, make it the first element of the moves array.
        // If FEN is NOT present, and PGN is present, call getFensFromPgn() to generate an array of FENs 
        // If FEN is NOT present, and PGN is NOT present, make first element of moves array an empty string
        const moves = props.fen ?
            Array.isArray(props.fen) ? props.fen : [props.fen]
            : props.pgn ? props.getFensFromPgn(props.pgn) : '';

        // If there is a PGN, set currentMove to this.startMove, otherwise zero.    
        const currentMove = props.pgn ? this.startMove : 0;
jniemann66 commented 7 years ago

fixed in 19eadb5ae64a0897118709ba319d50485b5bbdf2