X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FBerolina.js;h=be72e2d500f2ce7524e3e9758cf9bb036231405d;hb=26c1e3bd4d3e9fb7c86e25c0f423bea57b977111;hp=dc9e25740f622be88c720a4ec53c4a6cc1eff395;hpb=f6dbe8e31a3260487664f1e0b50710b3f3efaf5f;p=vchess.git diff --git a/public/javascripts/variants/Berolina.js b/public/javascripts/variants/Berolina.js index dc9e2574..be72e2d5 100644 --- a/public/javascripts/variants/Berolina.js +++ b/public/javascripts/variants/Berolina.js @@ -10,17 +10,26 @@ 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 + sx)/2, - y: (move.end.y + sy)/2 - }; + return + [ + { + x: (ex + sx)/2, + y: (move.end.y + sy)/2 + }, + move.end.y + ]; } return undefined; //default } @@ -47,7 +56,10 @@ class BerolinaRules extends ChessRules if (this.board[x+shiftX][y+shiftY] == V.EMPTY) { for (let piece of finalPieces) - moves.push(this.getBasicMove([x,y], [x+shiftX,y+shiftY], {c:color,p:piece})); + { + moves.push(this.getBasicMove([x,y], [x+shiftX,y+shiftY], + {c:color,p:piece})); + } if (x == startRank && y+2*shiftY>=0 && y+2*shiftY=0 && x+pawnShift