Adjustement to highlight checkered checks
authorBenjamin Auder <benjamin.auder@somewhere>
Sun, 18 Nov 2018 12:25:59 +0000 (13:25 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sun, 18 Nov 2018 12:25:59 +0000 (13:25 +0100)
public/javascripts/variants/Checkered.js

index 322d8fc..a481a54 100644 (file)
@@ -36,6 +36,7 @@ class CheckeredRules extends ChessRules
        {
                super.initVariables(fen);
                // Decode last non-capturing checkered move (if any)
+               // TODO: since now we store moves list, this can disappear
                const cmove = fen.split(" ")[4];
                if (cmove != "-")
                {
@@ -353,6 +354,18 @@ class CheckeredRules extends ChessRules
                return res;
        }
 
+       getCheckSquares(move, c)
+       {
+               this.play(move);
+               const kingAttacked = this.isAttacked(this.kingPos[c], this.getOppCol(c))
+                       || this.isAttacked(this.kingPos[c], 'c');
+               let res = kingAttacked
+                       ? [ JSON.parse(JSON.stringify(this.kingPos[c])) ] //need to duplicate!
+                       : [ ];
+               this.undo(move);
+               return res;
+       }
+
        updateVariables(move)
        {
                const piece = this.getPiece(move.start.x,move.start.y);