Work on Eightpieces main
authorBenjamin Auder <benjamin.auder@somewhere>
Fri, 6 Jun 2025 17:55:48 +0000 (19:55 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Fri, 6 Jun 2025 17:55:48 +0000 (19:55 +0200)
base_rules.js
variants/Eightpieces/class.js

index de3fa44..26e8e49 100644 (file)
@@ -1151,7 +1151,7 @@ export default class ChessRules {
   // Color of thing on square (i,j). '' if square is empty
   getColor(i, j) {
     if (typeof i == "string")
-      return i; //reserves
+      return i; //reserves : 'wb'
     return this.board[i][j].charAt(0);
   }
 
@@ -1166,7 +1166,7 @@ export default class ChessRules {
   // Piece on i,j. '' if square is empty
   getPiece(i, j) {
     if (typeof j == "string")
-      return j; //reserves
+      return j; //reserves : 'bq'
     return this.board[i][j].charAt(1);
   }
 
index eb68c76..c1edfb4 100644 (file)
@@ -12,11 +12,6 @@ export default class EightpiecesRules extends ChessRules {
     };
   }
 
-// TODO: variable (setupOthers) for lancers directions (x,y) => dir ("0, 1, 2, ...") 0 = top 1 = north east... / white viewpoint
-
-//variable lancer_orient ... --> array size 8 x 8 (TODO?)
-  //
-
   static get LANCER_STEP() {
     return {
       'N': [-1, 0],
@@ -30,6 +25,10 @@ export default class EightpiecesRules extends ChessRules {
     };
   }
 
+  encodeSquare(x, y) {
+    return (x*this.size.y+y).toString();
+  }
+
   pieces(color, x, y) {
     let basePieces = super.pieces(color, x, y);
     const extension = {
@@ -54,7 +53,7 @@ export default class EightpiecesRules extends ChessRules {
         both: [
           {
             steps: [ V.LANCER_STEP [
-              this.lancer_orient[(x*this.size.y+y).toString()] ]
+              this.lancer_orient[this.encodeSquare(x, y)] ]
             ]
           }
         ]
@@ -62,30 +61,35 @@ export default class EightpiecesRules extends ChessRules {
     };
   }
 
+  get pawnPromotions() {
+    // TODO: lancer orientation = backward vertical from promotion square?
+    return ['q', 'r', 'n', 'b', 'j', 's', 'l'];
+  }
+
   // lorient : "{z1:NO,z2:SE, ...etc}"
   setOtherVariables(fenParsed) {
     super.setOtherVariables(fenParsed);
     this.lancer_orient = JSON.parse(fenParsed.lorient);
   }
 
-  //TODO: from here
-
-  static ParseFen(fen) {
-    const fenParts = fen.split(" ");
-    return Object.assign(
-      ChessRules.ParseFen(fen),
-      { sentrypush: fenParts[5] }
+  getPartFen(o) {
+    return Object.assign({},
+      super.getPartFen(o),
+      {
+        "lorient": o.init ? "TODO" : this.getLorientFen(),
+        "sentrypush": o.init ? "-" : this.getSentrypushFen()
+      }
     );
   }
 
-  getFen() {
-    return super.getFen() + " " + this.getSentrypushFen();
+  getLorientFen() {
+    // TODO: use this.lancer_orient to output {z1:NO,z2:SE, ...etc}
+    return "";
   }
 
-  getFenForRepeat() {
-    return super.getFenForRepeat() + "_" + this.getSentrypushFen();
-  }
 
+
+  // TODO: from here --> L1500 in base -- moves generation
   getSentrypushFen() {
     const L = this.sentryPush.length;
     if (!this.sentryPush[L-1]) return "-";
@@ -97,6 +101,8 @@ export default class EightpiecesRules extends ChessRules {
       .join("");
   }
 
+
+
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
     // subTurn == 2 only when a sentry moved, and is about to push something
@@ -188,6 +194,12 @@ export default class EightpiecesRules extends ChessRules {
     return super.canTake([x1, y1], [x2, y2]);
   }
 
+
+
+
+
+
+
   // Is piece on square (x,y) immobilized?
   isImmobilized([x, y]) {
     const color = this.getColor(x, y);