X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=variants%2FBenedict%2Fclass.js;h=dfabddb72cc9a41efa3ef78026d78f43e8340a35;hp=bf15ee66d0e8e263be572a892a296c7e5d50f654;hb=6b9320bb6e42ece7694df32f85aab4d2989f6a13;hpb=ca8a399316d2496c069ea9c6ccf2dc241aeb70ef diff --git a/variants/Benedict/class.js b/variants/Benedict/class.js index bf15ee6..dfabddb 100644 --- a/variants/Benedict/class.js +++ b/variants/Benedict/class.js @@ -44,20 +44,34 @@ export default class BenedictRules extends ChessRules { } postProcessPotentialMoves(moves) { - moves.forEach(m => { + const oppCol = C.GetOppCol(this.turn); + let bMoves = super.postProcessPotentialMoves(moves); + bMoves.forEach(m => { m.flips = []; if (!this.options["cleopatra"] || m.vanish[0].p == 'q') { super.playOnBoard(m); let attacks = super.findDestSquares( [m.end.x, m.end.y], - {attackOnly: true, segments: false}, - ([x, y] => this.canTake([m.end.x, m.end.y], [x, y])) + { + attackOnly: true, + segments: this.options["cylinder"] + }, + ([i1, j1], [i2, j2]) => { + return ( + super.canTake([i1, j1], [i2, j2]) && + (!this.options["zen"] || this.getPiece(i2, j2) == 'k') + ); + } ); if (this.options["zen"]) { const zenAttacks = super.findCapturesOn( [m.end.x, m.end.y], - {segments: false}, - ([x, y] => this.canTake([m.end.x, m.end.y], [x, y])) + { + byCol: [oppCol], + segments: this.options["cylinder"] + }, + ([i1, j1], [i2, j2]) => + this.getPiece(i1, j1) != 'k' && super.canTake([i2, j2], [i1, j1]) ); Array.prototype.push.apply(attacks, zenAttacks); } @@ -65,7 +79,7 @@ export default class BenedictRules extends ChessRules { attacks.forEach(a => m.flips.push({x: a.sq[0], y: a.sq[1]})); } }); - return moves; + return bMoves; } playOnBoard(move) {