react-chessboard-ui 2.11.0 → 2.13.0
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/dist/index.js +52 -46
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +52 -46
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -275,22 +275,24 @@ JSChessEngine.correctionPossibleMoves = function (state, figurePos, possibleMove
|
|
|
275
275
|
DIRECTIONS_D.forEach(function (direction) {
|
|
276
276
|
if (!kingBehidFigure) {
|
|
277
277
|
var attackedLine = JSChessEngine.getFullAttackedLine(state, enemyPos, direction);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
var foundIndexFigurePos = attackedLine.findIndex(function (pos) {
|
|
282
|
-
return pos[0] === figurePos[0] && pos[1] === figurePos[1];
|
|
283
|
-
});
|
|
284
|
-
var countFiguresBehindKing = JSChessEngine.getCountEnemys(state, enemyPos, attackedLine);
|
|
285
|
-
kingBehidFigure = foundIndexKingPos > -1 && foundIndexFigurePos > -1 && foundIndexKingPos > foundIndexFigurePos && countFiguresBehindKing === 1;
|
|
286
|
-
if (kingBehidFigure) {
|
|
287
|
-
possibleMoves.forEach(function (possibleMove) {
|
|
288
|
-
[].concat(attackedLine, [enemyPos]).forEach(function (attackedPos) {
|
|
289
|
-
if (attackedPos[0] === possibleMove[0] && attackedPos[1] === possibleMove[1]) {
|
|
290
|
-
correctedPossibleMoves.push(possibleMove);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
278
|
+
if (!!kingPos) {
|
|
279
|
+
var foundIndexKingPos = attackedLine.findIndex(function (pos) {
|
|
280
|
+
return pos[0] === kingPos[0] && pos[1] === kingPos[1];
|
|
293
281
|
});
|
|
282
|
+
var foundIndexFigurePos = attackedLine.findIndex(function (pos) {
|
|
283
|
+
return pos[0] === figurePos[0] && pos[1] === figurePos[1];
|
|
284
|
+
});
|
|
285
|
+
var countFiguresBehindKing = JSChessEngine.getCountEnemys(state, enemyPos, attackedLine);
|
|
286
|
+
kingBehidFigure = foundIndexKingPos > -1 && foundIndexFigurePos > -1 && foundIndexKingPos > foundIndexFigurePos && countFiguresBehindKing === 1;
|
|
287
|
+
if (kingBehidFigure) {
|
|
288
|
+
possibleMoves.forEach(function (possibleMove) {
|
|
289
|
+
[].concat(attackedLine, [enemyPos]).forEach(function (attackedPos) {
|
|
290
|
+
if (attackedPos[0] === possibleMove[0] && attackedPos[1] === possibleMove[1]) {
|
|
291
|
+
correctedPossibleMoves.push(possibleMove);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
}
|
|
294
296
|
}
|
|
295
297
|
}
|
|
296
298
|
});
|
|
@@ -302,22 +304,24 @@ JSChessEngine.correctionPossibleMoves = function (state, figurePos, possibleMove
|
|
|
302
304
|
DIRECTIONS_VH.forEach(function (direction) {
|
|
303
305
|
if (!kingBehidFigure) {
|
|
304
306
|
var attackedLine = JSChessEngine.getFullAttackedLine(state, enemyPos, direction);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var foundIndexFigurePos = attackedLine.findIndex(function (pos) {
|
|
309
|
-
return pos[0] === figurePos[0] && pos[1] === figurePos[1];
|
|
310
|
-
});
|
|
311
|
-
var countFiguresBehindKing = JSChessEngine.getCountEnemys(state, enemyPos, attackedLine);
|
|
312
|
-
kingBehidFigure = foundIndexKingPos > -1 && foundIndexFigurePos > -1 && foundIndexKingPos > foundIndexFigurePos && countFiguresBehindKing === 1;
|
|
313
|
-
if (kingBehidFigure) {
|
|
314
|
-
possibleMoves.forEach(function (possibleMove) {
|
|
315
|
-
[].concat(attackedLine, [enemyPos]).forEach(function (attackedPos) {
|
|
316
|
-
if (attackedPos[0] === possibleMove[0] && attackedPos[1] === possibleMove[1]) {
|
|
317
|
-
correctedPossibleMoves.push(possibleMove);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
307
|
+
if (!!kingPos) {
|
|
308
|
+
var foundIndexKingPos = attackedLine.findIndex(function (pos) {
|
|
309
|
+
return pos[0] === kingPos[0] && pos[1] === kingPos[1];
|
|
320
310
|
});
|
|
311
|
+
var foundIndexFigurePos = attackedLine.findIndex(function (pos) {
|
|
312
|
+
return pos[0] === figurePos[0] && pos[1] === figurePos[1];
|
|
313
|
+
});
|
|
314
|
+
var countFiguresBehindKing = JSChessEngine.getCountEnemys(state, enemyPos, attackedLine);
|
|
315
|
+
kingBehidFigure = foundIndexKingPos > -1 && foundIndexFigurePos > -1 && foundIndexKingPos > foundIndexFigurePos && countFiguresBehindKing === 1;
|
|
316
|
+
if (kingBehidFigure) {
|
|
317
|
+
possibleMoves.forEach(function (possibleMove) {
|
|
318
|
+
[].concat(attackedLine, [enemyPos]).forEach(function (attackedPos) {
|
|
319
|
+
if (attackedPos[0] === possibleMove[0] && attackedPos[1] === possibleMove[1]) {
|
|
320
|
+
correctedPossibleMoves.push(possibleMove);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
}
|
|
321
325
|
}
|
|
322
326
|
}
|
|
323
327
|
});
|
|
@@ -329,22 +333,24 @@ JSChessEngine.correctionPossibleMoves = function (state, figurePos, possibleMove
|
|
|
329
333
|
[].concat(DIRECTIONS_D, DIRECTIONS_VH).forEach(function (direction) {
|
|
330
334
|
if (!kingBehidFigure) {
|
|
331
335
|
var attackedLine = JSChessEngine.getFullAttackedLine(state, enemyPos, direction);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
var countFiguresBehindKing = JSChessEngine.getCountEnemys(state, enemyPos, attackedLine);
|
|
339
|
-
kingBehidFigure = foundIndexKingPos > -1 && foundIndexFigurePos > -1 && foundIndexKingPos > foundIndexFigurePos && countFiguresBehindKing === 1;
|
|
340
|
-
if (kingBehidFigure) {
|
|
341
|
-
possibleMoves.forEach(function (possibleMove) {
|
|
342
|
-
[].concat(attackedLine, [enemyPos]).forEach(function (attackedPos) {
|
|
343
|
-
if (attackedPos[0] === possibleMove[0] && attackedPos[1] === possibleMove[1]) {
|
|
344
|
-
correctedPossibleMoves.push(possibleMove);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
336
|
+
if (!!kingPos) {
|
|
337
|
+
var foundIndexKingPos = attackedLine.findIndex(function (pos) {
|
|
338
|
+
return pos[0] === kingPos[0] && pos[1] === kingPos[1];
|
|
339
|
+
});
|
|
340
|
+
var foundIndexFigurePos = attackedLine.findIndex(function (pos) {
|
|
341
|
+
return pos[0] === figurePos[0] && pos[1] === figurePos[1];
|
|
347
342
|
});
|
|
343
|
+
var countFiguresBehindKing = JSChessEngine.getCountEnemys(state, enemyPos, attackedLine);
|
|
344
|
+
kingBehidFigure = foundIndexKingPos > -1 && foundIndexFigurePos > -1 && foundIndexKingPos > foundIndexFigurePos && countFiguresBehindKing === 1;
|
|
345
|
+
if (kingBehidFigure) {
|
|
346
|
+
possibleMoves.forEach(function (possibleMove) {
|
|
347
|
+
[].concat(attackedLine, [enemyPos]).forEach(function (attackedPos) {
|
|
348
|
+
if (attackedPos[0] === possibleMove[0] && attackedPos[1] === possibleMove[1]) {
|
|
349
|
+
correctedPossibleMoves.push(possibleMove);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
}
|
|
348
354
|
}
|
|
349
355
|
}
|
|
350
356
|
});
|
|
@@ -3197,7 +3203,7 @@ var ChessBoard = function ChessBoard(props) {
|
|
|
3197
3203
|
className: styles.fenErrorMessage,
|
|
3198
3204
|
role: "alert"
|
|
3199
3205
|
}, React.createElement("div", null, "Invalid FEN notation. The default board position was used instead.", " ", React.createElement("a", {
|
|
3200
|
-
href: "/docs/fen-errors"
|
|
3206
|
+
href: "https://react-chessboard-ui.dev/docs/fen-errors"
|
|
3201
3207
|
}, "See common FEN problems"), "."), React.createElement("div", null, React.createElement("a", {
|
|
3202
3208
|
className: styles.fenErrorMessageClose,
|
|
3203
3209
|
onClick: handleHideInvalidFENmessage
|