From: Benjamin Auder Date: Thu, 19 Mar 2020 16:13:02 +0000 (+0100) Subject: Fix variants with captures forced: castling isn't a capture! X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/user/current/index.css?a=commitdiff_plain;h=a34caaced0796c9118a12c609463582d656e9daf;p=vchess.git Fix variants with captures forced: castling isn't a capture! --- diff --git a/client/src/variants/Cannibal.js b/client/src/variants/Cannibal.js index 1508f672..6166860e 100644 --- a/client/src/variants/Cannibal.js +++ b/client/src/variants/Cannibal.js @@ -166,7 +166,8 @@ export class CannibalRules extends ChessRules { getAllValidMoves() { const moves = super.getAllValidMoves(); - if (moves.some(m => m.vanish.length == 2)) return V.KeepCaptures(moves); + if (moves.some(m => m.vanish.length == 2 && m.appear.length == 1)) + return V.KeepCaptures(moves); return moves; } diff --git a/client/src/variants/Capture.js b/client/src/variants/Capture.js index f0782a69..d7cc57e5 100644 --- a/client/src/variants/Capture.js +++ b/client/src/variants/Capture.js @@ -36,7 +36,8 @@ export class CaptureRules extends ChessRules { getAllValidMoves() { const moves = super.getAllValidMoves(); - if (moves.some(m => m.vanish.length == 2)) return V.KeepCaptures(moves); + if (moves.some(m => m.vanish.length == 2 && m.appear.length == 1)) + return V.KeepCaptures(moves); return moves; } diff --git a/client/src/variants/Losers.js b/client/src/variants/Losers.js index 1c087eff..4bc6a611 100644 --- a/client/src/variants/Losers.js +++ b/client/src/variants/Losers.js @@ -38,7 +38,8 @@ export class LosersRules extends ChessRules { getAllValidMoves() { const moves = super.getAllValidMoves(); - if (moves.some(m => m.vanish.length == 2)) return V.KeepCaptures(moves); + if (moves.some(m => m.vanish.length == 2 && m.appear.length == 1)) + return V.KeepCaptures(moves); return moves; }