From: Benjamin Auder Date: Mon, 19 Nov 2018 10:08:25 +0000 (+0100) Subject: Fix incheck by pawns for checkered X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/images/assets/doc/pieces/cn.svg?a=commitdiff_plain;h=cd4cad0468612cf00c6e6879554e3cee58d4b1f9;p=vchess.git Fix incheck by pawns for checkered --- diff --git a/TODO b/TODO index aeb537dd..e9d0cc5a 100644 --- a/TODO +++ b/TODO @@ -3,4 +3,3 @@ Tooltip text should fade (even when mouse stay on it, especially for small scree Checkered stage 2: switch button at reserve position (or on top). Mode expert: game.js, button on top (with online indicator) Turn indicator on top too (black or white) -incheck by checkered pawns: not marked (because of turn changed?) diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 7f4052ac..11de1471 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -712,7 +712,7 @@ class ChessRules VariantRules.PlayOnBoard(this.board, move); } - undo(move, ingame) + undo(move) { VariantRules.UndoOnBoard(this.board, move); this.epSquares.pop(); diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index bd3a1878..ab860572 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -549,7 +549,7 @@ Vue.component('my-game', { { const oppCol = this.vr.turn; const lastMove = moves[moves.length-1]; - this.vr.undo(lastMove, "ingame"); + this.vr.undo(lastMove); this.incheck = this.vr.getCheckSquares(lastMove, oppCol); this.vr.play(lastMove, "ingame"); } diff --git a/public/javascripts/variants/Checkered.js b/public/javascripts/variants/Checkered.js index 3626822b..a74143b9 100644 --- a/public/javascripts/variants/Checkered.js +++ b/public/javascripts/variants/Checkered.js @@ -338,11 +338,13 @@ class CheckeredRules extends ChessRules getCheckSquares(move, c) { this.play(move); + this.moves.push(move); //artifically change turn, for checkered pawns (TODO) 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.moves.pop(); this.undo(move); return res; }