From a0f5dbaac2a9c028aa0ca2559d157b34aeafd3c9 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Mon, 26 Nov 2018 00:39:32 +0100 Subject: [PATCH] Attempt to fix Alice chess --- public/javascripts/base_rules.js | 9 +++++++++ public/javascripts/variants/Alice.js | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 0f637c57..85689369 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -698,6 +698,10 @@ class ChessRules play(move, ingame) { + // DEBUG: +// if (!this.states) this.states = []; +// if (!ingame) this.states.push(JSON.stringify(this.board)); + if (!!ingame) move.notation = this.getNotation(move); @@ -715,6 +719,11 @@ class ChessRules this.moves.pop(); this.unupdateVariables(move); this.parseFlags(JSON.parse(move.flags)); + + // DEBUG: +// let state = this.states.pop(); +// if (JSON.stringify(this.board) != state) +// debugger; } ////////////// diff --git a/public/javascripts/variants/Alice.js b/public/javascripts/variants/Alice.js index 76168275..9a7cefa0 100644 --- a/public/javascripts/variants/Alice.js +++ b/public/javascripts/variants/Alice.js @@ -132,7 +132,8 @@ class AliceRules extends ChessRules }); } // Fix en-passant captures - if (m.vanish.length == 2 && this.board[m.end.x][m.end.y] == VariantRules.EMPTY) + if (m.vanish[0].p == VariantRules.PAWN + && m.vanish.length == 2 && this.board[m.end.x][m.end.y] == VariantRules.EMPTY) { m.vanish[1].c = this.getOppCol(this.getColor(x,y)); // In the special case of en-passant, if -- 2.44.0