Do not show chat button in blue if game is over
[vchess.git] / client / src / base_rules.js
index 42d9bdc..350e0de 100644 (file)
@@ -32,13 +32,26 @@ export const ChessRules = class ChessRules {
   //////////////
   // MISC UTILS
 
+  // Some variants don't have flags:
   static get HasFlags() {
     return true;
-  } //some variants don't have flags
+  }
 
+  // Some variants don't have en-passant
   static get HasEnpassant() {
     return true;
-  } //some variants don't have ep.
+  }
+
+  // Some variants cannot have analyse mode
+  static get CanAnalyze() {
+    return true;
+  }
+
+  // Some variants show incomplete information,
+  // and thus show only a partial moves list or no list at all.
+  static get ShowMoves() {
+    return "all";
+  }
 
   // Path to pieces
   static getPpath(b) {
@@ -83,9 +96,12 @@ export const ChessRules = class ChessRules {
     if (position.length == 0) return false;
     const rows = position.split("/");
     if (rows.length != V.size.x) return false;
+    let kings = {};
     for (let row of rows) {
       let sumElts = 0;
       for (let i = 0; i < row.length; i++) {
+        if (['K','k'].includes(row[i]))
+          kings[row[i]] = true;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
           const num = parseInt(row[i]);
@@ -95,6 +111,9 @@ export const ChessRules = class ChessRules {
       }
       if (sumElts != V.size.y) return false;
     }
+    // Both kings should be on board:
+    if (Object.keys(kings).length != 2)
+      return false;
     return true;
   }