X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FBenedict%2Fclass.js;h=7c77e8bd40109434370077af84ae7d97fd23f74f;hb=c9ab034035a3cac65e4ac9f48a946ecef5ed111e;hp=e08a79ca48aadfa096f92484fcf4324f17f38192;hpb=cc2c71836442d7495ec570f8f78c006ea60852e0;p=xogo.git diff --git a/variants/Benedict/class.js b/variants/Benedict/class.js index e08a79c..7c77e8b 100644 --- a/variants/Benedict/class.js +++ b/variants/Benedict/class.js @@ -7,14 +7,14 @@ export default class BenedictRules extends ChessRules { return { select: C.Options.select, check: [], - styles: ( - C.Options.styles.filter(s => { - return ( - ["balance", "cylinder", "dark", "doublemove", "progressive", "zen"] - .includes(s) - ); - }) - ) + styles: [ + "balance", + "cylinder", + "dark", + "doublemove", + "progressive", + "zen" + ] }; } @@ -22,14 +22,6 @@ export default class BenedictRules extends ChessRules { return false; } - get pawnSpecs() { - return Object.assign( - {}, - super.pawnSpecs, - { canCapture: false } - ); - } - canTake() { return false; } @@ -40,18 +32,20 @@ export default class BenedictRules extends ChessRules { const [color, piece] = [this.getColor(x, y), this.getPiece(x, y)]; const oppCol = C.GetOppCol(color); let squares = {}; - const specs = this.pieces(color)[piece]; - const steps = specs.attack || specs.steps; - outerLoop: for (let step of steps) { - let [i, j] = [x + step[0], this.computeY(y + step[1])]; - let nbSteps = 1; - while (this.onBoard(i, j) && this.board[i][j] == "") { - if (specs.range <= nbSteps++) continue outerLoop; - i += step[0]; - j = this.computeY(j + step[1]); + const specs = this.pieces(color, x, y)[piece]; + const attacks = specs.attack || specs.moves; + for (let a of attacks) { + outerLoop: for (let step of a.steps) { + let [i, j] = [x + step[0], this.computeY(y + step[1])]; + let nbSteps = 1; + while (this.onBoard(i, j) && this.board[i][j] == "") { + if (a.range <= nbSteps++) continue outerLoop; + i += step[0]; + j = this.computeY(j + step[1]); + } + if (this.onBoard(i, j) && this.getColor(i, j) == oppCol) + squares[C.CoordsToSquare({x: i, y: j})] = true; } - if (this.onBoard(i, j) && this.getColor(i, j) == oppCol) - squares[C.CoordsToSquare({x: i, y: j})] = true; } return Object.keys(squares); }