static get Options() {
return {
select: C.Options.select,
- check: [],
+ input: [
+ {
+ label: "Cleopatra",
+ variable: "cleopatra",
+ type: "checkbox",
+ defaut: false
+ }
+ ],
styles: [
"balance",
"cylinder",
return false;
}
+ pieces(color, x, y) {
+ if (!this.options["cleopatra"])
+ return super.pieces(color, x, y);
+ const allSpecs = super.pieces(color, x, y);
+ return Object.assign({},
+ allSpecs,
+ {'q': Object.assign({}, allSpecs['q'], {"class": "cleopatra"})}
+ );
+ }
+
// Find potential captures from a square
// follow steps from x,y until something is met.
findAttacks([x, y]) {
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 [i, j] = [x + step[0], this.getY(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]);
+ j = this.getY(j + step[1]);
}
if (
this.onBoard(i, j) && this.getColor(i, j) == oppCol &&
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;
}