X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FJoker.js;h=a3cbdad550086a52a10a20c4146d105ab869e312;hb=HEAD;hp=fd302bbb7a35f9bbd891e6949ef4a6f6ca89e5a0;hpb=cee75a57d2f4f89c89d64cefbab55d839a238ed9;p=vchess.git diff --git a/client/src/variants/Joker.js b/client/src/variants/Joker.js index fd302bbb..a3cbdad5 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 = []; @@ -58,18 +58,21 @@ export class JokerRules extends ChessRules { // Following test is OK because only one Joker on board at a time if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == c) { const p = this.getPiece(i, j); - swapping.push( - new Move({ - vanish: [ - new PiPo({ x: x, y: y, c: c, p: V.JOKER }), - new PiPo({ x: i, y: j, c: c, p: p }) - ], - appear: [ - new PiPo({ x: i, y: j, c: c, p: V.JOKER }), - new PiPo({ x: x, y: y, c: c, p: p }) - ] - }) - ); + const lastRank = (c == 'w' ? 0 : 7); + if (p != V.KING && (p != V.PAWN || x != lastRank)) { + swapping.push( + new Move({ + vanish: [ + new PiPo({ x: x, y: y, c: c, p: V.JOKER }), + new PiPo({ x: i, y: j, c: c, p: p }) + ], + appear: [ + new PiPo({ x: i, y: j, c: c, p: V.JOKER }), + new PiPo({ x: x, y: y, c: c, p: p }) + ] + }) + ); + } } } }