fix : handle bestLinePvToPlay empty array case
This commit is contained in:
@@ -131,7 +131,11 @@ export const getIsPieceSacrifice = (
|
||||
bestLinePvToPlay: string[]
|
||||
): boolean => {
|
||||
const exchangeSquare = playedMove.slice(2, 4);
|
||||
if (bestLinePvToPlay[0].slice(2, 4) !== exchangeSquare) return false;
|
||||
if (
|
||||
!bestLinePvToPlay.length ||
|
||||
bestLinePvToPlay[0].slice(2, 4) !== exchangeSquare
|
||||
)
|
||||
return false;
|
||||
|
||||
const game = new Chess(fen);
|
||||
const whiteToPlay = game.turn() === "w";
|
||||
|
||||
Reference in New Issue
Block a user