From: Benjamin Auder Date: Sun, 25 Apr 2021 07:49:21 +0000 (+0200) Subject: Fix Joker X-Git-Url: https://git.auder.net/doc/html/index.html?a=commitdiff_plain;h=4c3031a52a1b95ad8002a3f055d4475130297a7b;p=vchess.git Fix Joker --- diff --git a/client/src/translations/rules/Joker/en.pug b/client/src/translations/rules/Joker/en.pug index 1f102384..b7a05350 100644 --- a/client/src/translations/rules/Joker/en.pug +++ b/client/src/translations/rules/Joker/en.pug @@ -4,7 +4,7 @@ p.boxed p. A new piece appears, starting in front of the pawns. It moves like an Amazon: Queen + Knight, but doesn't capture. - Instead, it can swap its position with any piece. + Instead, it can swap its position with any piece except the king. figure.diagram-container .diagram diff --git a/client/src/translations/rules/Joker/es.pug b/client/src/translations/rules/Joker/es.pug index 7aaaf9fb..6c066212 100644 --- a/client/src/translations/rules/Joker/es.pug +++ b/client/src/translations/rules/Joker/es.pug @@ -4,7 +4,7 @@ p.boxed p. Aparece una nueva pieza, comenzando por delante de los peones. Se mueve como una Amazona: Dama + Caballo, pero no captura. - En cambio, puede cambiar su posición con cualquier pieza. + En cambio, puede cambiar su posición con cualquier pieza excepto el rey. figure.diagram-container .diagram diff --git a/client/src/translations/rules/Joker/fr.pug b/client/src/translations/rules/Joker/fr.pug index 853d7040..bb64c0b7 100644 --- a/client/src/translations/rules/Joker/fr.pug +++ b/client/src/translations/rules/Joker/fr.pug @@ -5,7 +5,8 @@ p.boxed p. Une nouvelle pièce fait son apparition, démarrant devant les pions. Elle se déplace comme une Amazone : Dame + Cavalier, mais ne capture pas. - Au lieu de ça, elle peut échanger sa position avec n'importe quelle pièce. + Au lieu de ça, elle peut échanger sa position avec n'importe quelle pièce + sauf le roi. figure.diagram-container .diagram diff --git a/client/src/variants/Joker.js b/client/src/variants/Joker.js index bc3a7f1b..a3cbdad5 100644 --- a/client/src/variants/Joker.js +++ b/client/src/variants/Joker.js @@ -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 }) + ] + }) + ); + } } } }