Attempt to clarify installation instructions a little
[vchess.git] / client / src / variants / Rampage.js
index 2fe96db..12a61a1 100644 (file)
@@ -1,6 +1,7 @@
 import { ChessRules } from "@/base_rules";
 
 export class RampageRules extends ChessRules {
+
   // Sum white pieces attacking a square, and remove black pieces count.
   sumAttacks([x, y]) {
     const getSign = (color) => {
@@ -62,13 +63,19 @@ export class RampageRules extends ChessRules {
       return moves;
     // Remember current final squares to not add moves twice:
     const destinations = {};
+    const lastRank = (color == 'w' ? 0 : 7);
+    const piece = this.getPiece(x, y);
     moves.forEach(m => destinations[m.end.x + "_" + m.end.y] = true);
     for (let i=0; i<8; i++) {
       for (let j=0; j<8; j++) {
         if (this.board[i][j] == V.EMPTY && !destinations[i + "_" + j]) {
           const sa = this.sumAttacks([i, j]);
-          if ((color == 'w' && sa > 0) || (color == 'b' && sa < 0))
+          if (
+            ((color == 'w' && sa > 0) || (color == 'b' && sa < 0)) &&
+            (piece != V.PAWN || i != lastRank)
+          ) {
             moves.push(this.getBasicMove([x, y], [i, j]));
+          }
         }
       }
     }
@@ -78,4 +85,5 @@ export class RampageRules extends ChessRules {
   static get SEARCH_DEPTH() {
     return 1;
   }
+
 };