cm-chessboard 8.7.0 → 8.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/Chessboard.js
CHANGED
|
@@ -15,6 +15,9 @@ export const PIECE = {
|
|
|
15
15
|
wp: "wp", wb: "wb", wn: "wn", wr: "wr", wq: "wq", wk: "wk",
|
|
16
16
|
bp: "bp", bb: "bb", bn: "bn", br: "br", bq: "bq", bk: "bk"
|
|
17
17
|
}
|
|
18
|
+
export const PIECE_TYPE = {
|
|
19
|
+
pawn: "p", knight: "n", bishop: "b", rook: "r", queen: "q", king: "k"
|
|
20
|
+
}
|
|
18
21
|
export const PIECES_FILE_TYPE = {
|
|
19
22
|
svgSprite: "svgSprite"
|
|
20
23
|
}
|
|
@@ -92,7 +92,7 @@ class BrailleNotationInAlt {
|
|
|
92
92
|
let listW = piecesTranslations[this.extension.lang].colors.w.toUpperCase() + ":"
|
|
93
93
|
let listB = piecesTranslations[this.extension.lang].colors.b.toUpperCase() + ":"
|
|
94
94
|
for (const piece of pieces) {
|
|
95
|
-
const pieceName = piece.
|
|
95
|
+
const pieceName = piece.type === "p" ? "" : piecesTranslations[this.extension.lang].pieces[piece.type].toUpperCase()
|
|
96
96
|
if (piece.color === "w") {
|
|
97
97
|
listW += " " + pieceName + piece.position
|
|
98
98
|
} else {
|
|
@@ -226,9 +226,9 @@ class PiecesAsList {
|
|
|
226
226
|
let listB = ""
|
|
227
227
|
for (const piece of pieces) {
|
|
228
228
|
if (piece.color === "w") {
|
|
229
|
-
listW += `<li class="list-inline-item">${renderPieceTitle(this.extension.lang, piece.
|
|
229
|
+
listW += `<li class="list-inline-item">${renderPieceTitle(this.extension.lang, piece.type)} ${piece.position}</li>`
|
|
230
230
|
} else {
|
|
231
|
-
listB += `<li class="list-inline-item">${renderPieceTitle(this.extension.lang, piece.
|
|
231
|
+
listB += `<li class="list-inline-item">${renderPieceTitle(this.extension.lang, piece.type)} ${piece.position}</li>`
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
this.piecesList.innerHTML = `
|
package/src/model/Position.js
CHANGED
|
@@ -71,7 +71,7 @@ export class Position {
|
|
|
71
71
|
return parts.join("/")
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
getPieces(sortBy = ['k', 'q', 'r', 'b', 'n', 'p']) {
|
|
74
|
+
getPieces(pieceType = undefined, pieceColor = undefined, sortBy = ['k', 'q', 'r', 'b', 'n', 'p']) {
|
|
75
75
|
const pieces = []
|
|
76
76
|
const sort = (a, b) => {
|
|
77
77
|
return sortBy.indexOf(a.name) - sortBy.indexOf(b.name)
|
|
@@ -79,10 +79,18 @@ export class Position {
|
|
|
79
79
|
for (let i = 0; i < 64; i++) {
|
|
80
80
|
const piece = this.squares[i]
|
|
81
81
|
if (piece) {
|
|
82
|
+
const type = piece.charAt(1)
|
|
83
|
+
const color = piece.charAt(0)
|
|
84
|
+
const square = Position.indexToSquare(i)
|
|
85
|
+
if(pieceType && pieceType !== type || pieceColor && pieceColor !== color) {
|
|
86
|
+
continue
|
|
87
|
+
}
|
|
82
88
|
pieces.push({
|
|
83
|
-
name:
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
name: type, // deprecated, use type
|
|
90
|
+
type: type,
|
|
91
|
+
color: color,
|
|
92
|
+
position: square, // deprecated, use square
|
|
93
|
+
square: square
|
|
86
94
|
})
|
|
87
95
|
}
|
|
88
96
|
}
|
|
@@ -61,7 +61,6 @@ export class ChessboardView {
|
|
|
61
61
|
}
|
|
62
62
|
this.positionsAnimationTask = Promise.resolve()
|
|
63
63
|
this.pointerDownListener = this.pointerDownHandler.bind(this)
|
|
64
|
-
this.pointerDownListener = this.pointerDownHandler.bind(this)
|
|
65
64
|
this.container.addEventListener("mousedown", this.pointerDownListener)
|
|
66
65
|
this.container.addEventListener("touchstart", this.pointerDownListener, {passive: false})
|
|
67
66
|
this.createSvgAndGroups()
|