X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDark.js;h=a7edb916898fd967584e81fc8ce9918ad5f6f87d;hb=3a2a7b5fd3c6bfd0752838094c27e1fb6172d109;hp=6cf3b6787996314abc0ac38c0a0292db7ad50c59;hpb=71ef1664983cd58db3c3bbfdf6cb7c362474e9a5;p=vchess.git diff --git a/client/src/variants/Dark.js b/client/src/variants/Dark.js index 6cf3b678..a7edb916 100644 --- a/client/src/variants/Dark.js +++ b/client/src/variants/Dark.js @@ -63,6 +63,24 @@ export const VariantRules = class DarkRules extends ChessRules { this.enlightened["w"][move.end.x][move.end.y] = true; for (let move of movesBlack) this.enlightened["b"][move.end.x][move.end.y] = true; + // Include en-passant capturing square if any: + let moves = currentTurn == "w" ? movesWhite : movesBlack; + for (let m of moves) { + if ( + m.appear[0].p == V.PAWN && + m.vanish.length == 2 && + m.vanish[1].x != m.end.x + ) { + const psq = m.vanish[1]; + this.enlightened[currentTurn][psq.x][psq.y] = true; + break; + } + } + } + + filterValid(moves) { + // Used in the interface + return moves; } // Has to be redefined to avoid an infinite loop @@ -85,8 +103,8 @@ export const VariantRules = class DarkRules extends ChessRules { return []; } - updateVariables(move) { - super.updateVariables(move); + postPlay(move) { + super.postPlay(move); if (move.vanish.length >= 2 && move.vanish[1].p == V.KING) // We took opponent king (because if castle vanish[1] is a rook) this.kingPos[this.turn] = [-1, -1]; @@ -95,8 +113,8 @@ export const VariantRules = class DarkRules extends ChessRules { this.updateEnlightened(); } - unupdateVariables(move) { - super.unupdateVariables(move); + postUndo(move) { + super.postUndo(move); const c = move.vanish[0].c; const oppCol = V.GetOppCol(c); if (this.kingPos[oppCol][0] < 0)