X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FBenedict.js;h=5584fb870aa6f2239248d580fa0f2e45945ca1f3;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=fbc4b488a1753a298f95f19d151eab1fb19c3a85;hpb=32f6285ee325a14286562a53baefc647201df2af;p=vchess.git diff --git a/client/src/variants/Benedict.js b/client/src/variants/Benedict.js index fbc4b488..5584fb87 100644 --- a/client/src/variants/Benedict.js +++ b/client/src/variants/Benedict.js @@ -1,6 +1,7 @@ import { ChessRules, PiPo, Move } from "@/base_rules"; export class BenedictRules extends ChessRules { + static get HasEnpassant() { return false; } @@ -13,22 +14,8 @@ export class BenedictRules extends ChessRules { ); } - // TODO(?): some duplicated code in 2 next functions - getSlideNJumpMoves([x, y], steps, oneStep) { - let moves = []; - outerLoop: for (let loop = 0; loop < steps.length; loop++) { - const step = steps[loop]; - let i = x + step[0]; - let j = y + step[1]; - while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) { - moves.push(this.getBasicMove([x, y], [i, j])); - if (oneStep) continue outerLoop; - i += step[0]; - j += step[1]; - } - // No capture check: handled elsewhere (next method) - } - return moves; + canTake() { + return false; } // Find possible captures from a square @@ -135,13 +122,10 @@ export class BenedictRules extends ChessRules { // Stop at the first move found atLeastOneMove() { const color = this.turn; - const oppCol = V.GetOppCol(color); for (let i = 0; i < V.size.x; i++) { for (let j = 0; j < V.size.y; j++) { - if (this.board[i][j] != V.EMPTY && this.getColor(i, j) != oppCol) { - const moves = this.getPotentialMovesFrom([i, j]); - if (moves.length > 0) - return true; + if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == color) { + if (this.getPotentialMovesFrom([i, j]).length > 0) return true; } } } @@ -154,8 +138,7 @@ export class BenedictRules extends ChessRules { const kp = this.kingPos[color]; if (this.getColor(kp[0], kp[1]) != color) return color == "w" ? "0-1" : "1-0"; - if (this.atLeastOneMove()) - return "*"; + if (this.atLeastOneMove()) return "*"; // Stalemate: return "1/2"; } @@ -170,4 +153,5 @@ export class BenedictRules extends ChessRules { }; return super.getNotation(basicMove); } + };