X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FCheckered.js;h=b9e7223b58b5c70dbe4137e5c30c55babb208f01;hp=f1cf771f948e585ce9a4ce7342058c154b7d69e0;hb=098e8468ae7a52a55850c09f90506f52b8133567;hpb=5bfb09560aa346d132e829a7c63558407bcc8091 diff --git a/public/javascripts/variants/Checkered.js b/public/javascripts/variants/Checkered.js index f1cf771f..b9e7223b 100644 --- a/public/javascripts/variants/Checkered.js +++ b/public/javascripts/variants/Checkered.js @@ -88,7 +88,7 @@ class CheckeredRules extends ChessRules // A capture occured (m.vanish.length == 2) m.appear[0].c = "c"; moves.push(m); - if (m.appear[0].p != m.vanish[1].p //avoid promotions: + if (m.appear[0].p != m.vanish[1].p //avoid promotions (already treated): && (m.vanish[0].p != VariantRules.PAWN || m.end.x != lastRank)) { // Add transformation into captured piece @@ -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() @@ -263,9 +262,11 @@ class CheckeredRules extends ChessRules notation = startColumn + "x" + finalSquare + "=" + move.appear[0].p.toUpperCase(); } else //no capture + { notation = finalSquare; - if (move.appear.length > 0 && piece != move.appear[0].p) //promotion - notation += "=" + move.appear[0].p.toUpperCase(); + if (move.appear.length > 0 && piece != move.appear[0].p) //promotion + notation += "=" + move.appear[0].p.toUpperCase(); + } return notation; }