cm-chessboard 8.7.2 → 8.7.4
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 +1 -1
- package/src/Chessboard.js +1 -2
- package/src/model/Position.js +1 -1
- package/test/TestPosition.js +3 -3
package/package.json
CHANGED
package/src/Chessboard.js
CHANGED
|
@@ -115,9 +115,8 @@ export class Chessboard {
|
|
|
115
115
|
return this.state.position.getPiece(square)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/** return the position object since 2024-04-20 (8.7.0) */
|
|
119
118
|
getPosition() {
|
|
120
|
-
return this.state.position
|
|
119
|
+
return this.state.position.getFen()
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
getOrientation() {
|
package/src/model/Position.js
CHANGED
|
@@ -71,7 +71,7 @@ export class Position {
|
|
|
71
71
|
return parts.join("/")
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
getPieces(
|
|
74
|
+
getPieces(pieceColor = undefined, pieceType = 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)
|
package/test/TestPosition.js
CHANGED
|
@@ -29,13 +29,13 @@ describe("TestPosition", () => {
|
|
|
29
29
|
})
|
|
30
30
|
it("should find the correct pieces", () => {
|
|
31
31
|
const position = new Position("8/5P2/8/1P3r2/8/8/1P3P1P/8")
|
|
32
|
-
const blackPiece = position.getPieces(
|
|
32
|
+
const blackPiece = position.getPieces(COLOR.black)
|
|
33
33
|
assert.equal(blackPiece.length, 1)
|
|
34
34
|
assert.equal(blackPiece[0].type, PIECE_TYPE.rook)
|
|
35
35
|
assert.equal(blackPiece[0].square, "f5")
|
|
36
|
-
const whitePieces = position.getPieces(
|
|
36
|
+
const whitePieces = position.getPieces(COLOR.white)
|
|
37
37
|
assert.equal(whitePieces.length, 5)
|
|
38
|
-
const rooks = position.getPieces(PIECE_TYPE.rook)
|
|
38
|
+
const rooks = position.getPieces(undefined, PIECE_TYPE.rook)
|
|
39
39
|
assert.equal(rooks.length, 1)
|
|
40
40
|
assert.equal(rooks[0].square, "f5")
|
|
41
41
|
})
|