X-Git-Url: https://git.auder.net/assets/icon_infos.svg?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FBerolina.js;h=4cdbb88b97bcc1e8f21e69a00da95ab45caaad98;hb=8d1fcc37a933554e13bc996b5611f8307a4701e8;hp=03b1b3b275a934a39e4b2e1476ea493e12dc9637;hpb=6808d7a16ec1e761c6a2dffec2281c96953e4d89;p=vchess.git diff --git a/client/src/variants/Berolina.js b/client/src/variants/Berolina.js index 03b1b3b2..4cdbb88b 100644 --- a/client/src/variants/Berolina.js +++ b/client/src/variants/Berolina.js @@ -23,12 +23,36 @@ export const VariantRules = class BerolinaRules extends ChessRules { x: (ex + sx) / 2, y: (move.end.y + sy) / 2 }, + // The arrival column must be remembered, because + // potentially two pawns could be candidates to be captured: + // one on our left, and one on our right. move.end.y ]; } return undefined; //default } + static IsGoodEnpassant(enpassant) { + if (enpassant != "-") { + const epParts = enpassant.split(","); + const epSq = V.SquareToCoords(epParts[0]); + if (isNaN(epSq.x) || isNaN(epSq.y) || !V.OnBoard(epSq)) return false; + const arrCol = V.ColumnToCoord(epParts[1]); + if (isNaN(arrCol) || arrCol < 0 || arrCol >= V.size.y) return false; + } + return true; + } + + getEnpassantFen() { + const L = this.epSquares.length; + if (!this.epSquares[L - 1]) return "-"; //no en-passant + return ( + V.CoordsToSquare(this.epSquares[L - 1][0]) + + "," + + V.CoordToColumn(this.epSquares[L - 1][1]) + ); + } + // Special pawns movements getPotentialPawnMoves([x, y]) { const color = this.turn; @@ -81,8 +105,7 @@ export const VariantRules = class BerolinaRules extends ChessRules { if ( !!epSquare && epSquare[0].x == x + shiftX && - epSquare[0].y == y && - Math.abs(epSquare[1] - y) == 1 + epSquare[0].y == y ) { let enpassantMove = this.getBasicMove([x, y], [x + shiftX, y]); enpassantMove.vanish.push({