Add a few questions...
[vchess.git] / public / javascripts / variants / Atomic.js
index b7c7504..0fd7647 100644 (file)
@@ -96,10 +96,9 @@ class AtomicRules extends ChessRules
                }
        }
 
-       undo(move)
+       unupdateVariables(move)
        {
-               super.undo(move);
-
+               super.unupdateVariables(move);
                const c = this.getColor(move.start.x,move.start.y);
                const oppCol = this.getOppCol(c);
                if ([this.kingPos[c][0],this.kingPos[oppCol][0]].some(e => { return e < 0; }))
@@ -131,6 +130,19 @@ class AtomicRules extends ChessRules
                return res;
        }
 
+       getCheckSquares(move, c)
+       {
+               const saveKingPos = this.kingPos[c]; //king might explode
+               this.play(move);
+               let res = [ ];
+               if (this.kingPos[c][0] < 0)
+                       res = [saveKingPos];
+               else if (this.isAttacked(this.kingPos[c], this.getOppCol(c)))
+                       res = [ this.kingPos[c] ]
+               this.undo(move);
+               return res;
+       }
+
        checkGameEnd(color)
        {
                const kp = this.kingPos[color];