X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAllmate2.js;h=f4abbe330d82d03ca7cdb764620ea1d7e7beb37c;hp=9ba91ef05ab91b00bcf4ec198a85c99e4afbfa67;hb=d807470f965d4d60a7fe6e1320ac7dfd3f0ea03f;hpb=fd7295e824c0199ad5a1ea40ec4b1f0630a5d806 diff --git a/client/src/variants/Allmate2.js b/client/src/variants/Allmate2.js index 9ba91ef0..f4abbe33 100644 --- a/client/src/variants/Allmate2.js +++ b/client/src/variants/Allmate2.js @@ -1,6 +1,7 @@ import { ChessRules, PiPo, Move } from "@/base_rules"; export class Allmate2Rules extends ChessRules { + static get HasEnpassant() { return false; } @@ -63,14 +64,14 @@ export class Allmate2Rules extends ChessRules { case V.KING: // Do not allow castling to escape from check oppMoves = super.getSlideNJumpMoves( - sq, + [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); @@ -90,6 +91,7 @@ export class Allmate2Rules extends ChessRules { } } } + this.undo(m); // 3) Add mate-captures: Object.values(attacked).forEach(sq => { @@ -100,8 +102,6 @@ export class Allmate2Rules extends ChessRules { p: this.getPiece(sq[0], sq[1]) })); }); - - this.undo(m); }); return moves; @@ -109,7 +109,7 @@ export class Allmate2Rules extends ChessRules { // No "under check" conditions in castling getCastleMoves(sq) { - return super.getCastleMoves(sq, "castleInCheck"); + return super.getCastleMoves(sq, null, "castleInCheck"); } // TODO: allow pieces to "commit suicide"? (Currently yes except king) @@ -185,10 +185,10 @@ export class Allmate2Rules extends ChessRules { this.kingPos[this.turn] = [-1, -1]; // Or maybe a rook? else if (v.p == V.ROOK) { - if (v.y < this.INIT_COL_KING[v.c]) + if (v.y < this.kingPos[v.c][1]) this.castleFlags[v.c][0] = 8; else - // v.y > this.INIT_COL_KING[v.c] + // v.y > this.kingPos[v.c][1] this.castleFlags[v.c][1] = 8; } } @@ -232,4 +232,5 @@ export class Allmate2Rules extends ChessRules { } return notation; } + };