Fix some typos and forgotten things
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 19 Dec 2018 20:18:16 +0000 (21:18 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 19 Dec 2018 20:18:16 +0000 (21:18 +0100)
public/javascripts/components/game.js
public/javascripts/variants/Antiking.js
public/javascripts/variants/Crazyhouse.js
public/javascripts/variants/Grand.js
public/javascripts/variants/Magnetic.js
public/javascripts/variants/Zen.js

index e229cdf..a17876d 100644 (file)
@@ -1316,7 +1316,8 @@ Vue.component('my-game', {
                                const storageVariant = localStorage.getItem("comp-variant");
                                if (!!storageVariant)
                                {
-                                       if (storageVariant !== variant)
+                                       const score = localStorage.getItem("comp-score");
+                                       if (storageVariant !== variant && score == "*")
                                        {
                                                if (!confirm("Unfinished " + storageVariant +
                                                        " computer game will be erased"))
@@ -1324,12 +1325,8 @@ Vue.component('my-game', {
                                                        return;
                                                }
                                        }
-                                       else
-                                       {
-                                               const score = localStorage.getItem("comp-score");
-                                               if (score == "*")
-                                                       return this.continueGame("computer");
-                                       }
+                                       else if (score == "*")
+                                               return this.continueGame("computer");
                                }
                        }
                        this.vr = new VariantRules(fen, []);
index 0d34271..e4d402c 100644 (file)
@@ -201,7 +201,7 @@ class AntikingRules extends ChessRules
                return pieces["b"].join("") + "/" + ranks23_black +
                        "/8/8/" +
                        ranks23_white + "/" + pieces["w"].join("").toUpperCase() +
-                       " w 1111";
+                       " w 1111 -";
        }
 }
 
index afebcc3..1fff1e9 100644 (file)
@@ -24,10 +24,21 @@ class CrazyhouseRules extends ChessRules
                return true;
        }
 
+       static ParseFen(fen)
+       {
+               const fenParts = fen.split(" ");
+               return Object.assign(
+                       ChessRules.ParseFen(fen),
+                       {
+                               reserve: fenParts[4],
+                               promoted: fenParts[5],
+                       }
+               );
+       }
+
        static GenRandInitFen()
        {
-               const fen = ChessRules.GenRandInitFen();
-               return fen.replace(" w 1111", " w 1111 0000000000 -");
+               return ChessRules.GenRandInitFen() + " 0000000000 -";
        }
 
        getFen()
@@ -59,6 +70,8 @@ class CrazyhouseRules extends ChessRules
                }
                if (res.length > 0)
                        res = res.slice(0,-1); //remove last comma
+               else
+                       res = "-";
                return res;
        }
 
@@ -87,10 +100,13 @@ class CrazyhouseRules extends ChessRules
                        }
                };
                this.promoted = doubleArray(V.size.x, V.size.y, false);
-               for (let square of fenParsd.promoted.split(","))
+               if (fenParsed.promoted != "-")
                {
-                       const [x,y] = V.SquareToCoords(square);
-                       promoted[x][y] = true;
+                       for (let square of fenParsed.promoted.split(","))
+                       {
+                               const [x,y] = V.SquareToCoords(square);
+                               promoted[x][y] = true;
+                       }
                }
        }
 
index ec2afd8..22b2494 100644 (file)
@@ -18,10 +18,18 @@ class GrandRules extends ChessRules
                return true;
        }
 
+       static ParseFen(fen)
+       {
+               const fenParts = fen.split(" ");
+               return Object.assign(
+                       ChessRules.ParseFen(fen),
+                       { captured: fenParts[4] }
+               );
+       }
+
        static GenRandInitFen()
        {
-               const fen = ChessRules.GenRandInitFen();
-               return fen.replace(" w 1111", " w 1111 0000000000");
+               return ChessRules.GenRandInitFen() + " 0000000000";
        }
 
        getFen()
index 17efeaa..6682b27 100644 (file)
@@ -1,6 +1,6 @@
 class MagneticRules extends ChessRules
 {
-       static get HasEnpassant { return false; }
+       static get HasEnpassant() { return false; }
 
        setOtherVariables(fen)
        {
index b090a29..66cd61f 100644 (file)
@@ -1,7 +1,7 @@
 class ZenRules extends ChessRules
 {
        // NOTE: enPassant, if enabled, would need to redefine carefully getEpSquare
-       static get HasEnpassant { return false; }
+       static get HasEnpassant() { return false; }
 
        // TODO(?): some duplicated code in 2 next functions
        getSlideNJumpMoves([x,y], steps, oneStep)