First draft of Magnetic chess
[vchess.git] / public / javascripts / variants / Atomic.js
index d86ed0e..f32e21d 100644 (file)
@@ -134,13 +134,14 @@ class AtomicRules extends ChessRules
        getCheckSquares(move)
        {
                const c = this.getOppCol(this.turn);
-               const saveKingPos = this.kingPos[c]; //king might explode
+               // King might explode:
+               const saveKingPos = JSON.parse(JSON.stringify(this.kingPos[c]));
                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] ]
+                       res = [ JSON.parse(JSON.stringify(this.kingPos[c])) ]
                this.undo(move);
                return res;
        }