chessboardjs icon indicating copy to clipboard operation
chessboardjs copied to clipboard

Specify spare pieces

Open Tjorriemorrie opened this issue 9 years ago • 3 comments

Just to confirm: is it not possible to specify spare pieces? It seems you can only pass boolean parameter.

Tjorriemorrie avatar Jan 12 '16 15:01 Tjorriemorrie

Correct; you cannot specify which pieces show up as spare currently.

On Tuesday, January 12, 2016, Tjorriemorrie [email protected] wrote:

Just to confirm: is it not possible to specify spare pieces? It seems you can only pass boolean parameter.

— Reply to this email directly or view it on GitHub https://github.com/oakmac/chessboardjs/issues/115.

oakmac avatar Jan 12 '16 16:01 oakmac

I would like to add that feature; any advice on where to begin or the section of code is?

Tjorriemorrie avatar Jan 13 '16 08:01 Tjorriemorrie

In chessboard-0.3.0.js look under the heading Markup Building for the function buildSparePieces.

function buildSparePieces(color) {
  var pieces = ['wK', 'wQ', 'wR', 'wB', 'wN', 'wP'];
  if (color === 'black') {
    pieces = ['bK', 'bQ', 'bR', 'bB', 'bN', 'bP'];
  } ...

Delete whichever pieces you don't want. For example, remove 'wR', to remove the white rook.

user14159 avatar Mar 29 '16 22:03 user14159