Almost added TitanChess + EvolutionChess
[vchess.git] / client / src / variants / Synchrone.js
index 1af9379..365dd9a 100644 (file)
@@ -2,14 +2,19 @@ import { ChessRules } from "@/base_rules";
 import { randInt } from "@/utils/alea";
 
 export class SynchroneRules extends ChessRules {
+
   static get CanAnalyze() {
-    return true; //false;
+    return false;
   }
 
   static get ShowMoves() {
     return "byrow";
   }
 
+  static get SomeHiddenMoves() {
+    return true;
+  }
+
   static IsGoodFen(fen) {
     if (!ChessRules.IsGoodFen(fen)) return false;
     const fenParsed = V.ParseFen(fen);
@@ -74,7 +79,6 @@ export class SynchroneRules extends ChessRules {
         : null;
   }
 
-  // After undo(): no need to re-set INIT_COL_KING
   scanKings() {
     this.kingPos = { w: [-1, -1], b: [-1, -1] };
     for (let i = 0; i < V.size.x; i++) {
@@ -107,11 +111,11 @@ export class SynchroneRules extends ChessRules {
   }
 
   getPossibleMovesFrom([x, y]) {
-    return (
-      this.filterValid(super.getPotentialMovesFrom([x, y]))
-      // Augment with potential recaptures:
-      .concat(this.getRecaptures([x, y]))
-    );
+    let moves = this.filterValid(super.getPotentialMovesFrom([x, y]));
+    if (!this.underCheck(this.getColor(x, y)))
+      // Augment with potential recaptures, except if we are under check
+      Array.prototype.push.apply(moves, this.getRecaptures([x, y]));
+    return moves;
   }
 
   // Aux function used to find opponent and self captures
@@ -433,7 +437,8 @@ export class SynchroneRules extends ChessRules {
     } else this.whiteMove = move.whiteMove;
   }
 
-  getCheckSquares(color) {
+  getCheckSquares() {
+    const color = this.turn;
     if (color == 'b') {
       // kingPos must be reset for appropriate highlighting:
       var lastMove = JSON.parse(JSON.stringify(this.whiteMove));
@@ -511,4 +516,5 @@ export class SynchroneRules extends ChessRules {
       V.CoordsToSquare(move.end)
     );
   }
+
 };