Fix parseInt() usage, rename Doubleorda --> Ordamirror, implement Clorange variant
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 19 May 2020 19:45:52 +0000 (21:45 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 19 May 2020 19:45:52 +0000 (21:45 +0200)
68 files changed:
TODO
client/public/images/pieces/Clorange/bc.svg [new symlink]
client/public/images/pieces/Clorange/bo.svg [new symlink]
client/public/images/pieces/Clorange/bs.svg [new symlink]
client/public/images/pieces/Clorange/bt.svg [new symlink]
client/public/images/pieces/Clorange/bu.svg [new symlink]
client/public/images/pieces/Clorange/wc.svg [new symlink]
client/public/images/pieces/Clorange/wo.svg [new symlink]
client/public/images/pieces/Clorange/ws.svg [new symlink]
client/public/images/pieces/Clorange/wt.svg [new symlink]
client/public/images/pieces/Clorange/wu.svg [new symlink]
client/src/base_rules.js
client/src/components/BaseGame.vue
client/src/components/MoveList.vue
client/src/data/challengeCheck.js
client/src/data/problemCheck.js
client/src/store.js
client/src/translations/rules/Clorange/en.pug
client/src/translations/rules/Clorange/es.pug
client/src/translations/rules/Clorange/fr.pug
client/src/translations/rules/Ordamirror/en.pug [moved from client/src/translations/rules/Doubleorda/en.pug with 100% similarity]
client/src/translations/rules/Ordamirror/es.pug [moved from client/src/translations/rules/Doubleorda/es.pug with 100% similarity]
client/src/translations/rules/Ordamirror/fr.pug [moved from client/src/translations/rules/Doubleorda/fr.pug with 100% similarity]
client/src/utils/printDiagram.js
client/src/utils/squareId.js
client/src/utils/timeControl.js
client/src/variants/Alice.js
client/src/variants/Antiking1.js
client/src/variants/Antiking2.js
client/src/variants/Apocalypse.js
client/src/variants/Arena.js
client/src/variants/Ball.js
client/src/variants/Baroque.js
client/src/variants/Cannibal.js
client/src/variants/Chakart.js
client/src/variants/Checkered1.js
client/src/variants/Clorange.js
client/src/variants/Coregal.js
client/src/variants/Crazyhouse.js
client/src/variants/Extinction.js
client/src/variants/Football.js
client/src/variants/Forward.js
client/src/variants/Grand.js
client/src/variants/Hamilton.js
client/src/variants/Hidden.js
client/src/variants/Horde.js
client/src/variants/Interweave.js
client/src/variants/Kinglet.js
client/src/variants/Koopa.js
client/src/variants/Maxima.js
client/src/variants/Minishogi.js
client/src/variants/Monochrome.js
client/src/variants/Omega.js
client/src/variants/Ordamirror.js [moved from client/src/variants/Doubleorda.js with 100% similarity]
client/src/variants/Pacifist1.js
client/src/variants/Parachute.js
client/src/variants/Recycle.js
client/src/variants/Rococo.js
client/src/variants/Schess.js
client/src/variants/Shogi.js
client/src/variants/Suicide.js
client/src/variants/Threechecks.js
client/src/variants/Twokings.js
client/src/variants/Wormhole.js
client/src/views/Game.vue
client/src/views/Hall.vue
client/src/views/MyGames.vue
server/db/populate.sql

diff --git a/TODO b/TODO
index 0698ddf..f4d2c50 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,11 +3,6 @@ Also: if new live game starts in background, "new game" notify OK but not first
 On smartphone for Teleport, Chakart, Weiqi and some others: option "confirm moves on touch screen"
 (=> comme pour corr) + option "confirm moves in corr games"?
 
 On smartphone for Teleport, Chakart, Weiqi and some others: option "confirm moves on touch screen"
 (=> comme pour corr) + option "confirm moves in corr games"?
 
-Clorange:
-Clockwork Orange Chess (Fergus Duniho,
-1999). https://www.chessvariants.com/other.dir/clockworkorange.html
-implem : pieces code, yellow/red, easy
-
 https://www.chessvariants.com/difftaking.dir/replacement.html
 
 https://www.chessvariants.com/other.dir/pocket.html
 https://www.chessvariants.com/difftaking.dir/replacement.html
 
 https://www.chessvariants.com/other.dir/pocket.html
diff --git a/client/public/images/pieces/Clorange/bc.svg b/client/public/images/pieces/Clorange/bc.svg
new file mode 120000 (symlink)
index 0000000..b30a26a
--- /dev/null
@@ -0,0 +1 @@
+../Alice/bc.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/bo.svg b/client/public/images/pieces/Clorange/bo.svg
new file mode 120000 (symlink)
index 0000000..1200186
--- /dev/null
@@ -0,0 +1 @@
+../Alice/bo.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/bs.svg b/client/public/images/pieces/Clorange/bs.svg
new file mode 120000 (symlink)
index 0000000..e8cf23a
--- /dev/null
@@ -0,0 +1 @@
+../Alice/bs.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/bt.svg b/client/public/images/pieces/Clorange/bt.svg
new file mode 120000 (symlink)
index 0000000..c517549
--- /dev/null
@@ -0,0 +1 @@
+../Alice/bt.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/bu.svg b/client/public/images/pieces/Clorange/bu.svg
new file mode 120000 (symlink)
index 0000000..09e6ea3
--- /dev/null
@@ -0,0 +1 @@
+../Alice/bu.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/wc.svg b/client/public/images/pieces/Clorange/wc.svg
new file mode 120000 (symlink)
index 0000000..d23af91
--- /dev/null
@@ -0,0 +1 @@
+../Alice/wc.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/wo.svg b/client/public/images/pieces/Clorange/wo.svg
new file mode 120000 (symlink)
index 0000000..4a85712
--- /dev/null
@@ -0,0 +1 @@
+../Alice/wo.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/ws.svg b/client/public/images/pieces/Clorange/ws.svg
new file mode 120000 (symlink)
index 0000000..659b2de
--- /dev/null
@@ -0,0 +1 @@
+../Alice/ws.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/wt.svg b/client/public/images/pieces/Clorange/wt.svg
new file mode 120000 (symlink)
index 0000000..447fc4f
--- /dev/null
@@ -0,0 +1 @@
+../Alice/wt.svg
\ No newline at end of file
diff --git a/client/public/images/pieces/Clorange/wu.svg b/client/public/images/pieces/Clorange/wu.svg
new file mode 120000 (symlink)
index 0000000..c1403b3
--- /dev/null
@@ -0,0 +1 @@
+../Alice/wu.svg
\ No newline at end of file
index ee13d5e..d219f78 100644 (file)
@@ -158,7 +158,7 @@ export const ChessRules = class ChessRules {
     // 2) Check turn
     if (!fenParsed.turn || !V.IsGoodTurn(fenParsed.turn)) return false;
     // 3) Check moves count
     // 2) Check turn
     if (!fenParsed.turn || !V.IsGoodTurn(fenParsed.turn)) return false;
     // 3) Check moves count
-    if (!fenParsed.movesCount || !(parseInt(fenParsed.movesCount) >= 0))
+    if (!fenParsed.movesCount || !(parseInt(fenParsed.movesCount, 10) >= 0))
       return false;
     // 4) Check flags
     if (V.HasFlags && (!fenParsed.flags || !V.IsGoodFlags(fenParsed.flags)))
       return false;
     // 4) Check flags
     if (V.HasFlags && (!fenParsed.flags || !V.IsGoodFlags(fenParsed.flags)))
@@ -185,7 +185,7 @@ export const ChessRules = class ChessRules {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -232,7 +232,7 @@ export const ChessRules = class ChessRules {
     return {
       // NOTE: column is always one char => max 26 columns
       // row is counted from black side => subtraction
     return {
       // NOTE: column is always one char => max 26 columns
       // row is counted from black side => subtraction
-      x: V.size.x - parseInt(sq.substr(1)),
+      x: V.size.x - parseInt(sq.substr(1), 10),
       y: sq[0].charCodeAt() - 97
     };
   }
       y: sq[0].charCodeAt() - 97
     };
   }
@@ -480,7 +480,7 @@ export const ChessRules = class ChessRules {
       let j = 0;
       for (let indexInRow = 0; indexInRow < rows[i].length; indexInRow++) {
         const character = rows[i][indexInRow];
       let j = 0;
       for (let indexInRow = 0; indexInRow < rows[i].length; indexInRow++) {
         const character = rows[i][indexInRow];
-        const num = parseInt(character);
+        const num = parseInt(character, 10);
         // If num is a number, just shift j:
         if (!isNaN(num)) j += num;
         // Else: something at position i,j
         // If num is a number, just shift j:
         if (!isNaN(num)) j += num;
         // Else: something at position i,j
@@ -512,7 +512,7 @@ export const ChessRules = class ChessRules {
     const fenParsed = V.ParseFen(fen);
     this.board = V.GetBoard(fenParsed.position);
     this.turn = fenParsed.turn;
     const fenParsed = V.ParseFen(fen);
     this.board = V.GetBoard(fenParsed.position);
     this.turn = fenParsed.turn;
-    this.movesCount = parseInt(fenParsed.movesCount);
+    this.movesCount = parseInt(fenParsed.movesCount, 10);
     this.setOtherVariables(fen);
   }
 
     this.setOtherVariables(fen);
   }
 
@@ -536,7 +536,7 @@ export const ChessRules = class ChessRules {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
-            const num = parseInt(fenRows[i].charAt(j));
+            const num = parseInt(fenRows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index e7e097f..cb65f03 100644 (file)
@@ -87,6 +87,7 @@ export default {
       endgameMessage: "",
       orientation: "w",
       mode: "",
       endgameMessage: "",
       orientation: "w",
       mode: "",
+      gameMode: "",
       score: "*", //'*' means 'unfinished'
       moves: [],
       cursor: -1, //index of the move just played
       score: "*", //'*' means 'unfinished'
       moves: [],
       cursor: -1, //index of the move just played
@@ -298,7 +299,7 @@ export default {
       }
       else {
         // Exit analyze mode:
       }
       else {
         // Exit analyze mode:
-        this.mode = this.gameMode ;
+        this.mode = this.gameMode;
         this.cursor = this.gameCursor;
         this.moves = this.gameMoves;
         let fen = this.game.fenStart;
         this.cursor = this.gameCursor;
         this.moves = this.gameMoves;
         let fen = this.game.fenStart;
@@ -464,11 +465,11 @@ export default {
           this.stackToPlay.unshift(move);
           return;
         }
           this.stackToPlay.unshift(move);
           return;
         }
-        this.inPlay = true;
         if (this.mode == "analyze") this.toggleAnalyze();
         if (this.cursor < this.moves.length - 1)
           // To play a received move, cursor must be at the end of the game:
           this.gotoEnd();
         if (this.mode == "analyze") this.toggleAnalyze();
         if (this.cursor < this.moves.length - 1)
           // To play a received move, cursor must be at the end of the game:
           this.gotoEnd();
+        this.inPlay = true;
       }
       // The board may show some possible moves: (TODO: bad solution)
       this.$refs["board"].resetCurrentAttempt();
       }
       // The board may show some possible moves: (TODO: bad solution)
       this.$refs["board"].resetCurrentAttempt();
index 6385ea0..2e011b4 100644 (file)
@@ -81,7 +81,7 @@ export default {
     document.getElementById("adjuster")
       .addEventListener("click", processModalClick);
     // Take full width on small screens:
     document.getElementById("adjuster")
       .addEventListener("click", processModalClick);
     // Take full width on small screens:
-    let boardSize = parseInt(localStorage.getItem("boardSize"));
+    let boardSize = parseInt(localStorage.getItem("boardSize"), 10);
     if (!boardSize) {
       boardSize =
         window.innerWidth >= 768
     if (!boardSize) {
       boardSize =
         window.innerWidth >= 768
index fbfb445..7665f6f 100644 (file)
@@ -1,7 +1,7 @@
 import { extractTime } from "@/utils/timeControl";
 
 export function checkChallenge(c) {
 import { extractTime } from "@/utils/timeControl";
 
 export function checkChallenge(c) {
-  const vid = parseInt(c.vid);
+  const vid = parseInt(c.vid, 10);
   if (isNaN(vid) || vid <= 0) return "Please select a variant";
 
   const tc = extractTime(c.cadence);
   if (isNaN(vid) || vid <= 0) return "Please select a variant";
 
   const tc = extractTime(c.cadence);
index d6b916c..8ee101f 100644 (file)
@@ -1,5 +1,5 @@
 export function checkProblem(p) {
 export function checkProblem(p) {
-  const vid = parseInt(p.vid);
+  const vid = parseInt(p.vid, 10);
   if (isNaN(vid) || vid <= 0) return "Please select a variant";
 
   if (!V.IsGoodFen(p.fen)) return "Errors in FEN";
   if (isNaN(vid) || vid <= 0) return "Please select a variant";
 
   if (!V.IsGoodFen(p.fen)) return "Errors in FEN";
index 0bfeeeb..45535f8 100644 (file)
@@ -90,7 +90,7 @@ export const store = {
       hints: getItemDefaultTrue("hints"),
       highlight: getItemDefaultTrue("highlight"),
       gotonext: getItemDefaultTrue("gotonext"),
       hints: getItemDefaultTrue("hints"),
       highlight: getItemDefaultTrue("highlight"),
       gotonext: getItemDefaultTrue("gotonext"),
-      randomness: parseInt(localStorage.getItem("randomness"))
+      randomness: parseInt(localStorage.getItem("randomness"), 10)
     };
     if (isNaN(this.state.settings.randomness))
       // Default: random asymmetric
     };
     if (isNaN(this.state.settings.randomness))
       // Default: random asymmetric
index 3a33838..26679f5 100644 (file)
@@ -1,2 +1,31 @@
 p.boxed
 p.boxed
-  | TODO
+  | Captured pieces can be dropped later in the game,
+  | with or without capturing abilities.
+
+p Orthodox rules apply, with the following exceptions:
+ul
+  li.
+    When a regular (resp. non-capturing) Chess piece is captured, it is
+    replaced with a non-capturing (resp. regular) counterpart of the same
+    color and given back to the player of that color,
+    who holds it in hand until he drops it on the board.
+  li.
+    A player who has a piece in hand may use his turn to place it on any
+    empty square on the board. Pawns cannot be dropped on the last rank.
+
+p Non-capturing units appear in yellow for white, and red for black.
+
+figure.diagram-container
+  .diagram
+    | fen:3nkr2/1pNSpp1b/1p1sq3/7p/rT1N1cPp/8/PPPPPP2/R1BB1KR1:
+  figcaption The black king must capture the non-capturing white pawn.
+
+h3 Source
+
+p
+  | Slightly simplified from 
+  a(href="https://www.chessvariants.com/other.dir/clockworkorange.html")
+    | Clockwork Orange Chess
+  | &nbsp;on chessvariants.com.
+
+p Inventor: Fergus Duniho (1999)
index 3a33838..a5a8c83 100644 (file)
@@ -1,2 +1,34 @@
 p.boxed
 p.boxed
-  | TODO
+  | Las piezas capturadas se pueden soltar más adelante en el juego,
+  | con o sin capacidad de captura.
+
+p Se aplican reglas ortodoxas, con las siguientes excepciones:
+ul
+  li.
+    Cuando se captura una pieza estándar (resp. sin-captura), es
+    reemplazado por una pieza sin-captura (resp. estándar) del mismo color
+    y regresó al jugador de ese color, que lo tiene en la mano hasta que Ã©l
+    decide ponerlo en el tablero.
+  li.
+    Un jugador con una pieza en reserva puede soltarlo en cualquier casilla
+    del tablero en lugar de hacer un movimiento. Los peones no pueden alcanzar
+    la Ãºltima fila así.
+
+p.
+  Las unidades que no capturan aparecen en amarillo para las blancas,
+  y en rojo para las negras.
+
+figure.diagram-container
+  .diagram
+    | fen:3nkr2/1pNSpp1b/1p1sq3/7p/rT1N1cPp/8/PPPPPP2/R1BB1KR1:
+  figcaption El rey negro debe capturar el peón blanco sin-captura.
+
+h3 Fuente
+
+p
+  | Ligeramente simplificado desde 
+  a(href="https://www.chessvariants.com/other.dir/clockworkorange.html")
+    | Clockwork Orange Chess
+  | &nbsp;en chessvariants.com.
+
+p Inventor: Fergus Duniho (1999)
index 3a33838..1e8a406 100644 (file)
@@ -1,2 +1,34 @@
 p.boxed
 p.boxed
-  | TODO
+  | Les pièces capturées peuvent Ãªtre parachutées plus tard dans la partie,
+  | avec ou sans capacité de capture.
+
+p Les règles orthodoxes s'appliquent, avec les exceptions suivantes :
+ul
+  li.
+    Quand une pièce standard (resp. non-capturante) est capturée, elle est
+    remplacée par une pièce non-capturante (resp. standard) de la même couleur
+    et rendue au joueur de cette couleur, qui la garde en main jusqu'à ce qu'il
+    décide de la poser sur l'échiquier.
+  li.
+    Un joueur ayant une pièce en réserve peut la parachuter n'importe où sur
+    l'échiquier au lieu d'effectuer un coup. Les pions ne peuvent atteindre
+    la dernière rangée ainsi.
+
+p.
+  Les unités non-capturantes apparaissent en jaune pour les blancs,
+  et en rouge pour les noirs.
+
+figure.diagram-container
+  .diagram
+    | fen:3nkr2/1pNSpp1b/1p1sq3/7p/rT1N1cPp/8/PPPPPP2/R1BB1KR1:
+  figcaption le roi noir doit capturer le pion blanc non-capturant.
+
+h3 Source
+
+p
+  | Légèrement simplifié depuis 
+  a(href="https://www.chessvariants.com/other.dir/clockworkorange.html")
+    | Clockwork Orange Chess
+  | &nbsp;sur chessvariants.com.
+
+p Inventeur : Fergus Duniho (1999)
index aee1e96..524e12b 100644 (file)
@@ -19,7 +19,7 @@ function getShadowArray(shadow) {
   let shadowArray = ArrayFun.init(V.size.x, V.size.y, false);
   const squares = shadow.split(",");
   for (let i = 0; i < squares.length; i++) {
   let shadowArray = ArrayFun.init(V.size.x, V.size.y, false);
   const squares = shadow.split(",");
   for (let i = 0; i < squares.length; i++) {
-    const rownum = V.size.x - parseInt(squares[i]);
+    const rownum = V.size.x - parseInt(squares[i], 10);
     if (!isNaN(rownum)) {
       // Shadow a full row
       for (let i = 0; i < V.size.y; i++) shadowArray[rownum][i] = true;
     if (!isNaN(rownum)) {
       // Shadow a full row
       for (let i = 0; i < V.size.y; i++) shadowArray[rownum][i] = true;
index 58ca086..a54f1a5 100644 (file)
@@ -7,5 +7,5 @@ export function getSquareId(o) {
 // Inverse function
 export function getSquareFromId(id) {
   const idParts = id.split("-");
 // Inverse function
 export function getSquareFromId(id) {
   const idParts = id.split("-");
-  return [parseInt(idParts[1]), parseInt(idParts[2])];
+  return [parseInt(idParts[1], 10), parseInt(idParts[2], 10)];
 }
 }
index c38d08b..97d5ab6 100644 (file)
@@ -28,7 +28,7 @@ export function extractTime(cadence) {
   tcParts[0] += "m";
   const mainTimeArray = tcParts[0].match(/^([0-9]+)([smhd]+)$/);
   if (!mainTimeArray) return null;
   tcParts[0] += "m";
   const mainTimeArray = tcParts[0].match(/^([0-9]+)([smhd]+)$/);
   if (!mainTimeArray) return null;
-  const mainTimeValue = parseInt(mainTimeArray[1]);
+  const mainTimeValue = parseInt(mainTimeArray[1], 10);
   const mainTimeUnit = mainTimeArray[2][0];
   const mainTime = timeUnitToSeconds(mainTimeValue, mainTimeUnit);
   let increment = 0;
   const mainTimeUnit = mainTimeArray[2][0];
   const mainTime = timeUnitToSeconds(mainTimeValue, mainTimeUnit);
   let increment = 0;
@@ -38,7 +38,7 @@ export function extractTime(cadence) {
     tcParts[1] += "s";
     const incrementArray = tcParts[1].match(/^([0-9]+)([smhd]+)$/);
     if (!incrementArray) return null;
     tcParts[1] += "s";
     const incrementArray = tcParts[1].match(/^([0-9]+)([smhd]+)$/);
     if (!incrementArray) return null;
-    const incrementValue = parseInt(incrementArray[1]);
+    const incrementValue = parseInt(incrementArray[1], 10);
     const incrementUnit = incrementArray[2][0];
     // Increment unit cannot be larger than main unit:
     if (isLargerUnit(incrementUnit, mainTimeUnit)) return null;
     const incrementUnit = incrementArray[2][0];
     // Increment unit cannot be larger than main unit:
     if (isLargerUnit(incrementUnit, mainTimeUnit)) return null;
index 82ba6b7..61fcd01 100644 (file)
@@ -72,7 +72,7 @@ export class AliceRules extends ChessRules {
         if (['K','k','L','l'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k','L','l'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -101,7 +101,7 @@ export class AliceRules extends ChessRules {
               this.kingPos["w"] = [i, k];
               break;
             default: {
               this.kingPos["w"] = [i, k];
               break;
             default: {
-              const num = parseInt(rows[i].charAt(j));
+              const num = parseInt(rows[i].charAt(j), 10);
               if (!isNaN(num)) k += num - 1;
             }
           }
               if (!isNaN(num)) k += num - 1;
             }
           }
index ab86f69..07dae26 100644 (file)
@@ -56,7 +56,7 @@ export class Antiking1Rules extends BerolinaRules {
             this.antikingPos["w"] = [i, k];
             break;
           default: {
             this.antikingPos["w"] = [i, k];
             break;
           default: {
-            const num = parseInt(rows[i].charAt(j));
+            const num = parseInt(rows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index a7ec2a8..762ca5c 100644 (file)
@@ -43,7 +43,7 @@ export class Antiking2Rules extends ChessRules {
             this.antikingPos["w"] = [i, k];
             break;
           default: {
             this.antikingPos["w"] = [i, k];
             break;
           default: {
-            const num = parseInt(rows[i].charAt(j));
+            const num = parseInt(rows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index 2439ae5..77d17c0 100644 (file)
@@ -55,7 +55,7 @@ export class ApocalypseRules extends ChessRules {
         if (['P','p'].includes(row[i])) pawns[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['P','p'].includes(row[i])) pawns[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -139,8 +139,8 @@ export class ApocalypseRules extends ChessRules {
 
   setFlags(fenflags) {
     this.penaltyFlags = {
 
   setFlags(fenflags) {
     this.penaltyFlags = {
-      'w': parseInt(fenflags[0]),
-      'b': parseInt(fenflags[1])
+      'w': parseInt(fenflags[0], 10),
+      'b': parseInt(fenflags[1], 10)
     };
   }
 
     };
   }
 
index 7cfda1d..62d2802 100644 (file)
@@ -25,7 +25,7 @@ export class ArenaRules extends ChessRules {
         if (['K','k','Q','q'].includes(row[i])) royals[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k','Q','q'].includes(row[i])) royals[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index c9bdb33..056ec61 100644 (file)
@@ -105,7 +105,7 @@ export class BallRules extends ChessRules {
           if (withBall.includes(lowerRi)) ballCount++;
           sumElts++;
         } else {
           if (withBall.includes(lowerRi)) ballCount++;
           sumElts++;
         } else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index 1e02cdf..4ff23a0 100644 (file)
@@ -38,7 +38,7 @@ export class BaroqueRules extends ChessRules {
             this.kingPos["w"] = [i, k];
             break;
           default: {
             this.kingPos["w"] = [i, k];
             break;
           default: {
-            const num = parseInt(position[i].charAt(j));
+            const num = parseInt(position[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index 1a8a451..bd5524f 100644 (file)
@@ -49,7 +49,7 @@ export class CannibalRules extends ChessRules {
         else if (kingWhiteCodes.includes(row[i])) kings['w']++;
         if (allPiecesCodes.includes(row[i].toLowerCase())) sumElts++;
         else {
         else if (kingWhiteCodes.includes(row[i])) kings['w']++;
         if (allPiecesCodes.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -74,7 +74,7 @@ export class CannibalRules extends ChessRules {
             const color = (piece.charCodeAt(0) <= 90 ? 'w' : 'b');
             this.kingPos[color] = [i, k];
           } else {
             const color = (piece.charCodeAt(0) <= 90 ? 'w' : 'b');
             this.kingPos[color] = [i, k];
           } else {
-            const num = parseInt(rows[i].charAt(j));
+            const num = parseInt(rows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
           k++;
             if (!isNaN(num)) k += num - 1;
           }
           k++;
index 73d7cfc..1d12e42 100644 (file)
@@ -148,7 +148,7 @@ export class ChakartRules extends ChessRules {
         if (['K', 'k', 'L', 'l'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K', 'k', 'L', 'l'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -210,24 +210,25 @@ export class ChakartRules extends ChessRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
     // Initialize captured pieces' counts from FEN
     // Initialize captured pieces' counts from FEN
+    const captured =
+      V.ParseFen(fen).captured.split("").map(x => parseInt(x, 10));
     this.captured = {
       w: {
     this.captured = {
       w: {
-        [V.PAWN]: parseInt(fenParsed.captured[0]),
-        [V.ROOK]: parseInt(fenParsed.captured[1]),
-        [V.KNIGHT]: parseInt(fenParsed.captured[2]),
-        [V.BISHOP]: parseInt(fenParsed.captured[3]),
-        [V.QUEEN]: parseInt(fenParsed.captured[4]),
-        [V.KING]: parseInt(fenParsed.captured[5])
+        [V.PAWN]: captured[0],
+        [V.ROOK]: captured[1],
+        [V.KNIGHT]: captured[2],
+        [V.BISHOP]: captured[3],
+        [V.QUEEN]: captured[4],
+        [V.KING]: captured[5]
       },
       b: {
       },
       b: {
-        [V.PAWN]: parseInt(fenParsed.captured[6]),
-        [V.ROOK]: parseInt(fenParsed.captured[7]),
-        [V.KNIGHT]: parseInt(fenParsed.captured[8]),
-        [V.BISHOP]: parseInt(fenParsed.captured[9]),
-        [V.QUEEN]: parseInt(fenParsed.captured[10]),
-        [V.KING]: parseInt(fenParsed.captured[11])
+        [V.PAWN]: captured[6],
+        [V.ROOK]: captured[7],
+        [V.KNIGHT]: captured[8],
+        [V.BISHOP]: captured[9],
+        [V.QUEEN]: captured[10],
+        [V.KING]: captured[11]
       }
     };
     this.firstMove = [];
       }
     };
     this.firstMove = [];
index 561f02f..47e7375 100644 (file)
@@ -54,7 +54,7 @@ export class Checkered1Rules extends ChessRules {
     }
     // Stage 1: as Checkered2. Stage 2: checkered pieces are autonomous
     const stageInfo = V.ParseFen(fen).stage;
     }
     // Stage 1: as Checkered2. Stage 2: checkered pieces are autonomous
     const stageInfo = V.ParseFen(fen).stage;
-    this.stage = parseInt(stageInfo[0]);
+    this.stage = parseInt(stageInfo[0], 10);
     this.sideCheckered = (this.stage == 2 ? stageInfo[1] : undefined);
   }
 
     this.sideCheckered = (this.stage == 2 ? stageInfo[1] : undefined);
   }
 
index a999131..4c54e94 100644 (file)
@@ -2,15 +2,6 @@ import { ChessRules, PiPo, Move } from "@/base_rules";
 import { ArrayFun } from "@/utils/array";
 
 export class ClorangeRules extends ChessRules {
 import { ArrayFun } from "@/utils/array";
 
 export class ClorangeRules extends ChessRules {
-  static get PawnSpecs() {
-    return Object.assign(
-      {},
-      ChessRules.PawnSpecs,
-      // TODO: pawns reaching last rank promote normally? Seems better
-      { promotions: [V.PAWN] }
-    );
-  }
-
   static IsGoodFen(fen) {
     if (!ChessRules.IsGoodFen(fen)) return false;
     const fenParsed = V.ParseFen(fen);
   static IsGoodFen(fen) {
     if (!ChessRules.IsGoodFen(fen)) return false;
     const fenParsed = V.ParseFen(fen);
@@ -42,38 +33,64 @@ export class ClorangeRules extends ChessRules {
   }
 
   getReserveFen() {
   }
 
   getReserveFen() {
-    let counts = new Array(10);
-    for (
-      let i = 0;
-      i < V.PIECES.length - 1;
-      i++ //-1: no king reserve
+    return (
+      Object.keys(this.reserve).map(
+        c => Object.values(this.reserve[c]).join("")).join("")
+    );
+  }
+
+  getEpSquare(moveOrSquare) {
+    if (!moveOrSquare) return undefined;
+    if (typeof moveOrSquare === "string") {
+      const square = moveOrSquare;
+      if (square == "-") return undefined;
+      return V.SquareToCoords(square);
+    }
+    const move = moveOrSquare;
+    const s = move.start,
+          e = move.end;
+    if (
+      s.y == e.y &&
+      Math.abs(s.x - e.x) == 2 &&
+      move.vanish.length > 0 && ['p', 's'].includes(move.vanish[0].p)
     ) {
     ) {
-      // TODO: adapt
-      counts[i] = this.reserve["w"][V.PIECES[i]];
-      counts[5 + i] = this.reserve["b"][V.PIECES[i]];
+      return {
+        x: (s.x + e.x) / 2,
+        y: s.y
+      };
     }
     }
-    return counts.join("");
+    return undefined;
   }
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
   }
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
     // Also init reserves (used by the interface to show landable pieces)
     // Also init reserves (used by the interface to show landable pieces)
-    // TODO: adapt
+    const reserve =
+      V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10));
     this.reserve = {
       w: {
     this.reserve = {
       w: {
-        [V.PAWN]: parseInt(fenParsed.reserve[0]),
-        [V.ROOK]: parseInt(fenParsed.reserve[1]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[2]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[3]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[4])
+        'p': reserve[0],
+        'r': reserve[1],
+        'n': reserve[2],
+        'b': reserve[3],
+        'q': reserve[4],
+        's': reserve[5],
+        'u': reserve[6],
+        'o': reserve[7],
+        'c': reserve[8],
+        't': reserve[9]
       },
       b: {
       },
       b: {
-        [V.PAWN]: parseInt(fenParsed.reserve[5]),
-        [V.ROOK]: parseInt(fenParsed.reserve[6]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[7]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[8]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[9])
+        'p': reserve[10],
+        'r': reserve[11],
+        'n': reserve[12],
+        'b': reserve[13],
+        'q': reserve[14],
+        's': reserve[15],
+        'u': reserve[16],
+        'o': reserve[17],
+        'c': reserve[18],
+        't': reserve[19]
       }
     };
   }
       }
     };
   }
@@ -88,17 +105,27 @@ export class ClorangeRules extends ChessRules {
     return this.board[i][j].charAt(1);
   }
 
     return this.board[i][j].charAt(1);
   }
 
+  getPpath(b) {
+    return (V.NON_VIOLENT.includes(b[1]) ? "Clorange/" : "") + b;
+  }
+
   getReservePpath(index, color) {
   getReservePpath(index, color) {
-    return color + V.RESERVE_PIECES[index];
+    const prefix =
+      (V.NON_VIOLENT.includes(V.RESERVE_PIECES[index]) ? "Clorange/" : "");
+    return prefix + color + V.RESERVE_PIECES[index];
   }
 
   static get NON_VIOLENT() {
   }
 
   static get NON_VIOLENT() {
-    return ['s', 'u', 'o', 'c', 't', 'l'];
+    return ['s', 'u', 'o', 'c', 't'];
+  }
+
+  static get PIECES() {
+    return ChessRules.PIECES.concat(V.NON_VIOLENT);
   }
 
   // Ordering on reserve pieces
   static get RESERVE_PIECES() {
   }
 
   // Ordering on reserve pieces
   static get RESERVE_PIECES() {
-    return ChessRules.PIECES.concat(V.NON_VIOLENT);
+    return V.PIECES.filter(p => p != 'k');
   }
 
   getReserveMoves([x, y]) {
   }
 
   getReserveMoves([x, y]) {
@@ -106,8 +133,13 @@ export class ClorangeRules extends ChessRules {
     const p = V.RESERVE_PIECES[y];
     if (this.reserve[color][p] == 0) return [];
     let moves = [];
     const p = V.RESERVE_PIECES[y];
     if (this.reserve[color][p] == 0) return [];
     let moves = [];
-    const pawnShift = p == V.PAWN ? 1 : 0;
-    for (let i = pawnShift; i < V.size.x - pawnShift; i++) {
+    let rank1 = 0;
+    let rank2 = V.size.x - 1;
+    if (['p', 's'].includes(p)) {
+      if (color == 'w') rank1++;
+      else rank2--;
+    }
+    for (let i = rank1; i <= rank2; i++) {
       for (let j = 0; j < V.size.y; j++) {
         if (this.board[i][j] == V.EMPTY) {
           let mv = new Move({
       for (let j = 0; j < V.size.y; j++) {
         if (this.board[i][j] == V.EMPTY) {
           let mv = new Move({
@@ -130,28 +162,52 @@ export class ClorangeRules extends ChessRules {
     return moves;
   }
 
     return moves;
   }
 
-  // TODO: adapt all below:
   getPotentialMovesFrom([x, y]) {
   getPotentialMovesFrom([x, y]) {
-    if (x >= V.size.x) {
+    if (x >= V.size.x)
       // Reserves, outside of board: x == sizeX(+1)
       return this.getReserveMoves([x, y]);
       // Reserves, outside of board: x == sizeX(+1)
       return this.getReserveMoves([x, y]);
-    }
     // Standard moves
     // Standard moves
-    return super.getPotentialMovesFrom([x, y]);
+    switch (this.getPiece(x, y)) {
+      case 's': return super.getPotentialPawnMoves([x, y]);
+      case 'u': return super.getPotentialRookMoves([x, y]);
+      case 'o': return super.getPotentialKnightMoves([x, y]);
+      case 'c': return super.getPotentialBishopMoves([x, y]);
+      case 't': return super.getPotentialQueenMoves([x, y]);
+      default: return super.getPotentialMovesFrom([x, y]);
+    }
+    return []; //never reached
   }
 
   }
 
-  getPotentialPawnMoves([x, y]) {
-    
-    let moves = super.getPotentialPawnMoves([x, y]);
-    // Remove pawns on 8th rank ("fallen"):
-    const color = this.turn;
-    const lastRank = (color == "w" ? 0 : V.size.x - 1);
+  getPotentialPawnMoves(sq) {
+    let moves = super.getPotentialPawnMoves(sq);
     moves.forEach(m => {
     moves.forEach(m => {
-      if (m.appear[0].x == lastRank) m.appear.pop();
+      if (m.vanish[0].p == 's' && m.appear[0].p != 's') {
+        // Promotion pieces should be non-violent as well:
+        const pIdx = ChessRules.PIECES.findIndex(p => p == m.appear[0].p)
+        m.appear[0].p = V.NON_VIOLENT[pIdx];
+      }
     });
     return moves;
   }
 
     });
     return moves;
   }
 
+  getSlideNJumpMoves([x, y], steps, oneStep) {
+    let moves = [];
+    const canTake = ChessRules.PIECES.includes(this.getPiece(x, y));
+    outerLoop: for (let step of steps) {
+      let i = x + step[0];
+      let j = y + step[1];
+      while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) {
+        moves.push(this.getBasicMove([x, y], [i, j]));
+        if (oneStep) continue outerLoop;
+        i += step[0];
+        j += step[1];
+      }
+      if (V.OnBoard(i, j) && canTake && this.canTake([x, y], [i, j]))
+        moves.push(this.getBasicMove([x, y], [i, j]));
+    }
+    return moves;
+  }
+
   getAllValidMoves() {
     let moves = super.getAllPotentialMoves();
     const color = this.turn;
   getAllValidMoves() {
     let moves = super.getAllPotentialMoves();
     const color = this.turn;
@@ -177,20 +233,22 @@ export class ClorangeRules extends ChessRules {
     return true;
   }
 
     return true;
   }
 
-  canTake([x1, y1], [x2, y2]) {
-    // Self-captures allowed, except for the king:
-    return this.getPiece(x2, y2) != V.KING;
-  }
-
   prePlay(move) {
     super.prePlay(move);
     // Skip castle:
     if (move.vanish.length == 2 && move.appear.length == 2) return;
     const color = this.turn;
     if (move.vanish.length == 0) this.reserve[color][move.appear[0].p]--;
   prePlay(move) {
     super.prePlay(move);
     // Skip castle:
     if (move.vanish.length == 2 && move.appear.length == 2) return;
     const color = this.turn;
     if (move.vanish.length == 0) this.reserve[color][move.appear[0].p]--;
-    else if (move.vanish.length == 2 && move.vanish[1].c == color)
-      // Self-capture
-      this.reserve[color][move.vanish[1].p]++;
+    else if (move.vanish.length == 2) {
+      // Capture
+      const normal = ChessRules.PIECES.includes(move.vanish[1].p);
+      const pIdx =
+        normal
+          ? ChessRules.PIECES.findIndex(p => p == move.vanish[1].p)
+          : V.NON_VIOLENT.findIndex(p => p == move.vanish[1].p);
+      const rPiece = (normal ? V.NON_VIOLENT : ChessRules.PIECES)[pIdx];
+      this.reserve[move.vanish[1].c][rPiece]++;
+    }
   }
 
   postUndo(move) {
   }
 
   postUndo(move) {
@@ -198,14 +256,34 @@ export class ClorangeRules extends ChessRules {
     if (move.vanish.length == 2 && move.appear.length == 2) return;
     const color = this.turn;
     if (move.vanish.length == 0) this.reserve[color][move.appear[0].p]++;
     if (move.vanish.length == 2 && move.appear.length == 2) return;
     const color = this.turn;
     if (move.vanish.length == 0) this.reserve[color][move.appear[0].p]++;
-    else if (move.vanish.length == 2 && move.vanish[1].c == color)
-      this.reserve[color][move.vanish[1].p]--;
+    else if (move.vanish.length == 2) {
+      const normal = ChessRules.PIECES.includes(move.vanish[1].p);
+      const pIdx =
+        normal
+          ? ChessRules.PIECES.findIndex(p => p == move.vanish[1].p)
+          : V.NON_VIOLENT.findIndex(p => p == move.vanish[1].p);
+      const rPiece = (normal ? V.NON_VIOLENT : ChessRules.PIECES)[pIdx];
+      this.reserve[move.vanish[1].c][rPiece]--;
+    }
   }
 
   static get SEARCH_DEPTH() {
     return 2;
   }
 
   }
 
   static get SEARCH_DEPTH() {
     return 2;
   }
 
+  static get VALUES() {
+    return Object.assign(
+      {
+        s: 0.75,
+        u: 4,
+        o: 2,
+        c: 2,
+        t: 7
+      },
+      ChessRules.VALUES
+    );
+  }
+
   evalPosition() {
     let evaluation = super.evalPosition();
     // Add reserves:
   evalPosition() {
     let evaluation = super.evalPosition();
     // Add reserves:
@@ -220,16 +298,12 @@ export class ClorangeRules extends ChessRules {
   getNotation(move) {
     const finalSquare = V.CoordsToSquare(move.end);
     if (move.vanish.length > 0) {
   getNotation(move) {
     const finalSquare = V.CoordsToSquare(move.end);
     if (move.vanish.length > 0) {
-      if (move.appear.length > 0) {
-        // Standard move
-        return super.getNotation(move);
-      } else {
-        // Pawn fallen: capturing or not
-        let res = "";
-        if (move.vanish.length == 2)
-          res += V.CoordToColumn(move.start.y) + "x";
-        return res + finalSquare;
-      }
+      // Standard move (maybe with non-violent piece)
+      let notation = super.getNotation(move);
+      if (move.vanish[0].p == 's' && move.appear[0].p != 's')
+        // Fix non-violent promotions:
+        notation += "=" + move.appear[0].p.toUpperCase();
+      return notation;
     }
     // Rebirth:
     const piece =
     }
     // Rebirth:
     const piece =
index d6c736f..198cbfb 100644 (file)
@@ -37,7 +37,7 @@ export class CoregalRules extends ChessRules {
             this.kingPos["w"] = [i, k];
             break;
           default: {
             this.kingPos["w"] = [i, k];
             break;
           default: {
-            const num = parseInt(fenRows[i].charAt(j));
+            const num = parseInt(fenRows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
@@ -123,8 +123,10 @@ export class CoregalRules extends ChessRules {
         if (!!bishop1Options[pos]) delete bishop1Options[pos];
         else if (!!bishop2Options[pos]) delete bishop2Options[pos];
       });
         if (!!bishop1Options[pos]) delete bishop1Options[pos];
         else if (!!bishop2Options[pos]) delete bishop2Options[pos];
       });
-      const bishop1Pos = parseInt(sample(Object.keys(bishop1Options), 1)[0]);
-      const bishop2Pos = parseInt(sample(Object.keys(bishop2Options), 1)[0]);
+      const bishop1Pos =
+        parseInt(sample(Object.keys(bishop1Options), 1)[0], 10);
+      const bishop2Pos =
+        parseInt(sample(Object.keys(bishop2Options), 1)[0], 10);
 
       // Knights' positions are now determined
       const forbidden = [
 
       // Knights' positions are now determined
       const forbidden = [
index 8e61974..ee48544 100644 (file)
@@ -79,22 +79,23 @@ export class CrazyhouseRules extends ChessRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
     // Also init reserves (used by the interface to show landable pieces)
     // Also init reserves (used by the interface to show landable pieces)
+    const reserve =
+      V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10));
     this.reserve = {
       w: {
     this.reserve = {
       w: {
-        [V.PAWN]: parseInt(fenParsed.reserve[0]),
-        [V.ROOK]: parseInt(fenParsed.reserve[1]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[2]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[3]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[4])
+        [V.PAWN]: reserve[0],
+        [V.ROOK]: reserve[1],
+        [V.KNIGHT]: reserve[2],
+        [V.BISHOP]: reserve[3],
+        [V.QUEEN]: reserve[4]
       },
       b: {
       },
       b: {
-        [V.PAWN]: parseInt(fenParsed.reserve[5]),
-        [V.ROOK]: parseInt(fenParsed.reserve[6]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[7]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[8]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[9])
+        [V.PAWN]: reserve[5],
+        [V.ROOK]: reserve[6],
+        [V.KNIGHT]: reserve[7],
+        [V.BISHOP]: reserve[8],
+        [V.QUEEN]: reserve[9]
       }
     };
     this.promoted = ArrayFun.init(V.size.x, V.size.y, false);
       }
     };
     this.promoted = ArrayFun.init(V.size.x, V.size.y, false);
index bdea80b..db8abc0 100644 (file)
@@ -16,7 +16,7 @@ export class ExtinctionRules extends ChessRules {
     let pieces = {};
     for (let row of rows) {
       for (let i = 0; i < row.length; i++) {
     let pieces = {};
     for (let row of rows) {
       for (let i = 0; i < row.length; i++) {
-        if (isNaN(parseInt(row[i])) && !pieces[row[i]])
+        if (isNaN(parseInt(row[i], 10)) && !pieces[row[i]])
           pieces[row[i]] = true;
       }
     }
           pieces[row[i]] = true;
       }
     }
index e7e6513..1ccb2a4 100644 (file)
@@ -44,7 +44,7 @@ export class FootballRules extends ChessRules {
           pieces[row[i] == lowerRi ? "b" : "w"]++;
           sumElts++;
         } else {
           pieces[row[i] == lowerRi ? "b" : "w"]++;
           sumElts++;
         } else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index 5c5b641..8f2fc89 100644 (file)
@@ -46,7 +46,7 @@ export class ForwardRules extends ChessRules {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
-            const num = parseInt(fenRows[i].charAt(j));
+            const num = parseInt(fenRows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index b88410c..14c0cc9 100644 (file)
@@ -55,7 +55,8 @@ export class GrandRules extends ChessRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const captured = V.ParseFen(fen).captured.split("").map(parseInt);
+    const captured =
+      V.ParseFen(fen).captured.split("").map(x => parseInt(x, 10));
     // Initialize captured pieces' counts from FEN
     this.captured = {
       w: {
     // Initialize captured pieces' counts from FEN
     this.captured = {
       w: {
index 6794e72..69dd9e5 100644 (file)
@@ -50,7 +50,7 @@ export class HamiltonRules extends ChessRules {
       for (let i = 0; i < row.length; i++) {
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
       for (let i = 0; i < row.length; i++) {
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index f9455fd..2d44df5 100644 (file)
@@ -94,7 +94,7 @@ export class HiddenRules extends ChessRules {
             this.kingPos["w"] = [i, k];
             break;
           default: {
             this.kingPos["w"] = [i, k];
             break;
           default: {
-            const num = parseInt(fenRows[i].charAt(j));
+            const num = parseInt(fenRows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index aac4d27..c436811 100644 (file)
@@ -24,7 +24,7 @@ export class HordeRules extends ChessRules {
           }
           sumElts++;
         } else {
           }
           sumElts++;
         } else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index 8e0c3cc..973797d 100644 (file)
@@ -56,7 +56,7 @@ export class InterweaveRules extends ChessRules {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -97,18 +97,19 @@ export class InterweaveRules extends ChessRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
+    const captured =
+      V.ParseFen(fen).captured.split("").map(x => parseInt(x, 10));
     // Initialize captured pieces' counts from FEN
     this.captured = {
       w: {
     // Initialize captured pieces' counts from FEN
     this.captured = {
       w: {
-        [V.ROOK]: parseInt(fenParsed.captured[0]),
-        [V.KNIGHT]: parseInt(fenParsed.captured[1]),
-        [V.BISHOP]: parseInt(fenParsed.captured[2]),
+        [V.ROOK]: captured[0],
+        [V.KNIGHT]: captured[1],
+        [V.BISHOP]: captured[2]
       },
       b: {
       },
       b: {
-        [V.ROOK]: parseInt(fenParsed.captured[3]),
-        [V.KNIGHT]: parseInt(fenParsed.captured[4]),
-        [V.BISHOP]: parseInt(fenParsed.captured[5]),
+        [V.ROOK]: captured[3],
+        [V.KNIGHT]: captured[4],
+        [V.BISHOP]: captured[5]
       }
     };
     // Stack of "last move" only for intermediate captures
       }
     };
     // Stack of "last move" only for intermediate captures
index 38ca649..518069f 100644 (file)
@@ -28,7 +28,7 @@ export class KingletRules extends ChessRules {
           if (lowerRi == 'p') pawns[row[i] == lowerRi ? "b" : "w"]++;
           sumElts++;
         } else {
           if (lowerRi == 'p') pawns[row[i] == lowerRi ? "b" : "w"]++;
           sumElts++;
         } else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index f24e5b2..3f2e855 100644 (file)
@@ -49,11 +49,9 @@ export class KoopaRules extends ChessRules {
   }
 
   getStunnedFen() {
   }
 
   getStunnedFen() {
-    return (
-      Object.keys(this.stunned)
-      .map(square => square + this.stunned[square])
-      .join(",")
-    );
+    const squares = Object.keys(this.stunned);
+    if (squares.length == 0) return "-";
+    return squares.map(square => square + this.stunned[square]).join(",");
   }
 
   // Base GenRandInitFen() is fine because en-passant indicator will
   }
 
   // Base GenRandInitFen() is fine because en-passant indicator will
@@ -80,7 +78,7 @@ export class KoopaRules extends ChessRules {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
-            const num = parseInt(fenRows[i].charAt(j));
+            const num = parseInt(fenRows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
@@ -100,7 +98,7 @@ export class KoopaRules extends ChessRules {
         .map(s => {
           return {
             square: s.substr(0, 2),
         .map(s => {
           return {
             square: s.substr(0, 2),
-            state: parseInt(s[2])
+            state: parseInt(s[2], 10)
           };
         });
     }
           };
         });
     }
index 83d2076..e8b15d2 100644 (file)
@@ -49,7 +49,7 @@ export class MaximaRules extends ChessRules {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -76,7 +76,7 @@ export class MaximaRules extends ChessRules {
             this.kingPos["w"] = [i, k];
             break;
           default: {
             this.kingPos["w"] = [i, k];
             break;
           default: {
-            const num = parseInt(position[i].charAt(j));
+            const num = parseInt(position[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index 8315289..afeaa57 100644 (file)
@@ -42,22 +42,23 @@ export class MinishogiRules extends ShogiRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
     // Also init reserves (used by the interface to show landable pieces)
     // Also init reserves (used by the interface to show landable pieces)
+    const reserve =
+      V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10));
     this.reserve = {
       w: {
     this.reserve = {
       w: {
-        [V.PAWN]: parseInt(fenParsed.reserve[0]),
-        [V.ROOK]: parseInt(fenParsed.reserve[1]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[2]),
-        [V.GOLD_G]: parseInt(fenParsed.reserve[3]),
-        [V.SILVER_G]: parseInt(fenParsed.reserve[4])
+        [V.PAWN]: reserve[0],
+        [V.ROOK]: reserve[1],
+        [V.BISHOP]: reserve[2],
+        [V.GOLD_G]: reserve[3],
+        [V.SILVER_G]: reserve[4]
       },
       b: {
       },
       b: {
-        [V.PAWN]: parseInt(fenParsed.reserve[5]),
-        [V.ROOK]: parseInt(fenParsed.reserve[6]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[7]),
-        [V.GOLD_G]: parseInt(fenParsed.reserve[8]),
-        [V.SILVER_G]: parseInt(fenParsed.reserve[9])
+        [V.PAWN]: reserve[5],
+        [V.ROOK]: reserve[6],
+        [V.BISHOP]: reserve[7],
+        [V.GOLD_G]: reserve[8],
+        [V.SILVER_G]: reserve[9]
       }
     };
   }
       }
     };
   }
index b17b6f1..31cf59e 100644 (file)
@@ -23,7 +23,7 @@ export class MonochromeRules extends ChessRules {
       for (let i = 0; i < row.length; i++) {
         if (V.PIECES.includes(row[i])) sumElts++;
         else {
       for (let i = 0; i < row.length; i++) {
         if (V.PIECES.includes(row[i])) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index 258bc80..1fde582 100644 (file)
@@ -48,7 +48,7 @@ export class OmegaRules extends ChessRules {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index 234b02a..43c81d7 100644 (file)
@@ -24,7 +24,7 @@ export class Pacifist1Rules extends ChessRules {
         if (['K','k'].includes(row[i])) kingsCount++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k'].includes(row[i])) kingsCount++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -52,7 +52,7 @@ export class Pacifist1Rules extends ChessRules {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
             this.INIT_COL_KING["w"] = k;
             break;
           default: {
-            const num = parseInt(fenRows[i].charAt(j));
+            const num = parseInt(fenRows[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index 86b1ce8..8cd0f9c 100644 (file)
@@ -23,7 +23,7 @@ export class ParachuteRules extends ChessRules {
       for (let i = 0; i < row.length; i++) {
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
       for (let i = 0; i < row.length; i++) {
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
@@ -65,24 +65,25 @@ export class ParachuteRules extends ChessRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
     // Also init reserves (used by the interface to show landable pieces)
     // Also init reserves (used by the interface to show landable pieces)
+    const reserve =
+      V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10));
     this.reserve = {
       w: {
     this.reserve = {
       w: {
-        [V.PAWN]: parseInt(fenParsed.reserve[0]),
-        [V.ROOK]: parseInt(fenParsed.reserve[1]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[2]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[3]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[4]),
-        [V.KING]: parseInt(fenParsed.reserve[5])
+        [V.PAWN]: reserve[0],
+        [V.ROOK]: reserve[1],
+        [V.KNIGHT]: reserve[2],
+        [V.BISHOP]: reserve[3],
+        [V.QUEEN]: reserve[4],
+        [V.KING]: reserve[5]
       },
       b: {
       },
       b: {
-        [V.PAWN]: parseInt(fenParsed.reserve[6]),
-        [V.ROOK]: parseInt(fenParsed.reserve[7]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[8]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[9]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[10]),
-        [V.KING]: parseInt(fenParsed.reserve[11])
+        [V.PAWN]: reserve[6],
+        [V.ROOK]: reserve[7],
+        [V.KNIGHT]: reserve[8],
+        [V.BISHOP]: reserve[9],
+        [V.QUEEN]: reserve[10],
+        [V.KING]: reserve[11]
       }
     };
   }
       }
     };
   }
index bf25263..d23a78c 100644 (file)
@@ -54,22 +54,23 @@ export class RecycleRules extends ChessRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
     // Also init reserves (used by the interface to show landable pieces)
     // Also init reserves (used by the interface to show landable pieces)
+    const reserve =
+      V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10));
     this.reserve = {
       w: {
     this.reserve = {
       w: {
-        [V.PAWN]: parseInt(fenParsed.reserve[0]),
-        [V.ROOK]: parseInt(fenParsed.reserve[1]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[2]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[3]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[4])
+        [V.PAWN]: reserve[0],
+        [V.ROOK]: reserve[1],
+        [V.KNIGHT]: reserve[2],
+        [V.BISHOP]: reserve[3],
+        [V.QUEEN]: reserve[4]
       },
       b: {
       },
       b: {
-        [V.PAWN]: parseInt(fenParsed.reserve[5]),
-        [V.ROOK]: parseInt(fenParsed.reserve[6]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[7]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[8]),
-        [V.QUEEN]: parseInt(fenParsed.reserve[9])
+        [V.PAWN]: reserve[5],
+        [V.ROOK]: reserve[6],
+        [V.KNIGHT]: reserve[7],
+        [V.BISHOP]: reserve[8],
+        [V.QUEEN]: reserve[9]
       }
     };
   }
       }
     };
   }
@@ -124,10 +125,9 @@ export class RecycleRules extends ChessRules {
   }
 
   getPotentialMovesFrom([x, y]) {
   }
 
   getPotentialMovesFrom([x, y]) {
-    if (x >= V.size.x) {
+    if (x >= V.size.x)
       // Reserves, outside of board: x == sizeX(+1)
       return this.getReserveMoves([x, y]);
       // Reserves, outside of board: x == sizeX(+1)
       return this.getReserveMoves([x, y]);
-    }
     // Standard moves
     return super.getPotentialMovesFrom([x, y]);
   }
     // Standard moves
     return super.getPotentialMovesFrom([x, y]);
   }
index e0838e1..e6480a8 100644 (file)
@@ -54,7 +54,7 @@ export class RococoRules extends ChessRules {
             this.kingPos["w"] = [i, k];
             break;
           default: {
             this.kingPos["w"] = [i, k];
             break;
           default: {
-            const num = parseInt(position[i].charAt(j));
+            const num = parseInt(position[i].charAt(j), 10);
             if (!isNaN(num)) k += num - 1;
           }
         }
             if (!isNaN(num)) k += num - 1;
           }
         }
index 06644c7..9511898 100644 (file)
@@ -119,12 +119,12 @@ export class SchessRules extends ChessRules {
     const fenParsed = V.ParseFen(fen);
     this.pocket = {
       "w": {
     const fenParsed = V.ParseFen(fen);
     this.pocket = {
       "w": {
-        h: parseInt(fenParsed.pocket[0]),
-        e: parseInt(fenParsed.pocket[1])
+        h: parseInt(fenParsed.pocket[0], 10),
+        e: parseInt(fenParsed.pocket[1], 10)
       },
       "b": {
       },
       "b": {
-        h: parseInt(fenParsed.pocket[2]),
-        e: parseInt(fenParsed.pocket[3])
+        h: parseInt(fenParsed.pocket[2], 10),
+        e: parseInt(fenParsed.pocket[3], 10)
       }
     };
   }
       }
     };
   }
index 521e468..6c522dc 100644 (file)
@@ -176,26 +176,27 @@ export class ShogiRules extends ChessRules {
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
 
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
-    const fenParsed = V.ParseFen(fen);
     // Also init reserves (used by the interface to show landable pieces)
     // Also init reserves (used by the interface to show landable pieces)
+    const reserve =
+      V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10));
     this.reserve = {
       w: {
     this.reserve = {
       w: {
-        [V.PAWN]: parseInt(fenParsed.reserve[0]),
-        [V.ROOK]: parseInt(fenParsed.reserve[1]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[2]),
-        [V.GOLD_G]: parseInt(fenParsed.reserve[3]),
-        [V.SILVER_G]: parseInt(fenParsed.reserve[4]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[5]),
-        [V.LANCE]: parseInt(fenParsed.reserve[6])
+        [V.PAWN]: reserve[0],
+        [V.ROOK]: reserve[1],
+        [V.BISHOP]: reserve[2],
+        [V.GOLD_G]: reserve[3],
+        [V.SILVER_G]: reserve[4],
+        [V.KNIGHT]: reserve[5],
+        [V.LANCE]: reserve[6]
       },
       b: {
       },
       b: {
-        [V.PAWN]: parseInt(fenParsed.reserve[7]),
-        [V.ROOK]: parseInt(fenParsed.reserve[8]),
-        [V.BISHOP]: parseInt(fenParsed.reserve[9]),
-        [V.GOLD_G]: parseInt(fenParsed.reserve[10]),
-        [V.SILVER_G]: parseInt(fenParsed.reserve[11]),
-        [V.KNIGHT]: parseInt(fenParsed.reserve[12]),
-        [V.LANCE]: parseInt(fenParsed.reserve[13])
+        [V.PAWN]: reserve[7],
+        [V.ROOK]: reserve[8],
+        [V.BISHOP]: reserve[9],
+        [V.GOLD_G]: reserve[10],
+        [V.SILVER_G]: reserve[11],
+        [V.KNIGHT]: reserve[12],
+        [V.LANCE]: reserve[13]
       }
     };
   }
       }
     };
   }
index 2693f84..ecb2aef 100644 (file)
@@ -29,7 +29,7 @@ export class SuicideRules extends ChessRules {
           pieces[row[i] == lowerRi ? "b" : "w"]++;
           sumElts++;
         } else {
           pieces[row[i] == lowerRi ? "b" : "w"]++;
           sumElts++;
         } else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index 175b124..0525059 100644 (file)
@@ -11,7 +11,7 @@ export class ThreechecksRules extends ChessRules {
     this.checkFlags = { w: 0, b: 0 };
     const flags = fenflags.substr(4); //skip first 4 digits, for castle
     for (let c of ["w", "b"]) {
     this.checkFlags = { w: 0, b: 0 };
     const flags = fenflags.substr(4); //skip first 4 digits, for castle
     for (let c of ["w", "b"]) {
-      this.checkFlags[c] = parseInt(flags.charAt(c == "w" ? 0 : 1));
+      this.checkFlags[c] = parseInt(flags.charAt(c == "w" ? 0 : 1), 10);
     }
   }
 
     }
   }
 
index 52aebc3..d56d095 100644 (file)
@@ -21,7 +21,7 @@ export class TwokingsRules extends CoregalRules {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index cc9fd49..1f3ecd2 100644 (file)
@@ -39,7 +39,7 @@ export class WormholeRules extends ChessRules {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
         if (['K','k'].includes(row[i])) kings[row[i]]++;
         if (['x'].concat(V.PIECES).includes(row[i].toLowerCase())) sumElts++;
         else {
-          const num = parseInt(row[i]);
+          const num = parseInt(row[i], 10);
           if (isNaN(num)) return false;
           sumElts += num;
         }
           if (isNaN(num)) return false;
           sumElts += num;
         }
index 6722f33..cd781a5 100644 (file)
@@ -1285,7 +1285,10 @@ console.log(data.data);
     //  - from server (one correspondance game I play[ed] or not)
     //  - from remote peer (one live game I don't play, finished or not)
     fetchGame: function(callback) {
     //  - from server (one correspondance game I play[ed] or not)
     //  - from remote peer (one live game I don't play, finished or not)
     fetchGame: function(callback) {
-      if (Number.isInteger(this.gameRef) || !isNaN(parseInt(this.gameRef))) {
+      if (
+        Number.isInteger(this.gameRef) ||
+        !isNaN(parseInt(this.gameRef, 10))
+      ) {
         // corr games identifiers are integers
         ajax(
           "/games",
         // corr games identifiers are integers
         ajax(
           "/games",
index 146beb0..451299b 100644 (file)
@@ -240,12 +240,12 @@ export default {
       infoMessage: "",
       newchallenge: {
         fen: "",
       infoMessage: "",
       newchallenge: {
         fen: "",
-        vid: parseInt(localStorage.getItem("vid")) || 0,
+        vid: parseInt(localStorage.getItem("vid"), 10) || 0,
         to: "", //name of challenged player (if any)
         cadence: localStorage.getItem("cadence") || "",
         randomness:
           // Warning: randomness can be 0, then !!randomness is false
         to: "", //name of challenged player (if any)
         cadence: localStorage.getItem("cadence") || "",
         randomness:
           // Warning: randomness can be 0, then !!randomness is false
-          (parseInt(localStorage.getItem("challRandomness"))+1 || 3) - 1,
+          (parseInt(localStorage.getItem("challRandomness"),10)+1 || 3) - 1,
         // VariantRules object, stored to not interfere with
         // diagrams of targetted challenges:
         V: null,
         // VariantRules object, stored to not interfere with
         // diagrams of targetted challenges:
         V: null,
index 6835b55..5c3522e 100644 (file)
@@ -244,7 +244,7 @@ export default {
         case "notifyturn":
         case "notifyscore": {
           const info = data.data;
         case "notifyturn":
         case "notifyscore": {
           const info = data.data;
-          const type = (!!parseInt(info.gid) ? "corr" : "live");
+          const type = (!!parseInt(info.gid, 10) ? "corr" : "live");
           let game = gamesArrays[type].find(g => g.id == info.gid);
           // "notifything" --> "thing":
           const thing = data.code.substr(6);
           let game = gamesArrays[type].find(g => g.id == info.gid);
           // "notifything" --> "thing":
           const thing = data.code.substr(6);
index 703297a..60578f8 100644 (file)
@@ -43,7 +43,6 @@ insert or ignore into Variants (name, description) values
   ('Doublearmy', '64 pieces on the board'),
   ('Doublemove1', 'Double moves (v1)'),
   ('Doublemove2', 'Double moves (v2)'),
   ('Doublearmy', '64 pieces on the board'),
   ('Doublemove1', 'Double moves (v1)'),
   ('Doublemove2', 'Double moves (v2)'),
-  ('Doubleorda', 'Mongolian Horde (v2)'),
   ('Dynamo', 'Push and pull'),
   ('Eightpieces', 'Each piece is unique'),
   ('Enpassant', 'Capture en passant'),
   ('Dynamo', 'Push and pull'),
   ('Eightpieces', 'Each piece is unique'),
   ('Enpassant', 'Capture en passant'),
@@ -73,6 +72,7 @@ insert or ignore into Variants (name, description) values
   ('Monster', 'White move twice'),
   ('Omega', 'A wizard in the corner'),
   ('Orda', 'Mongolian Horde (v1)'),
   ('Monster', 'White move twice'),
   ('Omega', 'A wizard in the corner'),
   ('Orda', 'Mongolian Horde (v1)'),
+  ('Ordamirror', 'Mongolian Horde (v2)'),
   ('Pacifist1', 'Convert & support (v1)'),
   ('Pacifist2', 'Convert & support (v2)'),
   ('Parachute', 'Landing on the board'),
   ('Pacifist1', 'Convert & support (v1)'),
   ('Pacifist2', 'Convert & support (v2)'),
   ('Parachute', 'Landing on the board'),