X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FJoker.js;h=bc3a7f1bf82e3192e28145e16910566d3f534ecc;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=137249c4f83d5d0836bbbf064c46fd012f027ff5;hpb=459edd581fa23f511e224f07554944bbe53a2d70;p=vchess.git diff --git a/client/src/variants/Joker.js b/client/src/variants/Joker.js index 137249c4..bc3a7f1b 100644 --- a/client/src/variants/Joker.js +++ b/client/src/variants/Joker.js @@ -11,8 +11,8 @@ export class JokerRules extends ChessRules { ); } - static GenRandInitFen(randomness) { - const antikingFen = Antiking2Rules.GenRandInitFen(randomness); + static GenRandInitFen(options) { + const antikingFen = Antiking2Rules.GenRandInitFen(options); return antikingFen.replace('a', 'J').replace('A', 'j'); } @@ -48,7 +48,7 @@ export class JokerRules extends ChessRules { getPotentialJokerMoves([x, y]) { const moving = - super.getSlideNJumpMoves([x, y], V.steps[V.KNIGHT], "oneStep") + super.getSlideNJumpMoves([x, y], V.steps[V.KNIGHT], 1) .concat(super.getSlideNJumpMoves([x, y], V.steps[V.ROOK].concat(V.steps[V.BISHOP]))); let swapping = []; @@ -76,6 +76,19 @@ export class JokerRules extends ChessRules { return moving.concat(swapping); } + postPlay(move) { + super.postPlay(move); + // Was my king swapped? + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) + this.kingPos[move.appear[1].c] = [move.appear[1].x, move.appear[1].y]; + } + + postUndo(move) { + super.postUndo(move); + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) + this.kingPos[move.vanish[1].c] = [move.vanish[1].x, move.vanish[1].y]; + } + static get VALUES() { return Object.assign({ j: 2 }, ChessRules.VALUES); }