X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FFusion.js;h=2eb8b2da3db51f0dda3ef63042ab4f0046b7c25d;hb=aeba929c6d4e2388f9b16593d6b11b0d7fa5a16e;hp=a0098ab6d0f8d786133d606837516a7cec133866;hpb=22c591c5862e7ff769ba117f5b6c88d074271352;p=vchess.git 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() {