From f897a4ef9f30a51755e9180cf6ba9f9c2557616f Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Fri, 23 Apr 2021 07:41:39 +0200
Subject: [PATCH] Fix Football

---
 client/src/variants/Football.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

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
           }
         }
       }
-- 
2.44.0