From: Benjamin Auder Date: Mon, 22 Feb 2021 14:27:16 +0000 (+0100) Subject: Fix king tracking in Fusion variant X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/images/pieces/scripts/R.css?a=commitdiff_plain;h=7097b7363df7d1d632a4c94c1f3ba8a3431d62d0;p=vchess.git Fix king tracking in Fusion variant --- diff --git a/client/src/variants/Fusion.js b/client/src/variants/Fusion.js index a0098ab6..2eb8b2da 100644 --- a/client/src/variants/Fusion.js +++ b/client/src/variants/Fusion.js @@ -399,16 +399,17 @@ export class FusionRules extends ChessRules { postPlay(move) { const c = V.GetOppCol(this.turn); - const piece = move.appear[0].p; - if ([V.KING, V.KN, V.KB, V.KR].includes(piece)) - this.kingPos[c] = [move.appear[0].x, move.appear[0].y]; - this.updateCastleFlags(move, piece); + move.kingMove = ( + [V.KING, V.KN, V.KB, V.KR].includes(move.appear[0].p) && + [V.KING, V.KN, V.KB, V.KR].includes(move.vanish[0].p) + ); + if (move.kingMove) this.kingPos[c] = [move.appear[0].x, move.appear[0].y]; + this.updateCastleFlags(move, move.appear[0].p); } postUndo(move) { const c = this.getColor(move.start.x, move.start.y); - if ([V.KING, V.KN, V.KB, V.KR].includes(move.appear[0].p)) - this.kingPos[c] = [move.start.x, move.start.y]; + if (!!move.kingMove) this.kingPos[c] = [move.start.x, move.start.y]; } static get VALUES() {