From 383387d2404756263a52da5c37de30ff71afa37b Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Mon, 3 Dec 2018 15:27:07 +0100 Subject: [PATCH] Fix Atomic when an init rook is taken --- public/javascripts/variants/Atomic.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/public/javascripts/variants/Atomic.js b/public/javascripts/variants/Atomic.js index a6934e73..633e70a9 100644 --- a/public/javascripts/variants/Atomic.js +++ b/public/javascripts/variants/Atomic.js @@ -66,7 +66,8 @@ class AtomicRules extends ChessRules && this.board[move.end.x][move.end.y] != VariantRules.EMPTY) { const oppCol = this.getOppCol(c); - const oppFirstRank = (oppCol == "w" ? 7 : 0); + const firstRank = (c == "w" ? 7 : 0); + const oppFirstRank = 7 - firstRank; // Did we explode our king ? (TODO: remove move earlier) if (Math.abs(this.kingPos[c][0]-move.end.x) <= 1 @@ -75,6 +76,17 @@ class AtomicRules extends ChessRules this.kingPos[c] = [-1,-1]; this.castleFlags[c] = [false,false]; } + else + { + // Now check if our init rook(s) exploded + if (Math.abs(move.end.x-firstRank) <= 1) + { + if (Math.abs(move.end.y-this.INIT_COL_ROOK[oppCol][0]) <= 1) + this.castleFlags[c][0] = false; + if (Math.abs(move.end.y-this.INIT_COL_ROOK[oppCol][1]) <= 1) + this.castleFlags[c][1] = false; + } + } // Did we explode opponent king ? if (Math.abs(this.kingPos[oppCol][0]-move.end.x) <= 1 -- 2.44.0