From: Benjamin Auder Date: Mon, 26 Nov 2018 10:48:01 +0000 (+0100) Subject: Fix end of game for Checkered chess X-Git-Url: https://git.auder.net/doc/html/vendor/img/css/index.css?a=commitdiff_plain;h=e2b216fecd1676fb97c28d5d3c46612c78e04e64;p=vchess.git Fix end of game for Checkered chess --- 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()