From 818ede16c09c2f5650d7a6b7b5ea42d6dd1a0c30 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Mon, 19 Nov 2018 18:53:37 +0100 Subject: [PATCH] Add a few questions... --- public/javascripts/base_rules.js | 3 +-- public/javascripts/variants/Antiking.js | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 99574b45..16304953 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -268,8 +268,7 @@ class ChessRules { var i = x + step[0]; var j = y + step[1]; - while (i>=0 && i<sizeX && j>=0 && j<sizeY - && this.board[i][j] == VariantRules.EMPTY) + while (i>=0 && i<sizeX && j>=0 && j<sizeY && this.board[i][j] == VariantRules.EMPTY) { moves.push(this.getBasicMove(x, y, i, j)); if (oneStep !== undefined) diff --git a/public/javascripts/variants/Antiking.js b/public/javascripts/variants/Antiking.js index ddfd9677..ac25c736 100644 --- a/public/javascripts/variants/Antiking.js +++ b/public/javascripts/variants/Antiking.js @@ -8,10 +8,10 @@ class AntikingRules static get ANTIKING() { return 'a'; } - // TODO: more subtle than that, require changing args: wp, bk and not just colors - canTake(color1, color2) + canTake(color1, color2, [x,y]) { - return color1 != color2; + const piece = this.getPiece(x,y); + return (piece != "a" && color1 != color2) || (piece == "a" && color1 == color2); } getPotentialMovesFrom([x,y]) @@ -26,6 +26,8 @@ class AntikingRules } } +// TODO: generaliser (à moindre coût) base_rules ? Ou spécialiser variantes ? + getPotentialAntikingMoves(x, y, c) { // TODO -- 2.44.0