X-Git-Url: https://git.auder.net/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fvariants%2FDynamo.js;fp=client%2Fsrc%2Fvariants%2FDynamo.js;h=7403d061f2889e746aab8798bd147bfb321a214e;hb=05d37cc77857fc683e431820aff39db24bd86835;hp=9c0d08013c437205a872b3f5491eb37dcefe4fc2;hpb=efc6e836bba614593c119819b99b9599456d503a;p=vchess.git diff --git a/client/src/variants/Dynamo.js b/client/src/variants/Dynamo.js index 9c0d0801..7403d061 100644 --- a/client/src/variants/Dynamo.js +++ b/client/src/variants/Dynamo.js @@ -208,6 +208,22 @@ export class DynamoRules extends ChessRules { return false; } + isAprioriValidVertical([x1, y1], x2) { + const piece = this.getPiece(x1, y1); + const deltaX = Math.abs(x1 - x2); + const startRank = (this.getColor(x1, y1) == 'w' ? 6 : 1); + return ( + [V.QUEEN, V.ROOK].includes(piece) || + ( + [V.KING, V.PAWN].includes(piece) && + ( + deltaX == 1 || + (deltaX == 2 && piece == V.PAWN && x1 == startRank) + ) + ) + ); + } + // NOTE: for pushes, play the pushed piece first. // for pulls: play the piece doing the action first // NOTE: to push a piece out of the board, make it slide until its king @@ -337,6 +353,15 @@ export class DynamoRules extends ChessRules { [fm.start.x - x, fm.start.y - y]); // Normalized directions should match if (dir[0] == dirM[0] && dir[1] == dirM[1]) { + // If first move is a pawn move, only a queen, rook, or maybe king or + // pawn can follow (need vertical movement option). + if ( + fm.vanish[0].p == V.PAWN && + fm.vanish[0].c == color && + !this.isAprioriValidVertical([x, y], fm.start.x) + ) { + return []; + } // And nothing should stand between [x, y] and the square fm.start let [i, j] = [x + dir[0], y + dir[1]]; while (