Add Fanorona
[vchess.git] / client / src / variants / Yote.js
index 7158d4f..76d7c2e 100644 (file)
@@ -23,6 +23,25 @@ export class YoteRules extends ChessRules {
     return true;
   }
 
+  static IsGoodPosition(position) {
+    if (position.length == 0) return false;
+    const rows = position.split("/");
+    if (rows.length != V.size.x) return false;
+    for (let row of rows) {
+      let sumElts = 0;
+      for (let i = 0; i < row.length; i++) {
+        if (row[i].toLowerCase() == V.PAWN) sumElts++;
+        else {
+          const num = parseInt(row[i], 10);
+          if (isNaN(num) || num <= 0) return false;
+          sumElts += num;
+        }
+      }
+      if (sumElts != V.size.y) return false;
+    }
+    return true;
+  }
+
   static IsGoodFen(fen) {
     if (!ChessRules.IsGoodFen(fen)) return false;
     const fenParsed = V.ParseFen(fen);
@@ -120,10 +139,6 @@ export class YoteRules extends ChessRules {
     return { x: 5, y: 6 };
   }
 
-  static get PIECES() {
-    return [V.PAWN];
-  }
-
   getColor(i, j) {
     if (i >= V.size.x) return i == V.size.x ? "w" : "b";
     return this.board[i][j].charAt(0);