chess-moments 1.3.0 → 1.4.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const prettify = require('./prettify');
|
|
2
2
|
const shape = require('./shape');
|
|
3
3
|
|
|
4
|
-
module.exports = ({ depth, move, fen, comment, from, to }) => {
|
|
4
|
+
module.exports = ({ depth, move, fen, comment, suffix, from, to }) => {
|
|
5
5
|
const moment = { depth, fen };
|
|
6
6
|
if (move) {
|
|
7
7
|
moment.move = move;
|
|
@@ -20,6 +20,9 @@ module.exports = ({ depth, move, fen, comment, from, to }) => {
|
|
|
20
20
|
moment.shapes = shapes;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
if (suffix) {
|
|
24
|
+
moment.suffix = suffix;
|
|
25
|
+
}
|
|
23
26
|
|
|
24
27
|
return moment;
|
|
25
28
|
};
|
|
@@ -102,6 +102,11 @@ const momentsToPgn = (moments) => {
|
|
|
102
102
|
// Add the move
|
|
103
103
|
pgn += moment.move;
|
|
104
104
|
|
|
105
|
+
// Add suffix if present
|
|
106
|
+
if (moment.suffix) {
|
|
107
|
+
pgn += moment.suffix;
|
|
108
|
+
}
|
|
109
|
+
|
|
105
110
|
// Add comment if present
|
|
106
111
|
if (moment.comment) {
|
|
107
112
|
pgn += ` {${moment.comment}}`;
|
package/functions/parser.js
CHANGED
|
@@ -12,8 +12,12 @@ module.exports = (moves, fen = initial, depth = 1) => {
|
|
|
12
12
|
chess.undo();
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const first = moment.build({
|
|
15
|
+
// First moment does not have a move
|
|
16
|
+
const first = moment.build({
|
|
17
|
+
depth,
|
|
18
|
+
comment: chess.getComment(),
|
|
19
|
+
fen: chess.fen(),
|
|
20
|
+
});
|
|
17
21
|
|
|
18
22
|
const moments = history.map((item) => {
|
|
19
23
|
chess.move(item.san);
|
|
@@ -24,6 +28,7 @@ module.exports = (moves, fen = initial, depth = 1) => {
|
|
|
24
28
|
from: item.from,
|
|
25
29
|
to: item.to,
|
|
26
30
|
comment: chess.getComment(),
|
|
31
|
+
suffix: chess.getSuffixAnnotation(),
|
|
27
32
|
fen: chess.fen(),
|
|
28
33
|
});
|
|
29
34
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chess-moments",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "PGN parser that transforms PGN files into chess \"moments\"",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"chess.js": "
|
|
27
|
+
"chess.js": "github:jhlywa/chess.js#master"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"chai": "^4.3.7",
|