Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spare pieces count #190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link

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 #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

@ebadi
Copy link

ebadi commented Dec 25, 2022

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?

@GuillaumeGomez
Copy link
Author

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.

@ebadi
Copy link

ebadi commented Dec 25, 2022

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

@GuillaumeGomez
Copy link
Author

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.

@dsolstad
Copy link

dsolstad commented Jan 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants