Fix Joker
authorBenjamin Auder <benjamin.auder@somewhere>
Sun, 25 Apr 2021 07:49:21 +0000 (09:49 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Sun, 25 Apr 2021 07:49:21 +0000 (09:49 +0200)
client/src/translations/rules/Joker/en.pug
client/src/translations/rules/Joker/es.pug
client/src/translations/rules/Joker/fr.pug
client/src/variants/Joker.js

index 1f10238..b7a0535 100644 (file)
@@ -4,7 +4,7 @@ p.boxed
 p.
   A new piece appears, starting in front of the pawns.
   It moves like an Amazon: Queen + Knight, but doesn't capture.
 p.
   A new piece appears, starting in front of the pawns.
   It moves like an Amazon: Queen + Knight, but doesn't capture.
-  Instead, it can swap its position with any piece.
+  Instead, it can swap its position with any piece except the king.
 
 figure.diagram-container
   .diagram
 
 figure.diagram-container
   .diagram
index 7aaaf9f..6c06621 100644 (file)
@@ -4,7 +4,7 @@ p.boxed
 p.
   Aparece una nueva pieza, comenzando por delante de los peones.
   Se mueve como una Amazona: Dama + Caballo, pero no captura.
 p.
   Aparece una nueva pieza, comenzando por delante de los peones.
   Se mueve como una Amazona: Dama + Caballo, pero no captura.
-  En cambio, puede cambiar su posición con cualquier pieza.
+  En cambio, puede cambiar su posición con cualquier pieza excepto el rey.
 
 figure.diagram-container
   .diagram
 
 figure.diagram-container
   .diagram
index 853d704..bb64c0b 100644 (file)
@@ -5,7 +5,8 @@ p.boxed
 p.
   Une nouvelle pièce fait son apparition, démarrant devant les pions.
   Elle se déplace comme une Amazone : Dame + Cavalier, mais ne capture pas.
 p.
   Une nouvelle pièce fait son apparition, démarrant devant les pions.
   Elle se déplace comme une Amazone : Dame + Cavalier, mais ne capture pas.
-  Au lieu de ça, elle peut échanger sa position avec n'importe quelle pièce.
+  Au lieu de ça, elle peut échanger sa position avec n'importe quelle pièce
+  sauf le roi.
 
 figure.diagram-container
   .diagram
 
 figure.diagram-container
   .diagram
index bc3a7f1..a3cbdad 100644 (file)
@@ -58,18 +58,21 @@ export class JokerRules extends ChessRules {
         // Following test is OK because only one Joker on board at a time
         if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == c) {
           const p = this.getPiece(i, j);
         // Following test is OK because only one Joker on board at a time
         if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == c) {
           const p = this.getPiece(i, j);
-          swapping.push(
-            new Move({
-              vanish: [
-                new PiPo({ x: x, y: y, c: c, p: V.JOKER }),
-                new PiPo({ x: i, y: j, c: c, p: p })
-              ],
-              appear: [
-                new PiPo({ x: i, y: j, c: c, p: V.JOKER }),
-                new PiPo({ x: x, y: y, c: c, p: p })
-              ]
-            })
-          );
+          const lastRank = (c == 'w' ? 0 : 7);
+          if (p != V.KING && (p != V.PAWN || x != lastRank)) {
+            swapping.push(
+              new Move({
+                vanish: [
+                  new PiPo({ x: x, y: y, c: c, p: V.JOKER }),
+                  new PiPo({ x: i, y: j, c: c, p: p })
+                ],
+                appear: [
+                  new PiPo({ x: i, y: j, c: c, p: V.JOKER }),
+                  new PiPo({ x: x, y: y, c: c, p: p })
+                ]
+              })
+            );
+          }
         }
       }
     }
         }
       }
     }