X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FBerolina.js;h=be72e2d500f2ce7524e3e9758cf9bb036231405d;hb=26c1e3bd4d3e9fb7c86e25c0f423bea57b977111;hp=c556f51758c6a8122f1c4818cd363a352097049c;hpb=375ecdd1387e729f85ed114e82253469e4849869;p=vchess.git diff --git a/public/javascripts/variants/Berolina.js b/public/javascripts/variants/Berolina.js index c556f517..be72e2d5 100644 --- a/public/javascripts/variants/Berolina.js +++ b/public/javascripts/variants/Berolina.js @@ -10,23 +10,31 @@ class BerolinaRules extends ChessRules const square = moveOrSquare; if (square == "-") return undefined; - return V.SquareToCoords(square); + // Enemy pawn initial column must be given too: + let res = []; + const epParts = square.split(","); + res.push(V.SquareToCoords(epParts[0])); + res.push(V.ColumnToCoord(epParts[1])); + return res; } // Argument is a move: const move = moveOrSquare; const [sx,ex,sy] = [move.start.x,move.end.x,move.start.y]; if (this.getPiece(sx,sy) == V.PAWN && Math.abs(sx - ex) == 2) { - return { - x: ex, - y: (move.end.y + sy)/2 - }; + return + [ + { + x: (ex + sx)/2, + y: (move.end.y + sy)/2 + }, + move.end.y + ]; } return undefined; //default } - // Special pawn rules: promotions to captured friendly pieces, - // optional on ranks 8-9 and mandatory on rank 10. + // Special pawns movements getPotentialPawnMoves([x,y]) { const color = this.turn; @@ -50,12 +58,13 @@ class BerolinaRules extends ChessRules for (let piece of finalPieces) { moves.push(this.getBasicMove([x,y], [x+shiftX,y+shiftY], - {c:pawnColor,p:piece})); + {c:color,p:piece})); } - if (x == startRank && this.board[x+2*shiftX][y] == V.EMPTY) + if (x == startRank && y+2*shiftY>=0 && y+2*shiftY=0 && x+pawnShift