chessboardjs icon indicating copy to clipboard operation
chessboardjs copied to clipboard

Spare pieces count

Open GuillaumeGomez opened this issue 4 years ago • 5 comments

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:

Screenshot from 2020-06-21 20-24-15

GuillaumeGomez avatar Jun 21 '20 18:06 GuillaumeGomez

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?

ebadi avatar Dec 25 '22 12:12 ebadi

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.

GuillaumeGomez avatar Dec 25 '22 14:12 GuillaumeGomez

Thanks. Just a feature request beyond what you have accomplished. It would be great if you entirely remove spare pieces with count==0

ebadi avatar Dec 25 '22 14:12 ebadi

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.

GuillaumeGomez avatar Dec 25 '22 14:12 GuillaumeGomez

Thank you for this! Exactly what I needed. However, this change makes the animation on .move() not smooth anymore. At least for me.

dsolstad avatar Jan 26 '23 09:01 dsolstad