Saving state - unstable
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 21 Nov 2018 16:28:39 +0000 (17:28 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 21 Nov 2018 16:28:39 +0000 (17:28 +0100)
public/javascripts/base_rules.js
public/javascripts/components/game.js
public/javascripts/variants/Alice.js [new file with mode: 0644]
public/javascripts/variants/Checkered.js
public/javascripts/variants/Magnetic.js

index 5b0d5d1..d638067 100644 (file)
@@ -1019,7 +1019,7 @@ class ChessRules
                {
                        // Pawn move
                        let notation = "";
-                       if (move.vanish.length > 1)
+                       if (move.vanish.length > move.appear.length)
                        {
                                // Capture
                                let startColumn = String.fromCharCode(97 + move.start.y);
index 74092b5..5ad33d0 100644 (file)
@@ -574,7 +574,7 @@ Vue.component('my-game', {
                        this.newGame("computer");
                },
                newGame: function(mode, fenInit, color, oppId, moves, continuation) {
-                       const fen = fenInit || VariantRules.GenRandInitFen();
+                       const fen = "rbnqknbr/pppppppp/8/8/8/8/PPPPPPPP/BQRKNNRB 1111";//fenInit || VariantRules.GenRandInitFen();
                        console.log(fen); //DEBUG
                        this.score = "*";
                        if (mode=="human" && !oppId)
@@ -672,9 +672,10 @@ Vue.component('my-game', {
                                this.selectedPiece.style.display = "inline-block";
                                this.selectedPiece.style.zIndex = 3000;
                                let startSquare = this.getSquareFromId(e.target.parentNode.id);
-                               this.possibleMoves = this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
+                               this.possibleMoves = true //this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
                                        ? this.vr.getPossibleMovesFrom(startSquare)
                                        : [];
+                               console.log(this.possibleMoves);
                                e.target.parentNode.appendChild(this.selectedPiece);
                        }
                },
diff --git a/public/javascripts/variants/Alice.js b/public/javascripts/variants/Alice.js
new file mode 100644 (file)
index 0000000..673af08
--- /dev/null
@@ -0,0 +1,7 @@
+class AliceRules extends ChessRUles
+{
+       getPpath(b)
+       {
+               return ""; //TODO
+       }
+}
index 56fa15a..f1cf771 100644 (file)
@@ -1,6 +1,5 @@
 class CheckeredRules extends ChessRules
 {
-       // Path to pieces
        static getPpath(b)
        {
                return b[0]=='c' ? "Checkered/"+b : b;
index d6cf918..4c286e1 100644 (file)
@@ -20,6 +20,7 @@ class MagneticRules extends ChessRules
        }
 
        // Complete a move with magnetic actions
+       // TODO: job is done multiple times for (normal) promotions.
        applyMagneticLaws(move)
        {
                const V = VariantRules;
@@ -43,8 +44,7 @@ class MagneticRules extends ChessRules
                                        if (this.getColor(i,j) != color)
                                        {
                                                // Attraction
-                                               if ((Math.abs(i-x)>=2 || Math.abs(j-y)>=2)
-                                                       && this.getPiece(i,j) != V.KING)
+                                               if ((Math.abs(i-x)>=2 || Math.abs(j-y)>=2) && this.getPiece(i,j) != V.KING)
                                                {
                                                        move.vanish.push(
                                                                new PiPo({