chess-moments 1.2.0 → 1.2.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.
|
@@ -62,29 +62,36 @@ const getNextMoments = (moments, current) => {
|
|
|
62
62
|
// Add fullmove number to the current moment
|
|
63
63
|
current.fullmove = Number(current.fen.split(' ')[5]);
|
|
64
64
|
|
|
65
|
-
// Keep only slim moments
|
|
66
|
-
const slim = moments.filter((moment) => {
|
|
67
|
-
const fullmove = Number(moment.fen.split(' ')[5]);
|
|
68
|
-
return (
|
|
69
|
-
moment.index > current.index + 1 &&
|
|
70
|
-
fullmove <= current.fullmove + 1 &&
|
|
71
|
-
moment.move // Also filter out moments without a move
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
65
|
// Active color after current move (who moves next)
|
|
76
66
|
const activeColorAfterCurrent = current.fen.split(' ')[1];
|
|
77
67
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
//
|
|
81
|
-
if (moment.
|
|
68
|
+
// Process moments in order and stop when we leave the current branch
|
|
69
|
+
for (const moment of moments) {
|
|
70
|
+
// Skip moments that are at or before the current moment's index
|
|
71
|
+
if (moment.index <= current.index + 1) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
// Stop if we hit a moment with lower depth (we've left this branch)
|
|
75
|
+
if (moment.depth < current.depth) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
// Skip moments without moves
|
|
79
|
+
if (!moment.move) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
// Only consider moments at current depth or one level deeper
|
|
83
|
+
if (moment.depth > current.depth + 1) {
|
|
82
84
|
continue;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const activeColorAfterMoment = moment.fen.split(' ')[1];
|
|
86
88
|
const fullmove = Number(moment.fen.split(' ')[5]);
|
|
87
89
|
|
|
90
|
+
// Only consider moments within the valid move range
|
|
91
|
+
if (fullmove > current.fullmove + 1) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
|
|
88
95
|
// Check if this is a valid next move based on color and fullmove
|
|
89
96
|
const isValidWhiteMove =
|
|
90
97
|
activeColorAfterCurrent === 'w' &&
|