chessboardjs
chessboardjs copied to clipboard
Spare pieces count
First of all: this is very useful for the crazy house variant and is a bit complicated to work around for the moment so I decided to take a look at it.
In the end, I updated the https://github.com/oakmac/chessboardjs/pull/128 PR (the UI is different for example).
Also: the first commit is just a cleanup for some weird \r
in the code (made automatically by my text editor).
Here's a screen of what it looks like:
Thanks for the pull request. I don't see the counts updated correctly when a piece is removed from the board. (moving pieces off and on the board) I used the code for example 2006 and initiated the board like this:
var board = Chessboard('myBoard', {
draggable: true,
dropOffBoard: 'trash',
sparePieces: true, // I even removed this line
spareCounts: { 'wK':0, 'wQ':0, 'wR':0, 'wB':0, 'wN':2, 'wP':1, 'bK':0, 'bQ':0, 'bR':0, 'bB':0, 'bN':0, 'bP':0 }
})
Feature or bug?
It seems to be a bug. Since I opened this PR, I heavily updated the code in my own fork (removed jquery, turned a lot of the code into async
so I can await
for moves to be done, simplified DOM a bit, etc). I'll try to fix it again.
Thanks. Just a feature request beyond what you have accomplished. It would be great if you entirely remove spare pieces with count==0
Ah no, my bad. Moving off the board is not supposed to increase the spare count. Just double-checked locally.
As for not displaying pieces with count==0, I can do it in follow-up PR with a specific config if you want.
Thank you for this! Exactly what I needed. However, this change makes the animation on .move() not smooth anymore. At least for me.