chess-moments 0.14.4 → 0.14.6

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.
@@ -7,7 +7,7 @@ const getNextMoments = (moments, current) => {
7
7
 
8
8
  // If it's the first moment without move, add the next moment
9
9
  if (current.index === 0 && !current.move) {
10
- return moments[1];
10
+ return [moments[1]];
11
11
  }
12
12
 
13
13
  // Split moments after the current index
@@ -29,7 +29,8 @@ const getPrevMoment = (moments, current) => {
29
29
  const fullmove = Number(moment.fen.split(' ')[5]);
30
30
 
31
31
  if (
32
- moment.depth === current.depth - 1 &&
32
+ (moment.depth === current.depth - 1 ||
33
+ moment.depth === current.depth) &&
33
34
  activeColor === 'b' &&
34
35
  fullmove === current.fullmove - 1
35
36
  ) {
@@ -47,7 +48,8 @@ const getPrevMoment = (moments, current) => {
47
48
  const fullmove = Number(moment.fen.split(' ')[5]);
48
49
 
49
50
  if (
50
- moment.depth === current.depth - 1 &&
51
+ (moment.depth === current.depth - 1 ||
52
+ moment.depth === current.depth) &&
51
53
  activeColor === 'w' &&
52
54
  fullmove === current.fullmove
53
55
  ) {
@@ -12,7 +12,7 @@ const momentsToPgn = (moments) => {
12
12
  // Return empty PGN if no moments are provided
13
13
  if (!Array.isArray(moments) || moments.length === 0) {
14
14
  pgn += `[SetUp "1"]\n`;
15
- pgn += `[FEN "${initialMoment.fen}"]\n\n`;
15
+ pgn += `[FEN "${fen.initial}"]\n\n`;
16
16
  pgn += '*';
17
17
  return pgn;
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chess-moments",
3
- "version": "0.14.4",
3
+ "version": "0.14.6",
4
4
  "description": "PGN parser that transforms PGN files into chess \"moments\"",
5
5
  "main": "dist/index.js",
6
6
  "files": [