Add Alapo, Crossing, Kingsmaker, Squatter variants
[vchess.git] / client / src / variants / Suicide.js
index 2693f84..e71e3a2 100644 (file)
@@ -3,6 +3,7 @@ import { ArrayFun } from "@/utils/array";
 import { shuffle } from "@/utils/alea";
 
 export class SuicideRules extends ChessRules {
+
   static get HasFlags() {
     return false;
   }
@@ -28,8 +29,9 @@ export class SuicideRules extends ChessRules {
         if (V.PIECES.includes(lowerRi)) {
           pieces[row[i] == lowerRi ? "b" : "w"]++;
           sumElts++;
-        } else {
-          const num = parseInt(row[i]);
+        }
+        else {
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -50,12 +52,11 @@ export class SuicideRules extends ChessRules {
   // Stop at the first capture found (if any)
   atLeastOneCapture() {
     const color = this.turn;
-    const oppCol = V.GetOppCol(color);
     for (let i = 0; i < V.size.x; i++) {
       for (let j = 0; j < V.size.y; j++) {
         if (
           this.board[i][j] != V.EMPTY &&
-          this.getColor(i, j) != oppCol &&
+          this.getColor(i, j) == color &&
           this.getPotentialMovesFrom([i, j]).some(m => m.vanish.length == 2)
         ) {
           return true;
@@ -166,4 +167,5 @@ export class SuicideRules extends ChessRules {
       " w 0 -"
     );
   }
+
 };