Fix end of game for Checkered chess
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 26 Nov 2018 10:48:01 +0000 (11:48 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 26 Nov 2018 10:48:01 +0000 (11:48 +0100)
public/javascripts/variants/Checkered.js

index f1cf771..441cd3c 100644 (file)
@@ -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()