From: Benjamin Auder Date: Sun, 18 Nov 2018 12:25:59 +0000 (+0100) Subject: Adjustement to highlight checkered checks X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/user/doc/pieces/cr.svg?a=commitdiff_plain;h=bd6ff57c4533799ab853fa95a53d68deaa4c500d;p=vchess.git Adjustement to highlight checkered checks --- diff --git a/public/javascripts/variants/Checkered.js b/public/javascripts/variants/Checkered.js index 322d8fc0..a481a54f 100644 --- a/public/javascripts/variants/Checkered.js +++ b/public/javascripts/variants/Checkered.js @@ -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);