cm-chess 3.2.0 → 3.2.2
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 +2 -3
- package/src/Chess.js +11 -0
- package/test/TestChess.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cm-chess",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "It's like chess.js, but in ES6 and can handle variations (tree-structured move history)",
|
|
5
5
|
"main": "./src/Chess.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
"homepage": "https://github.com/shaack/cm-chess#readme",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"chess.mjs": "^1.4.0",
|
|
28
|
-
"cm-pgn": "3.2.1"
|
|
29
|
-
"import-node-modules": "^1.0.6"
|
|
28
|
+
"cm-pgn": "3.2.1"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"teevi": "^2.2.4"
|
package/src/Chess.js
CHANGED
|
@@ -291,6 +291,17 @@ export class Chess {
|
|
|
291
291
|
return result
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* get the piece on a square
|
|
296
|
+
* @param square
|
|
297
|
+
* @param move
|
|
298
|
+
* @returns {{color: any, type: any}|null}
|
|
299
|
+
*/
|
|
300
|
+
piece(square, move = this.lastMove()) {
|
|
301
|
+
const chessJs = move ? new ChessJs(move.fen) : new ChessJs()
|
|
302
|
+
return chessJs.get(square)
|
|
303
|
+
}
|
|
304
|
+
|
|
294
305
|
/**
|
|
295
306
|
* @returns {string} "b" or "w" the color to move in the main variation
|
|
296
307
|
*/
|
package/test/TestChess.js
CHANGED
|
@@ -19,6 +19,8 @@ describe("Chess", function () {
|
|
|
19
19
|
const chess = new Chess(fen)
|
|
20
20
|
assert.equal(chess.pgn.header.tags[TAGS.FEN], fen)
|
|
21
21
|
assert.equal(chess.fen(), fen)
|
|
22
|
+
assert.equal(chess.piece("e1").type, "k")
|
|
23
|
+
assert.equal(chess.piece("e1").color, "w")
|
|
22
24
|
})
|
|
23
25
|
|
|
24
26
|
it("should load a pgn with SetUp and FEN", function () {
|