Add FB and Twitter links on main page. Only icons, no text for Discord + Github as...
[vchess.git] / client / src / base_rules.js
index 99de626..e0353e8 100644 (file)
@@ -80,6 +80,19 @@ export const ChessRules = class ChessRules {
     return V.ShowMoves;
   }
 
+  // Sometimes moves must remain hidden until game ends
+  static get SomeHiddenMoves() {
+    return false;
+  }
+  get someHiddenMoves() {
+    return V.SomeHiddenMoves;
+  }
+
+  // Generally true, unless the variant includes random effects
+  static get CorrConfirm() {
+    return true;
+  }
+
   // Used for Monochrome variant (TODO: harmonize: !canFlip ==> showFirstTurn)
   get showFirstTurn() {
     return false;
@@ -117,6 +130,11 @@ export const ChessRules = class ChessRules {
     return null;
   }
 
+  // Some variants may need to highlight squares on hover (Hamilton, Weiqi...)
+  hoverHighlight() {
+    return false;
+  }
+
   static get IMAGE_EXTENSION() {
     // All pieces should be in the SVG format
     return ".svg";
@@ -733,8 +751,7 @@ export const ChessRules = class ChessRules {
     if (x2 == lastRank) {
       // promotions arg: special override for Hiddenqueen variant
       if (!!promotions) finalPieces = promotions;
-      else if (!!V.PawnSpecs.promotions)
-        finalPieces = V.PawnSpecs.promotions;
+      else if (!!V.PawnSpecs.promotions) finalPieces = V.PawnSpecs.promotions;
     }
     let tr = null;
     for (let piece of finalPieces) {
@@ -783,10 +800,7 @@ export const ChessRules = class ChessRules {
         // Captures
         if (V.PawnSpecs.canCapture) {
           for (let shiftY of [-1, 1]) {
-            if (
-              y + shiftY >= 0 &&
-              y + shiftY < sizeY
-            ) {
+            if (y + shiftY >= 0 && y + shiftY < sizeY) {
               if (
                 this.board[x + shiftX][y + shiftY] != V.EMPTY &&
                 this.canTake([x, y], [x + shiftX, y + shiftY])
@@ -903,6 +917,7 @@ export const ChessRules = class ChessRules {
         if (
           // NOTE: "castling" arg is used by some variants (Monster),
           // where "isAttacked" is overloaded in an infinite-recursive way.
+          // TODO: not used anymore (Monster + Doublemove2 are simplified).
           (!castleInCheck && this.isAttacked([x, i], oppCol, "castling")) ||
           (this.board[x][i] != V.EMPTY &&
             // NOTE: next check is enough, because of chessboard constraints