Backward compatibility for Ball variant (wildebeest)
[vchess.git] / client / src / variants / Ball.js
index 5de871d..8f6493a 100644 (file)
@@ -137,7 +137,7 @@ export class BallRules extends ChessRules {
     const withPrefix =
       Object.keys(V.HAS_BALL_DECODE)
       .concat([V.PHOENIX])
-      .concat(['a']);
+      .concat(['a', 'w']); //TODO: 'w' for backward compatibility - to remove
     if (withPrefix.includes(b[1])) prefix = "Ball/";
     return prefix + b;
   }
@@ -205,8 +205,10 @@ export class BallRules extends ChessRules {
       if (rem2 == positions[1] % 2) {
         // Fix bishops (on different colors)
         for (let i=4; i<9; i++) {
-          if (positions[i] % 2 != rem2)
+          if (positions[i] % 2 != rem2) {
             [positions[1], positions[i]] = [positions[i], positions[1]];
+            break;
+          }
         }
       }
       rem2 = positions[2] % 2;