X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FSwitching.js;h=8cb3141dd93729a80f530bcbbbbfd1d5cf370e47;hb=HEAD;hp=229c7b35b30512b564104215d43bcb87bf6e38e6;hpb=964eda04ad6415b4ec95387ea08b63a3d0f0f9cc;p=vchess.git diff --git a/client/src/variants/Switching.js b/client/src/variants/Switching.js index 229c7b35..8cb3141d 100644 --- a/client/src/variants/Switching.js +++ b/client/src/variants/Switching.js @@ -1,6 +1,7 @@ import { ChessRules, Move, PiPo } from "@/base_rules"; export 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 @@ -76,6 +77,7 @@ export class SwitchingRules extends ChessRules { this.castleFlags[a.c] = [V.size.y, V.size.y]; } }); + const firstRank = (move.vanish[0].c == 'w' ? 7 : 0); for (let coords of [move.start, move.end]) { if ( Object.keys(firstRank).includes(coords.x) && @@ -106,7 +108,7 @@ export class SwitchingRules extends ChessRules { return super.getAllPotentialMoves().filter(m => { return ( m.appear.length == 1 || - (move.appear[0].p == V.KING && move.appear[1].p == V.ROOK) || + (m.appear[0].p == V.KING && m.appear[1].p == V.ROOK) || (m.appear[1].x <= m.vanish[1].x && m.appear[1].y <= m.vanish[1].y) ); }); @@ -122,4 +124,5 @@ export class SwitchingRules extends ChessRules { // Switch return "S" + V.CoordsToSquare(move.start) + V.CoordsToSquare(move.end); } -} + +};