Improve Chakart rules (captures after banana/bomb redirection)
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 4 May 2020 10:26:00 +0000 (12:26 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 4 May 2020 10:26:00 +0000 (12:26 +0200)
client/src/translations/rules/Chakart/en.pug
client/src/translations/rules/Chakart/es.pug
client/src/translations/rules/Chakart/fr.pug
client/src/variants/Chakart.js

index 7870457..a89d4ae 100644 (file)
@@ -55,6 +55,7 @@ ul
   li.
     A piece arriving on a banana (resp. bomb) is redirected at random by one
     square in an orthogonal (resp. diagonal) direction, if possible.
   li.
     A piece arriving on a banana (resp. bomb) is redirected at random by one
     square in an orthogonal (resp. diagonal) direction, if possible.
+    An enemy piece could be captured in this way.
 p.
   The effects can cumulate, as illustrated on the diagram:
   the bishop "captures" the banana on e4, and is then redirected twoard e5:
 p.
   The effects can cumulate, as illustrated on the diagram:
   the bishop "captures" the banana on e4, and is then redirected twoard e5:
index b8b4781..378edce 100644 (file)
@@ -59,7 +59,7 @@ ul
   li.
     Una pieza que llega en un plátano (resp. bomba) se redirige
     aleatoriamente de una casilla en una dirección ortogonal (resp. diagonal),
   li.
     Una pieza que llega en un plátano (resp. bomba) se redirige
     aleatoriamente de una casilla en una dirección ortogonal (resp. diagonal),
-    si es posible.
+    si es posible. Une pieza enemiga podría ser capturada de esta manera.
 p.
   Los efectos pueden sumar, como se muestra en el diagrama:
   el alfil "captura" el plátano en e4, luego es redirigido a e5: hongo,
 p.
   Los efectos pueden sumar, como se muestra en el diagrama:
   el alfil "captura" el plátano en e4, luego es redirigido a e5: hongo,
index 8bd6e7e..ee04216 100644 (file)
@@ -58,7 +58,7 @@ ul
   li.
     Une pièce arrivant sur une banane (resp. bombe) est redirigée
     aléatoirement d'une case dans une direction orthogonale (resp. diagonale),
   li.
     Une pièce arrivant sur une banane (resp. bombe) est redirigée
     aléatoirement d'une case dans une direction orthogonale (resp. diagonale),
-    si possible.
+    si possible. Une pièce adverse pourrait être capturée de cette façon.
 p.
   Les effets peuvent se cumuler, comme illustré sur le diagramme :
   le fou "capture" la banane en e4, puis est redirigé vers e5 : champignon,
 p.
   Les effets peuvent se cumuler, comme illustré sur le diagramme :
   le fou "capture" la banane en e4, puis est redirigé vers e5 : champignon,
index bfbca52..73d7cfc 100644 (file)
@@ -320,7 +320,6 @@ export class ChakartRules extends ChessRules {
       const L = this.firstMove.length;
       const fm = this.firstMove[L-1];
       switch (fm.end.effect) {
       const L = this.firstMove.length;
       const fm = this.firstMove[L-1];
       switch (fm.end.effect) {
-        // case 0: a click is required (banana or bomb)
         case "kingboo":
           // Exchange position with any piece,
           // except pawns if arriving on last rank.
         case "kingboo":
           // Exchange position with any piece,
           // except pawns if arriving on last rank.
@@ -370,11 +369,12 @@ export class ChakartRules extends ChessRules {
 
   // Helper for getBasicMove()
   getRandomSquare([x, y], steps) {
 
   // Helper for getBasicMove()
   getRandomSquare([x, y], steps) {
+    const color = this.turn;
     const validSteps = steps.filter(s => {
       const [i, j] = [x + s[0], y + s[1]];
       return (
         V.OnBoard(i, j) &&
     const validSteps = steps.filter(s => {
       const [i, j] = [x + s[0], y + s[1]];
       return (
         V.OnBoard(i, j) &&
-        (this.board[i][j] == V.EMPTY || this.getColor(i, j) == 'a')
+        (this.board[i][j] == V.EMPTY || this.getColor(i, j) != color)
       );
     });
     if (validSteps.length == 0)
       );
     });
     if (validSteps.length == 0)