X-Git-Url: https://git.auder.net/?a=blobdiff_plain;ds=sidebyside;f=public%2Fjavascripts%2Fbase_rules.js;h=b604e7970ffc357c4b05b0217836756485bde3c6;hb=4b5fe3061829e184f9ad86a13d831eda22d95343;hp=9a4ef9120ca8463a9e4e36d4197aead688c94299;hpb=0cfb593616e766e5f5ed693f52452dc3f6efc8fd;p=vchess.git diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 9a4ef912..b604e797 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -629,6 +629,7 @@ class ChessRules return false; } + // Is color c under check after move ? underCheck(move, c) { this.play(move); @@ -637,6 +638,17 @@ class ChessRules return res; } + // On which squares is color c under check (after move) ? + getCheckSquares(move, c) + { + this.play(move); + let res = this.isAttacked(this.kingPos[c], this.getOppCol(c)) + ? [ JSON.parse(JSON.stringify(this.kingPos[c])) ] //need to duplicate! + : [ ]; + this.undo(move); + return res; + } + // Apply a move on board static PlayOnBoard(board, move) {