X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FSwitching.js;fp=public%2Fjavascripts%2Fvariants%2FSwitching.js;h=ee84e4ca6385e92f1db646b7224a64634fc4b1ed;hb=0b7d99ecbb5dedc02cd96c457b5fc2962db9b297;hp=cedba3dbdb2e15c8dbc869329355d2ad6032bd8d;hpb=18f9c763d17110b75489f721bf155bb88ac6c5c1;p=vchess.git diff --git a/public/javascripts/variants/Switching.js b/public/javascripts/variants/Switching.js index cedba3db..ee84e4ca 100644 --- a/public/javascripts/variants/Switching.js +++ b/public/javascripts/variants/Switching.js @@ -6,7 +6,6 @@ class SwitchingRules extends ChessRules const c = this.getColor(x1,y1); //same as color at square 2 const p1 = this.getPiece(x1,y1); const p2 = this.getPiece(x2,y2); - const V = VariantRules; if (p1 == V.KING && p2 == V.ROOK) return []; //avoid duplicate moves (potential conflict with castle) let move = new Move({ @@ -22,8 +21,7 @@ class SwitchingRules extends ChessRules end: {x:x2,y:y2} }); // Move completion: promote switched pawns (as in Magnetic) - const sizeX = VariantRules.size[0]; - const lastRank = (c == "w" ? 0 : sizeX-1); + const lastRank = (c == "w" ? 0 : V.size.x-1); let moves = []; if ((p1==V.PAWN && x2==lastRank) || (p2==V.PAWN && x1==lastRank)) { @@ -55,10 +53,8 @@ class SwitchingRules extends ChessRules { let moves = super.getPotentialMovesFrom([x,y]); // Add switches: respecting chessboard ordering if "computer" is on - const V = VariantRules; const color = this.turn; const piece = this.getPiece(x,y); - const [sizeX,sizeY] = V.size; const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); const kp = this.kingPos[color]; const oppCol = this.getOppCol(color); @@ -67,7 +63,7 @@ class SwitchingRules extends ChessRules let [i,j] = [x+step[0],y+step[1]]; if (!!computer && (i=0 && i=0 && j