X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAllmate2.js;h=259faa74e628a672765e8b0e03a758b04cdcee50;hp=424ff61bb73e394f79e0b852643507d6ef99a738;hb=6f10b38369cc92057a25cc0150727aeeeaa6f1d1;hpb=a68362420a3a92099dfaacea10f6cbd579161183 diff --git a/client/src/variants/Allmate2.js b/client/src/variants/Allmate2.js index 424ff61b..259faa74 100644 --- a/client/src/variants/Allmate2.js +++ b/client/src/variants/Allmate2.js @@ -61,11 +61,16 @@ export class Allmate2Rules extends ChessRules { oppMoves = this.getPotentialQueenMoves([i, j]); break; case V.KING: - oppMoves = this.getPotentialKingMoves([i, j]); + // Do not allow castling to escape from check + oppMoves = super.getSlideNJumpMoves( + [i, j], + V.steps[V.ROOK].concat(V.steps[V.BISHOP]), + "oneStep" + ); break; } for (let om of oppMoves) { - if (om.vanish.length == 2 && om.appear.length == 1) + if (om.vanish.length == 2) // Skip captures: forbidden in this mode continue; V.PlayOnBoard(this.board, om); @@ -85,6 +90,7 @@ export class Allmate2Rules extends ChessRules { } } } + this.undo(m); // 3) Add mate-captures: Object.values(attacked).forEach(sq => { @@ -95,8 +101,6 @@ export class Allmate2Rules extends ChessRules { p: this.getPiece(sq[0], sq[1]) })); }); - - this.undo(m); }); return moves; @@ -207,8 +211,7 @@ export class Allmate2Rules extends ChessRules { if (kp[0] < 0) // King disappeared return color == "w" ? "0-1" : "1-0"; - if (this.atLeastOneMove()) - return "*"; + if (this.atLeastOneMove()) return "*"; // Kings still there, no moves: return "1/2"; }