From 5bfb09560aa346d132e829a7c63558407bcc8091 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Wed, 21 Nov 2018 17:28:39 +0100
Subject: [PATCH] Saving state - unstable

---
 public/javascripts/base_rules.js         | 2 +-
 public/javascripts/components/game.js    | 5 +++--
 public/javascripts/variants/Alice.js     | 7 +++++++
 public/javascripts/variants/Checkered.js | 1 -
 public/javascripts/variants/Magnetic.js  | 4 ++--
 5 files changed, 13 insertions(+), 6 deletions(-)
 create mode 100644 public/javascripts/variants/Alice.js

diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js
index 5b0d5d1e..d6380675 100644
--- a/public/javascripts/base_rules.js
+++ b/public/javascripts/base_rules.js
@@ -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);
diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js
index 74092b56..5ad33d07 100644
--- a/public/javascripts/components/game.js
+++ b/public/javascripts/components/game.js
@@ -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
index 00000000..673af088
--- /dev/null
+++ b/public/javascripts/variants/Alice.js
@@ -0,0 +1,7 @@
+class AliceRules extends ChessRUles
+{
+	getPpath(b)
+	{
+		return ""; //TODO
+	}
+}
diff --git a/public/javascripts/variants/Checkered.js b/public/javascripts/variants/Checkered.js
index 56fa15a3..f1cf771f 100644
--- a/public/javascripts/variants/Checkered.js
+++ b/public/javascripts/variants/Checkered.js
@@ -1,6 +1,5 @@
 class CheckeredRules extends ChessRules
 {
-	// Path to pieces
 	static getPpath(b)
 	{
 		return b[0]=='c' ? "Checkered/"+b : b;
diff --git a/public/javascripts/variants/Magnetic.js b/public/javascripts/variants/Magnetic.js
index d6cf918c..4c286e1d 100644
--- a/public/javascripts/variants/Magnetic.js
+++ b/public/javascripts/variants/Magnetic.js
@@ -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({
-- 
2.44.0