Some bugs fixes
[xogo.git] / variants / Benedict / class.js
index 88609d7..81fee87 100644 (file)
@@ -6,7 +6,6 @@ export default class BenedictRules extends ChessRules {
   static get Options() {
     return {
       select: C.Options.select,
-      check: [],
       styles: [
         "balance",
         "cylinder",
@@ -22,6 +21,10 @@ export default class BenedictRules extends ChessRules {
     return false;
   }
 
+  canTake() {
+    return false;
+  }
+
   // Find potential captures from a square
   // follow steps from x,y until something is met.
   findAttacks([x, y]) {
@@ -32,13 +35,13 @@ export default class BenedictRules extends ChessRules {
     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 &&
@@ -52,20 +55,12 @@ export default class BenedictRules extends ChessRules {
   }
 
   postProcessPotentialMoves(moves) {
-    if (moves.length == 0)
-      return moves;
-    const color = this.getColor(moves[0].start.x, moves[0].start.y);
-    const oppCol = C.GetOppCol(color);
-    // Remove captures (NOTE: altering canTake has side effects,
-    // Benedict is still based on captures even if they are forbidden):
-    moves = super.postProcessPotentialMoves(moves)
-                 .filter(m => this.board[m.end.x][m.end.y] == "");
     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], true).forEach(c => {
+        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));
@@ -115,7 +110,7 @@ export default class BenedictRules extends ChessRules {
   }
 
   // A king under (regular) check flips color, and the game is over.
-  underCheck(square, color) {
+  underCheck() {
     return false;
   }