From 15952ada1d73262371654351ab8a4471f64010fd Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Sat, 8 Dec 2018 01:39:20 +0100 Subject: [PATCH] Improve Switching chess: avoid duplicate moves for analysis, better notation --- TODO | 1 + public/javascripts/base_rules.js | 18 ++++------ public/javascripts/variants/Switching.js | 43 ++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index 1aae2fb1..26aabd51 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +Allow to navigate in game after it's over (back/play) For animation, moves should contains "moving" and "fading" maybe... (But it's really just for Magnetic chess) setInterval "CRON" task in sockets.js to check connected clients diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 48a5602c..ee5ddd02 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -821,7 +821,9 @@ class ChessRules this.shouldReturn = false; const maxeval = VariantRules.INFINITY; const color = this.turn; - let moves1 = this.getAllValidMoves(); + // Some variants may show a bigger moves list to the human (Switching), + // thus the argument "computer" below (which is generally ignored) + let moves1 = this.getAllValidMoves("computer"); // Can I mate in 1 ? (for Magnetic & Extinction) for (let i of _.shuffle(_.range(moves1.length))) @@ -843,7 +845,7 @@ class ChessRules { eval2 = (color=="w" ? 1 : -1) * maxeval; //initialized with checkmate value // Second half-move: - let moves2 = this.getAllValidMoves(); + let moves2 = this.getAllValidMoves("computer"); for (let j=0; j=0 && i=0 && j