Attempt to clarify installation instructions a little
[vchess.git] / client / src / variants / Football.js
index 18a3eca..ffe6736 100644 (file)
@@ -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,19 @@ 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;
+            moves.push({
+              appear: [], vanish: [],
+              start: { x: x, y: y }, end: { x: i, y: j }
+            });
+            if (computer) break outerLoop; //no choice for computer
           }
         }
       }
@@ -358,7 +363,7 @@ export class FootballRules extends ChessRules {
 
   play(move) {
     // Special message saying "passes are over"
-    const passesOver = (move.vanish.length == 2);
+    const passesOver = (move.vanish.length == 0);
     if (!passesOver) {
       this.prePlay(move);
       V.PlayOnBoard(this.board, move);
@@ -380,7 +385,7 @@ export class FootballRules extends ChessRules {
   }
 
   undo(move) {
-    const passesOver = (move.vanish.length == 2);
+    const passesOver = (move.vanish.length == 0);
     if (move.turn[0] != this.turn) {
       [this.turn, this.subTurn] = move.turn;
       this.movesCount--;
@@ -434,7 +439,7 @@ export class FootballRules extends ChessRules {
   // NOTE: evalPosition() is wrong, but unused since bot plays at random
 
   getNotation(move) {
-    if (move.vanish.length == 2) return "pass";
+    if (move.vanish.length == 0) return "pass";
     if (move.vanish[0].p != 'a') return super.getNotation(move);
     // Kick: simple notation (TODO?)
     return V.CoordsToSquare(move.end);