From: Benjamin Auder Date: Fri, 8 Jan 2021 19:03:29 +0000 (+0100) Subject: Fix Synchrone2::filterValid() X-Git-Url: https://git.auder.net/images/pieces/%24%7BgetWhatsApp%28link%29%7D?a=commitdiff_plain;h=44cf6ba723579cbb0ff84cfda94062583fadfe95;p=vchess.git Fix Synchrone2::filterValid() --- diff --git a/client/src/variants/Synchrone2.js b/client/src/variants/Synchrone2.js index ee016844..5539c9e0 100644 --- a/client/src/variants/Synchrone2.js +++ b/client/src/variants/Synchrone2.js @@ -118,10 +118,10 @@ export class Synchrone2Rules extends Synchrone1Rules { } filterValid(moves) { - if (moves.length == 0) return []; - if (moves.length == 1 && moves[0].vanish.length == 0) return moves; + const nonEmptyMove = moves.find(m => m.vanish.length > 0); + if (!nonEmptyMove) return moves; // filterValid can be called when it's "not our turn": - const color = moves.find(m => m.vanish.length > 0).vanish[0].c; + const color = nonEmptyMove.vanish[0].c; return moves.filter(m => { if (m.vanish.length == 0) return true; const piece = m.vanish[0].p;