From a34caaced0796c9118a12c609463582d656e9daf Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Thu, 19 Mar 2020 17:13:02 +0100
Subject: [PATCH] Fix variants with captures forced: castling isn't a capture!

---
 client/src/variants/Cannibal.js | 3 ++-
 client/src/variants/Capture.js  | 3 ++-
 client/src/variants/Losers.js   | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

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;
   }
 
-- 
2.44.0