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