X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FSwitching.js;fp=public%2Fjavascripts%2Fvariants%2FSwitching.js;h=0000000000000000000000000000000000000000;hb=625022fdcf750f0aff8fcd699f7e9b89730e1d10;hp=04bb110c0489ad3f56ae2abdc9d61aafa8da1fce;hpb=b955c65b942d09d24b5c3bed0d755d4f2f8f71f1;p=vchess.git diff --git a/public/javascripts/variants/Switching.js b/public/javascripts/variants/Switching.js deleted file mode 100644 index 04bb110c..00000000 --- a/public/javascripts/variants/Switching.js +++ /dev/null @@ -1,135 +0,0 @@ -class SwitchingRules extends ChessRules -{ - // Build switch move between squares x1,y1 and x2,y2 - getSwitchMove_s([x1,y1],[x2,y2]) - { - const c = this.getColor(x1,y1); //same as color at square 2 - const p1 = this.getPiece(x1,y1); - const p2 = this.getPiece(x2,y2); - if (p1 == V.KING && p2 == V.ROOK) - return []; //avoid duplicate moves (potential conflict with castle) - let move = new Move({ - appear: [ - new PiPo({x:x2,y:y2,c:c,p:p1}), - new PiPo({x:x1,y:y1,c:c,p:p2}) - ], - vanish: [ - new PiPo({x:x1,y:y1,c:c,p:p1}), - new PiPo({x:x2,y:y2,c:c,p:p2}) - ], - start: {x:x1,y:y1}, - end: {x:x2,y:y2} - }); - // Move completion: promote switched pawns (as in Magnetic) - const lastRank = (c == "w" ? 0 : V.size.x-1); - let moves = []; - if ((p1==V.PAWN && x2==lastRank) || (p2==V.PAWN && x1==lastRank)) - { - const idx = (p1==V.PAWN ? 0 : 1); - move.appear[idx].p = V.ROOK; - moves.push(move); - for (let piece of [V.KNIGHT, V.BISHOP, V.QUEEN]) - { - let cmove = JSON.parse(JSON.stringify(move)); - cmove.appear[idx].p = piece; - moves.push(cmove); - } - if (idx == 1) - { - // Swap moves[i].appear[0] and [1] for moves presentation [TODO...] - moves.forEach(m => { - let tmp = m.appear[0]; - m.appear[0] = m.appear[1]; - m.appear[1] = tmp; - }); - } - } - else //other cases - moves.push(move); - return moves; - } - - getPotentialMovesFrom([x,y], computer) - { - let moves = super.getPotentialMovesFrom([x,y]); - // Add switches: respecting chessboard ordering if "computer" is on - const color = this.turn; - const piece = this.getPiece(x,y); - const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); - const kp = this.kingPos[color]; - const oppCol = V.GetOppCol(color); - for (let step of steps) - { - let [i,j] = [x+step[0],y+step[1]]; - if (!!computer && (i