lichess-org / chessground

Mobile/Web chess UI for lichess.org
https://lichess.org
GNU General Public License v3.0
1.04k stars 261 forks source link

Cancel a move? #63

Closed legoboy0215 closed 7 years ago

legoboy0215 commented 7 years ago

I am using chess.js with this amazing chessboard. However, I can use the move event to validate the moves, but I do not know how to cancel an illegal move. How would I achieve that? (This isn't an issue, but I don't know where else to ask this, sorry)

cancelMove in the move event doesn't cancel the move, I've tried that. Or am I doing something wrong?

ornicar commented 7 years ago

cancelMove cancels the move being played, not the move that was played.

You should pass chessground the legal moves, so legal moves are highlighted, and illegal moves can't be played.

legoboy0215 commented 7 years ago

Oh, thanks! BTW, how would I undo a move? I do want to perform server side validation so...

ornicar commented 7 years ago

Cancel on chess.js and apply the new FEN to chessground.

legoboy0215 commented 7 years ago

Ah! Thanks again :) Glad I moved away from chessboard.js after reading your post on reddit lol Thanks for making this open-sourced.