Fix capturing promotions in Absorption variant
authorBenjamin Auder <benjamin.auder@somewhere>
Sun, 7 Jun 2020 23:14:17 +0000 (01:14 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Sun, 7 Jun 2020 23:14:17 +0000 (01:14 +0200)
client/src/variants/Absorption.js

index 7a9ff3c..b10f165 100644 (file)
@@ -80,6 +80,15 @@ export class AbsorptionRules extends ChessRules {
       default:
         moves = super.getPotentialMovesFrom(sq);
     }
+    // Filter out capturing promotions (except one),
+    // because they are all the same.
+    moves = moves.filter(m => {
+      return (
+        m.vanish.length == 1 ||
+        m.vanish[0].p != V.PAWN ||
+        [V.PAWN, V.QUEEN].includes(m.appear[0].p)
+      );
+    });
     moves.forEach(m => {
       if (m.vanish.length == 2) {
         // Augment pieces abilities in case of captures