From 2cfc3b918bf2c6581199f9ca72b61112c35fdb15 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Sat, 27 Mar 2021 22:53:59 +0100 Subject: [PATCH] Fix typo in Fugue rules + remove Football redundant kicks --- client/src/translations/rules/Fugue/en.pug | 8 ++++---- client/src/translations/rules/Fugue/es.pug | 10 +++++----- client/src/translations/rules/Fugue/fr.pug | 8 ++++---- client/src/variants/Football.js | 14 ++++++++++---- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/client/src/translations/rules/Fugue/en.pug b/client/src/translations/rules/Fugue/en.pug index 528b9ea7..ebbd33c7 100644 --- a/client/src/translations/rules/Fugue/en.pug +++ b/client/src/translations/rules/Fugue/en.pug @@ -26,15 +26,15 @@ ul The Pushme-Pullyu (U) (gnu) captures pieces which are on its line of movement, either just below the first square or right after the final square. It cannot capture both, however. - li. - The Archer (A) (bow) captures by "shooting": it can remove any enemy - piece P standing in its range, provided that + li + | The Archer (A) (bow) captures by "shooting": it can remove any enemy + | piece P standing in its range, provided that ul li P is standing at most two squares from the archer, or, li. a friendly piece is at a distance of two squares or less from P, without obstacle between it and P. - In both cases the archer must have a clear path until the target. + | In both cases the archer must have a clear path until the target. li. The Shield (S) protects all friendly pieces adjacent to it: they cannot be captured. The shield cannot capture. diff --git a/client/src/translations/rules/Fugue/es.pug b/client/src/translations/rules/Fugue/es.pug index 29a7f144..bbe8c28a 100644 --- a/client/src/translations/rules/Fugue/es.pug +++ b/client/src/translations/rules/Fugue/es.pug @@ -27,16 +27,16 @@ ul El "Pushme-Pullyu" (U) (ñu) captura las piezas que yacen en su línea movimiento, ya sea justo antes del primer cuadro o justo después de la casilla final. Sin embargo, no puede tomar ambos. - li. - El arquero (A) (arco) captura "disparando": puede suprimir cualquier - pieza enemiga P qué está dentro del alcance, siempre que + li + | El arquero (A) (arco) captura "disparando": puede suprimir cualquier + | pieza enemiga P qué está dentro del alcance, siempre que ul li P está a dos casillas o menos del arquero, o li. una pieza amiga está a dos casillas o menos de P (en línea recta), sin obstáculo entre ella y P. - En ambos casos, el arquero debe tener un - camino despejado hacia su objetivo. + | En ambos casos, el arquero debe tener un + | camino despejado hacia su objetivo. li. El Escudo (S) protege cualquier pieza amiga a su lado: estos no puede ser capturado. El escudo no puede capturar. diff --git a/client/src/translations/rules/Fugue/fr.pug b/client/src/translations/rules/Fugue/fr.pug index fd353b65..e1b29a7e 100644 --- a/client/src/translations/rules/Fugue/fr.pug +++ b/client/src/translations/rules/Fugue/fr.pug @@ -28,15 +28,15 @@ ul Le "Pushme-Pullyu" (U) (gnou) capture les pièces se situant sur sa ligne de déplacement, soit juste avant la première case soit juste après la case finale. Il ne peut pas prendre les deux, ceci dit. - li. - L'Archer (A) (arc) capture en "tirant" : il peut supprimer n'importe - quelle pièce ennemie P à sa portée, à condition que + li + | L'Archer (A) (arc) capture en "tirant" : il peut supprimer n'importe + | quelle pièce ennemie P à sa portée, à condition que ul li P se trouve à deux cases ou moins de l'archer, ou, li. une pièce amie est à deux cases ou moins de P (en ligne droite), sans obstacle entre elle et P. - Dans les deux cas l'archer doit avoir un chemin dégagé jusqu'à sa cible. + | Dans les deux cas l'archer doit avoir un chemin dégagé jusqu'à sa cible. li. Le Bouclier (S) protège toute pièce amie à côté de lui : celles-ci ne peuvent être capturées. Le bouclier ne peut pas capturer. diff --git a/client/src/variants/Football.js b/client/src/variants/Football.js index df46d01c..d63cfee3 100644 --- a/client/src/variants/Football.js +++ b/client/src/variants/Football.js @@ -282,7 +282,7 @@ export class FootballRules extends ChessRules { const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); const c = this.turn; let moves = []; - let atLeastOnePotentialKick = false; + let kicks = {}; for (let s of steps) { const [i, j] = [x + s[0], y + s[1]]; if ( @@ -290,11 +290,17 @@ export class FootballRules extends ChessRules { this.board[i][j] != V.EMPTY && this.getColor(i, j) == c ) { - if (!atLeastOnePotentialKick) atLeastOnePotentialKick = true; - Array.prototype.push.apply(moves, this.tryKickFrom([i, j])); + const kmoves = this.tryKickFrom([i, j]); + kmoves.forEach(km => { + const key = V.CoordsToSquare(km.start) + V.CoordsToSquare(km.end); + if (!kicks[km]) { + moves.push(km); + kicks[km] = true; + } + }); } } - if (atLeastOnePotentialKick) { + if (Object.keys(kicks).length > 0) { // And, always add the "end" move. For computer, keep only one outerLoop: for (let i=0; i < V.size.x; i++) { for (let j=0; j < V.size.y; j++) { -- 2.44.0