Add Makpong, Hoppelpoppel, and Jangqi (rules unwritten yet)
[vchess.git] / client / src / base_rules.js
index d17ebe6..293e933 100644 (file)
@@ -112,6 +112,11 @@ export const ChessRules = class ChessRules {
     return false;
   }
 
+  // Some games are drawn unusually (bottomr right corner is black)
+  static get DarkBottomRight() {
+    return false;
+  }
+
   // Some variants require lines drawing
   static get Lines() {
     if (V.Monochrome) {
@@ -126,6 +131,11 @@ export const ChessRules = class ChessRules {
     return null;
   }
 
+  // In some variants, the player who repeat a position loses
+  static get LoseOnRepetition() {
+    return false;
+  }
+
   // Some variants use click infos:
   doClick() {
     return null;
@@ -645,18 +655,12 @@ export const ChessRules = class ChessRules {
   // All possible moves from selected square
   getPotentialMovesFrom([x, y]) {
     switch (this.getPiece(x, y)) {
-      case V.PAWN:
-        return this.getPotentialPawnMoves([x, y]);
-      case V.ROOK:
-        return this.getPotentialRookMoves([x, y]);
-      case V.KNIGHT:
-        return this.getPotentialKnightMoves([x, y]);
-      case V.BISHOP:
-        return this.getPotentialBishopMoves([x, y]);
-      case V.QUEEN:
-        return this.getPotentialQueenMoves([x, y]);
-      case V.KING:
-        return this.getPotentialKingMoves([x, y]);
+      case V.PAWN: return this.getPotentialPawnMoves([x, y]);
+      case V.ROOK: return this.getPotentialRookMoves([x, y]);
+      case V.KNIGHT: return this.getPotentialKnightMoves([x, y]);
+      case V.BISHOP: return this.getPotentialBishopMoves([x, y]);
+      case V.QUEEN: return this.getPotentialQueenMoves([x, y]);
+      case V.KING: return this.getPotentialKingMoves([x, y]);
     }
     return []; //never reached
   }
@@ -969,7 +973,7 @@ export const ChessRules = class ChessRules {
           ],
           vanish: [
             // King might be initially disguised (Titan...)
-            new PiPo({ x: x, y: y, p: this.board[x][y][1], c: c }),
+            new PiPo({ x: x, y: y, p: castlingKing, c: c }),
             new PiPo({ x: x, y: rookPos, p: castlingPiece, c: c })
           ],
           end: