X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FSwitching.js;h=67078f536202aa55885ae8d9621906b1419d0607;hb=26c1e3bd4d3e9fb7c86e25c0f423bea57b977111;hp=e53ab6926d9e5e7be2b70bed410d7db70e4d3656;hpb=643479f8d7c3622b57fc49c4f10d9950793ebf4f;p=vchess.git diff --git a/public/javascripts/variants/Switching.js b/public/javascripts/variants/Switching.js index e53ab692..67078f53 100644 --- a/public/javascripts/variants/Switching.js +++ b/public/javascripts/variants/Switching.js @@ -104,7 +104,7 @@ class SwitchingRules extends ChessRules && move.appear[1].p == V.KING) { // Switch with the king; not castle, and not handled by main class - const color = this.getColor(move.start.x, move.start.y); + const color = move.vanish[0].c; this.kingPos[color] = [move.appear[1].x, move.appear[1].y]; } } @@ -115,7 +115,7 @@ class SwitchingRules extends ChessRules if (move.appear.length == 2 && move.vanish.length == 2 && move.appear[1].p == V.KING) { - const color = this.getColor(move.start.x, move.start.y); + const color = move.vanish[0].c; this.kingPos[color] = [move.appear[0].x, move.appear[0].y]; } } @@ -130,11 +130,7 @@ class SwitchingRules extends ChessRules if (move.appear[0].p == V.KING && move.appear[1].p == V.ROOK) return (move.end.y < move.start.y ? "0-0-0" : "0-0"); // Switch: - const startSquare = - String.fromCharCode(97 + move.start.y) + (V.size.x-move.start.x); - const finalSquare = - String.fromCharCode(97 + move.end.y) + (V.size.x-move.end.x); - return "S" + startSquare + finalSquare; + return "S" + V.CoordsToSquare(move.start) + V.CoordsToSquare(move.end); } }