chess-moments 1.4.7 → 1.4.8
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,3 +1,4 @@
|
|
|
1
|
+
const { isEmpty } = require('lodash');
|
|
1
2
|
const fen = require('../fen');
|
|
2
3
|
const { getBrushCode } = require('../helpers');
|
|
3
4
|
|
|
@@ -10,7 +11,7 @@ const momentsToPgn = (moments) => {
|
|
|
10
11
|
let pgn = '';
|
|
11
12
|
|
|
12
13
|
// Return empty PGN if no moments are provided
|
|
13
|
-
if (
|
|
14
|
+
if (isEmpty(moments)) {
|
|
14
15
|
pgn += `[SetUp "1"]\n`;
|
|
15
16
|
pgn += `[FEN "${fen.initial}"]\n\n`;
|
|
16
17
|
pgn += '*';
|
|
@@ -20,12 +21,9 @@ const momentsToPgn = (moments) => {
|
|
|
20
21
|
let currentDepth = 1;
|
|
21
22
|
let variationStack = [];
|
|
22
23
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
pgn += `[SetUp "1"]\n`;
|
|
27
|
-
pgn += `[FEN "${initialMoment.fen}"]\n\n`;
|
|
28
|
-
}
|
|
24
|
+
// Add FEN headers
|
|
25
|
+
pgn += `[SetUp "1"]\n`;
|
|
26
|
+
pgn += `[FEN "${moments[0].fen}"]\n\n`;
|
|
29
27
|
|
|
30
28
|
for (let i = 0; i < moments.length; i++) {
|
|
31
29
|
const moment = moments[i];
|