X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=variants%2FBenedict%2Fclass.js;h=2bc60e739bb624095d1285bee6a94ef15d84c635;hp=81fee87e5eb8e0e841ca84ca632ca61b30ef1e39;hb=e2be4b04faeac3fca5b292499bb70b98542e45ce;hpb=2159c2391f765c55ad79d5e05a62ecc6586b8522 diff --git a/variants/Benedict/class.js b/variants/Benedict/class.js index 81fee87..2bc60e7 100644 --- a/variants/Benedict/class.js +++ b/variants/Benedict/class.js @@ -6,6 +6,14 @@ export default class BenedictRules extends ChessRules { static get Options() { return { select: C.Options.select, + input: [ + { + label: "Cleopatra", + variable: "cleopatra", + type: "checkbox", + defaut: false + } + ], styles: [ "balance", "cylinder", @@ -25,6 +33,24 @@ export default class BenedictRules extends ChessRules { return false; } + pieces(color, x, y) { + if (!this.options["cleopatra"]) + return super.pieces(color, x, y); + return Object.assign({}, super.pieces(color, x, y), { + 'q': { + "class": "cleopatra", + moves: [ + { + steps: [ + [0, 1], [0, -1], [1, 0], [-1, 0], + [1, 1], [1, -1], [-1, 1], [-1, -1] + ] + } + ] + }, + }); + } + // Find potential captures from a square // follow steps from x,y until something is met. findAttacks([x, y]) { @@ -56,20 +82,22 @@ export default class BenedictRules extends ChessRules { postProcessPotentialMoves(moves) { moves.forEach(m => { - super.playOnBoard(m); - let attacks = this.findAttacks([m.end.x, m.end.y]) - if (this.options["zen"]) { - let endSquares = {}; - super.findCapturesOn([m.end.x, m.end.y], {zen: true}).forEach(c => { - endSquares[C.CoordsToSquare(c.end)] = true; + m.flips = []; + if (!this.options["cleopatra"] || m.vanish[0].p == 'q') { + super.playOnBoard(m); + let attacks = this.findAttacks([m.end.x, m.end.y]) + if (this.options["zen"]) { + let endSquares = {}; + super.findCapturesOn([m.end.x, m.end.y], {zen: true}).forEach(c => { + endSquares[C.CoordsToSquare(c.end)] = true; + }); + Array.prototype.push.apply(attacks, Object.keys(endSquares)); + } + super.undoOnBoard(m); + attacks.map(C.SquareToCoords).forEach(a => { + m.flips.push({x: a.x, y: a.y}); }); - Array.prototype.push.apply(attacks, Object.keys(endSquares)); } - super.undoOnBoard(m); - m.flips = []; - attacks.map(C.SquareToCoords).forEach(a => { - m.flips.push({x: a.x, y: a.y}); - }); }); return moves; }