X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FBalaklava.js;h=835aa965dc4c09a3f8f8eb3056076a56c62b03a9;hb=7e8a7ea1cb66adb4a987badfb0a3c2f99a21bd0a;hp=3a04e1d0669bffe998970d286df6150957828f70;hpb=a0224b03c91dd83a6e133378b85591a1a64e427b;p=vchess.git diff --git a/client/src/variants/Balaklava.js b/client/src/variants/Balaklava.js index 3a04e1d0..835aa965 100644 --- a/client/src/variants/Balaklava.js +++ b/client/src/variants/Balaklava.js @@ -1,6 +1,7 @@ import { ChessRules } from "@/base_rules"; export class BalaklavaRules extends ChessRules { + static get PawnSpecs() { return Object.assign( {}, @@ -61,8 +62,19 @@ export class BalaklavaRules extends ChessRules { : super.getPotentialMovesFrom([x, y]); if (piece != V.KING) { // Add non-capturing knight movements - const lastRank = (this.turn == 'w' ? 0 : 7); + const color = this.turn; + const lastRank = (color == 'w' ? 0 : 7); V.steps[V.KNIGHT].forEach(step => { + // Pawns cannot go backward: + if ( + piece == V.PAWN && + ( + (color == 'w' && step[0] > 0) || + (color == 'b' && step[0] < 0) + ) + ) { + return; + } const [i, j] = [x + step[0], y + step[1]]; if ( V.OnBoard(i, j) && @@ -106,4 +118,5 @@ export class BalaklavaRules extends ChessRules { ChessRules.VALUES ); } + };