Fix Pandemonium + Janggi (first move)
[vchess.git] / client / src / variants / Janggi.js
index 895e23f..aecc8fe 100644 (file)
@@ -35,10 +35,6 @@ export class JanggiRules extends ChessRules {
     return false;
   }
 
-  static get LoseOnRepetition() {
-    return true;
-  }
-
   static get ELEPHANT() {
     return "e";
   }
@@ -56,7 +52,7 @@ export class JanggiRules extends ChessRules {
   }
 
   getPpath(b) {
-    return "Jiangqi/" + b;
+    return "Janggi/" + b;
   }
 
   static get size() {
@@ -110,9 +106,14 @@ export class JanggiRules extends ChessRules {
     // TODO: next "if" is mutually exclusive with the block above
     if (this.movesCount <= 1) {
       const firstRank = (this.movesCount == 0 ? 9 : 0);
-      const [initFile, destFile] = (this.subTurn == 1 ? [1, 2] : [7, 6]);
-      // Only option is knight / elephant swap:
-      if (x == firstRank && y == initFile) {
+      const initDestFile = new Map([[1, 2], [7, 6]]);
+      // Only option is knight --> elephant swap:
+      if (
+        x == firstRank &&
+        !!initDestFile.get(y) &&
+        this.getPiece(x, y) == V.KNIGHT
+      ) {
+        const destFile = initDestFile.get(y);
         moves.push(
           new Move({
             appear: [