X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FFootball.js;fp=client%2Fsrc%2Fvariants%2FFootball.js;h=5b0b16df1b91c31667f313d8829980581521f558;hp=18a3ecad4ee3dbf691698677214ce600f42c7e5c;hb=f897a4ef9f30a51755e9180cf6ba9f9c2557616f;hpb=cc0f1cbf5844499838d34d7c7342e64e5d33dbe3 diff --git a/client/src/variants/Football.js b/client/src/variants/Football.js index 18a3ecad..5b0b16df 100644 --- a/client/src/variants/Football.js +++ b/client/src/variants/Football.js @@ -266,6 +266,7 @@ export class FootballRules extends ChessRules { const c = this.turn; let moves = []; let kicks = {}; + let adjacentPieces = false; for (let s of steps) { const [i, j] = [x + s[0], y + s[1]]; if ( @@ -281,15 +282,16 @@ export class FootballRules extends ChessRules { kicks[key] = true; } }); + if (!adjacentPieces) adjacentPieces = true; } } - if (Object.keys(kicks).length > 0) { - // And, always add the "end" move. For computer, keep only one + if (adjacentPieces) { + // Add the "end" move (even if no valid kicks) outerLoop: for (let i=0; i < V.size.x; i++) { for (let j=0; j < V.size.y; j++) { if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == c) { moves.push(super.getBasicMove([x, y], [i, j])); - if (computer) break outerLoop; + if (computer) break outerLoop; //no choice for computer } } }