X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FGrand.js;h=7f5fe422fb32c862a3aa70f27c86060d3cf1f42a;hb=6e62b1c7d177585003e923d423025dff280a7525;hp=4271a6936d5415d386e6ecf105c776275a085f1c;hpb=dc0d28e509798eede4f2ca969358400542cdfc7f;p=vchess.git diff --git a/public/javascripts/variants/Grand.js b/public/javascripts/variants/Grand.js index 4271a693..7f5fe422 100644 --- a/public/javascripts/variants/Grand.js +++ b/public/javascripts/variants/Grand.js @@ -18,6 +18,23 @@ class GrandRules extends ChessRules return true; } + static IsGoodEnpassant(enpassant) + { + if (enpassant != "-") + { + const squares = enpassant.split(","); + if (squares.length > 2) + return false; + for (let sq of squares) + { + const ep = V.SquareToCoords(sq); + if (isNaN(ep.x) || !V.OnBoard(ep)) + return false; + } + } + return true; + } + static ParseFen(fen) { const fenParts = fen.split(" "); @@ -218,13 +235,12 @@ class GrandRules extends ChessRules // TODO: some redundant checks if (epsq.x == x+shift && Math.abs(epsq.y - y) == 1) { - let epStep = epsq.y - y; - var enpassantMove = this.getBasicMove([x,y], [x+shift,y+epStep]); + var enpassantMove = this.getBasicMove([x,y], [x+shift,epsq.y]); enpassantMove.vanish.push({ x: x, - y: y+epStep, + y: epsq.y, p: 'p', - c: this.getColor(x,y+epStep) + c: this.getColor(x,epsq.y) }); moves.push(enpassantMove); }