Add unambiguous section in the PGN + some fixes + code formatting and fix typos
[vchess.git] / client / src / variants / Ball.js
index 1bb7731..0f84bae 100644 (file)
@@ -7,18 +7,15 @@ export class BallRules extends ChessRules {
     return Object.assign(
       {},
       ChessRules.PawnSpecs,
-      { promotions: ChessRules.PawnSpecs.promotions.concat([V.CHAMPION]) }
+      { promotions: ChessRules.PawnSpecs.promotions.concat([V.PHOENIX]) }
     );
   }
 
   static get HasFlags() {
     return false;
   }
-  static get HasCastle() {
-    return false;
-  }
 
-  static get CHAMPION() {
+  static get PHOENIX() {
     return 'h';
   }
 
@@ -38,10 +35,10 @@ export class BallRules extends ChessRules {
       'p': 's',
       'r': 'u',
       'n': 'o',
-      'b': 'c',
+      'b': 'd',
       'q': 't',
       'k': 'l',
-      'h': 'd'
+      'h': 'i'
     };
   }
 
@@ -50,16 +47,16 @@ export class BallRules extends ChessRules {
       's': 'p',
       'u': 'r',
       'o': 'n',
-      'c': 'b',
+      'd': 'b',
       't': 'q',
       'l': 'k',
-      'd': 'h'
+      'i': 'h'
     };
   }
 
   static get PIECES() {
     return ChessRules.PIECES
-      .concat([V.CHAMPION])
+      .concat([V.PHOENIX])
       .concat(Object.keys(V.HAS_BALL_DECODE))
       .concat(['a']);
   }
@@ -108,7 +105,7 @@ export class BallRules extends ChessRules {
     let prefix = "";
     const withPrefix =
       Object.keys(V.HAS_BALL_DECODE)
-      .concat([V.CHAMPION])
+      .concat([V.PHOENIX])
       .concat(['a']);
     if (withPrefix.includes(b[1])) prefix = "Ball/";
     return prefix + b;
@@ -128,7 +125,7 @@ export class BallRules extends ChessRules {
 
   static GenRandInitFen(randomness) {
     if (randomness == 0)
-      return "rnbhqhnbr/ppppppppp/9/9/4a4/9/9/PPPPPPPPP/RNBHQHNBR w 0 -";
+      return "rnbcqcnbr/ppppppppp/9/9/4a4/9/9/PPPPPPPPP/RNBCQCNBR w 0 -";
 
     let pieces = { w: new Array(9), b: new Array(9) };
     for (let c of ["w", "b"]) {
@@ -139,7 +136,7 @@ export class BallRules extends ChessRules {
 
       // Get random squares for every piece, totally freely
       let positions = shuffle(ArrayFun.range(9));
-      const composition = ['b', 'b', 'r', 'r', 'n', 'n', 'h', 'h', 'q'];
+      const composition = ['b', 'b', 'r', 'r', 'n', 'n', 'c', 'c', 'q'];
       const rem2 = positions[0] % 2;
       if (rem2 == positions[1] % 2) {
         // Fix bishops (on different colors)
@@ -176,16 +173,12 @@ export class BallRules extends ChessRules {
     return Object.assign(
       {},
       ChessRules.steps,
-      // Add champion moves
+      // Add phoenix moves
       {
         h: [
           [-2, -2],
-          [-2, 0],
           [-2, 2],
-          [0, -2],
-          [0, 2],
           [2, -2],
-          [2, 0],
           [2, 2],
           [-1, 0],
           [1, 0],
@@ -261,8 +254,8 @@ export class BallRules extends ChessRules {
   // So base implementation is fine.
 
   getPotentialMovesFrom([x, y]) {
-    if (this.getPiece(x, y) == V.CHAMPION)
-      return this.getPotentialChampionMoves([x, y]);
+    if (this.getPiece(x, y) == V.PHOENIX)
+      return this.getPotentialPhoenixMoves([x, y]);
     return super.getPotentialMovesFrom([x, y]);
   }
 
@@ -286,8 +279,8 @@ export class BallRules extends ChessRules {
     return moves;
   }
 
-  getPotentialChampionMoves(sq) {
-    return this.getSlideNJumpMoves(sq, V.steps[V.CHAMPION], "oneStep");
+  getPotentialPhoenixMoves(sq) {
+    return this.getSlideNJumpMoves(sq, V.steps[V.PHOENIX], "oneStep");
   }
 
   filterValid(moves) {
@@ -323,11 +316,11 @@ export class BallRules extends ChessRules {
   static get VALUES() {
     return {
       p: 1,
-      r: 5,
+      r: 3,
       n: 3,
-      b: 3,
-      q: 9,
-      h: 4,
+      b: 2,
+      q: 5,
+      h: 3,
       a: 0 //ball: neutral
     };
   }