X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FSwap.js;h=9c3407b7351cd91e4137a20506d4921f84f07ff6;hb=de0706e6db65fa857a314a8d982f006d35eebb94;hp=bf4e78715c000b9b0992733db0859edab0c89efb;hpb=964eda04ad6415b4ec95387ea08b63a3d0f0f9cc;p=vchess.git diff --git a/client/src/variants/Swap.js b/client/src/variants/Swap.js index bf4e7871..9c3407b7 100644 --- a/client/src/variants/Swap.js +++ b/client/src/variants/Swap.js @@ -2,6 +2,7 @@ import { ChessRules, PiPo } from "@/base_rules"; import { randInt } from "@/utils/alea"; export class SwapRules extends ChessRules { + setOtherVariables(fen) { super.setOtherVariables(fen); // Local stack of swaps @@ -34,7 +35,7 @@ export class SwapRules extends ChessRules { } getPPpath(m) { - if (m.vanish.length == 1) return super.getPPpath(m); + if (m.appear.length == 1) return super.getPPpath(m); // Swap promotion: return m.appear[1].c + m.appear[1].p; } @@ -71,7 +72,7 @@ export class SwapRules extends ChessRules { const color = this.turn; const piece = this.getPiece(x, y); const addSmoves = (i, j) => { - if (this.getPiece(i, j) != piece) + if (this.getPiece(i, j) != piece || this.getColor(i, j) != color) Array.prototype.push.apply(moves, this.getSwapMoves([x, y], [i, j])); }; switch (piece) { @@ -341,4 +342,5 @@ export class SwapRules extends ChessRules { // Swap return "S" + V.CoordsToSquare(move.start) + V.CoordsToSquare(move.end); } + };