X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAtomic1.js;h=a5198d6951b97bed322e19ee45e43243b75d582f;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=27769a7e372aa4a44acbb004373f6efce5a5ee62;hpb=0fb43db7c2858201e8410670b90f95ad8b138964;p=vchess.git diff --git a/client/src/variants/Atomic1.js b/client/src/variants/Atomic1.js index 27769a7e..a5198d69 100644 --- a/client/src/variants/Atomic1.js +++ b/client/src/variants/Atomic1.js @@ -5,6 +5,17 @@ export class Atomic1Rules extends ChessRules { getPotentialMovesFrom([x, y]) { let moves = super.getPotentialMovesFrom([x, y]); + if (this.getPiece(x, y) == V.PAWN) { + // Promotions by captures can be reduced to only one deterministic + // move (because of the explosion). + moves = moves.filter(m => { + return ( + m.vanish.length == 1 || + [V.PAWN, V.QUEEN].includes(m.appear[0].p) + ); + }); + } + // Handle explosions moves.forEach(m => { // NOTE: if vanish.length==2 and appear.length==2, this is castle @@ -91,7 +102,8 @@ export class Atomic1Rules extends ChessRules { ) { this.kingPos[c] = [-1, -1]; this.castleFlags[c] = [8, 8]; - } else { + } + else { // Now check if init rook(s) exploded if (Math.abs(move.end.x - firstRank[c]) <= 1) { if (Math.abs(move.end.y - this.castleFlags[c][0]) <= 1)