X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRampage.js;h=12a61a18dcfd21907983baf9362c4e834ec9505a;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=2fe96db65d3e534b4b472cf8f80d9dbf2bea0ba9;hpb=35ff9d1b79c050a7b8304bd725221aaee57f7209;p=vchess.git diff --git a/client/src/variants/Rampage.js b/client/src/variants/Rampage.js index 2fe96db6..12a61a18 100644 --- a/client/src/variants/Rampage.js +++ b/client/src/variants/Rampage.js @@ -1,6 +1,7 @@ import { ChessRules } from "@/base_rules"; export class RampageRules extends ChessRules { + // Sum white pieces attacking a square, and remove black pieces count. sumAttacks([x, y]) { const getSign = (color) => { @@ -62,13 +63,19 @@ export class RampageRules extends ChessRules { return moves; // Remember current final squares to not add moves twice: const destinations = {}; + const lastRank = (color == 'w' ? 0 : 7); + const piece = this.getPiece(x, y); moves.forEach(m => destinations[m.end.x + "_" + m.end.y] = true); for (let i=0; i<8; i++) { for (let j=0; j<8; j++) { if (this.board[i][j] == V.EMPTY && !destinations[i + "_" + j]) { const sa = this.sumAttacks([i, j]); - if ((color == 'w' && sa > 0) || (color == 'b' && sa < 0)) + if ( + ((color == 'w' && sa > 0) || (color == 'b' && sa < 0)) && + (piece != V.PAWN || i != lastRank) + ) { moves.push(this.getBasicMove([x, y], [i, j])); + } } } } @@ -78,4 +85,5 @@ export class RampageRules extends ChessRules { static get SEARCH_DEPTH() { return 1; } + };