Open coffeeDev98 opened 2 years ago
@jhlywa Does this package create variations and later discard/ignore them when the user undos and makes another move? Would like to get in touch with you if possible to discuss this.
The library doesn't explicitly create variations, it simply uses a stack to keep track of moves - pushing (.move()
) and popping (.undo()
) as needed. There's currently no support for preserving RAV when loading PGN.
The current PGN parser is dense and brittle. If I can find some time, I'd like roll a new one using a parser generator (e.g. PEG.js).
Came across an es6 rework of this package by @aaronfi (here) which includes move variations but am unable to use the package in my project with React.
Hi @coffeeDev98. It was an old project of mine. Definitely could use a rewrite into TypeScript (which I imagine would allow for far cleaner code).
https://github.com/aaronfi/chess-es6-demo is the demo site I wrote that made use of the package you mentioned. This demo repo makes use of the package. Maybe you can mimic its approach? Hope this helps.
Hey @aaronfi , Is it possible to use your es6 rework of chess.js in a React(JS/Typescript) project? Not well versed with Ruby so, I'm having a bit of trouble going through the example code.
Hi @coffeeDev98, yes it should be possible. It's just JavaScript. You can ignore the Ruby.
The chess.js library is here: https://github.com/aaronfi/chess-es6-demo/tree/master/chess-es6 The constructor is here: https://github.com/aaronfi/chess-es6-demo/blob/d784f9a31118eb94bde5f2223b62d13c99ad013a/chess-es6/src/chess.js#L11
Here's the line in my demo website where the chess.js library is instantiated: https://github.com/aaronfi/chess-es6-demo/blob/d784f9a31118eb94bde5f2223b62d13c99ad013a/app/assets/javascripts/main.js#L245
I think the chess.js functionality of interest to you might be here: https://github.com/aaronfi/chess-es6-demo/blob/d784f9a31118eb94bde5f2223b62d13c99ad013a/chess-es6/src/chess.js#L144
Let me know if you run into any issues or shortcomings. I've long wanted to revisit this old work and port it over to TypeScript.
Cheers
Hey @aaronfi, Thanks for the help! It was very useful. Had a doubt. Is it possible to implement creating a variation from any point of the match by clicking on the move notation and playing a different move from there with the existing functionalities? Like in PGNViewer (https://mliebelt.github.io/PgnViewerJS/examples.html#1003).
Hi, I wrapped some ES6 around chess.js, combined it with my "cm-pgn" module and here I proudly present "cm-chess", which supports variations and annotations: https://github.com/shaack/cm-chess
I want to use this package in my project (with chessboardjs package) but I want to keep RAV functionality.