Fix incheck by pawns for checkered
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 19 Nov 2018 10:08:25 +0000 (11:08 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 19 Nov 2018 10:08:25 +0000 (11:08 +0100)
TODO
public/javascripts/base_rules.js
public/javascripts/components/game.js
public/javascripts/variants/Checkered.js

diff --git a/TODO b/TODO
index aeb537d..e9d0cc5 100644 (file)
--- 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)
 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?)
index 7f4052a..11de147 100644 (file)
@@ -712,7 +712,7 @@ class ChessRules
                VariantRules.PlayOnBoard(this.board, move);
        }
 
                VariantRules.PlayOnBoard(this.board, move);
        }
 
-       undo(move, ingame)
+       undo(move)
        {
                VariantRules.UndoOnBoard(this.board, move);
                this.epSquares.pop();
        {
                VariantRules.UndoOnBoard(this.board, move);
                this.epSquares.pop();
index bd3a187..ab86057 100644 (file)
@@ -549,7 +549,7 @@ Vue.component('my-game', {
                                {
                                        const oppCol = this.vr.turn;
                                        const lastMove = moves[moves.length-1];
                                {
                                        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");
                                }
                                        this.incheck = this.vr.getCheckSquares(lastMove, oppCol);
                                        this.vr.play(lastMove, "ingame");
                                }
index 3626822..a74143b 100644 (file)
@@ -338,11 +338,13 @@ class CheckeredRules extends ChessRules
        getCheckSquares(move, c)
        {
                this.play(move);
        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!
                        : [ ];
                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;
        }
                this.undo(move);
                return res;
        }