From e2b216fecd1676fb97c28d5d3c46612c78e04e64 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Mon, 26 Nov 2018 11:48:01 +0100 Subject: [PATCH] Fix end of game for Checkered chess --- public/javascripts/variants/Checkered.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/public/javascripts/variants/Checkered.js b/public/javascripts/variants/Checkered.js index f1cf771f..441cd3c6 100644 --- a/public/javascripts/variants/Checkered.js +++ b/public/javascripts/variants/Checkered.js @@ -190,13 +190,12 @@ class CheckeredRules extends ChessRules checkGameEnd() { const color = this.turn; - if (!this.isAttacked(this.kingPos[color], this.getOppCol(color)) - && !this.isAttacked(this.kingPos[color], 'c')) - { - return "1/2"; - } - // OK, checkmate - return color == "w" ? "0-1" : "1-0"; + this.moves.length++; //artifically change turn, for checkered pawns (TODO) + const res = this.isAttacked(this.kingPos[color], [this.getOppCol(color),'c']) + ? (color == "w" ? "0-1" : "1-0") + : "1/2"; + this.moves.length--; + return res; } evalPosition() -- 2.44.0