cm-pgn
cm-pgn copied to clipboard
Add Multiple variations to history fails with invalid move error
Hi
if you try to add more than 3 variations to a move it will fail with the invalid move error.
should add a variant and render it => fail Error: invalid move
these moves are valid I tested them on lichess.
from the History test I tried to change the history test like this
it("should add a variant and render it", () => {
const history = new History();
const ply1 = history.addMove("e4");
history.addMove("e6");
history.addMove("d3");
history.addMove("d5");
history.addMove("Nd2");
history.addMove("e5", ply1);
history.addMove("f3", ply1);
history.addMove("e6", ply1);
history.addMove("Ne2", ply1);
assert.equals(history.moves[1].variations.length, 4);
});
if I manage to fix this issue I will post the solution here. also, I can send a pull request for render variations.
Thanks for your report. I will take a look to the problem.
"f3" is certainly an invalid move for black.
I suspect what you meant is:
const ply2 = history.addMove("e5", ply1);
history.addMove("f3", ply2);