Add Tencubed and Omega variants + some fixes (updateCastleFlags()) + cleaner FEN...
[vchess.git] / client / src / variants / Schess.js
index d2e3528..06644c7 100644 (file)
@@ -33,10 +33,6 @@ export class SchessRules extends ChessRules {
     return b;
   }
 
-  // TODO: maybe changes could be done to this method to show "empty"
-  // instead of a piece to not use a pocket piece...
-//  getPPpath(b) { }
-
   static IsGoodFen(fen) {
     if (!ChessRules.IsGoodFen(fen)) return false;
     const fenParsed = V.ParseFen(fen);
@@ -54,7 +50,7 @@ export class SchessRules extends ChessRules {
   setFlags(fenflags) {
     super.setFlags(fenflags); //castleFlags
     this.pieceFlags = {
-      w: [...Array(8)], //pawns can move 2 squares?
+      w: [...Array(8)], //pieces can generate Hawk or Elephant?
       b: [...Array(8)]
     };
     const flags = fenflags.substr(4); //skip first 4 letters, for castle
@@ -176,7 +172,8 @@ export class SchessRules extends ChessRules {
                 (
                   m.appear.length == shift+1 ||
                   // Special castle case: is initial king square free?
-                  ![m.appear[shift].y, m.appear[shift+1].y].includes(m.vanish[0].y)
+                  ![m.appear[shift].y, m.appear[shift+1].y]
+                    .includes(m.vanish[0].y)
                 )
               ) {
                 let pMove = JSON.parse(JSON.stringify(m));
@@ -193,9 +190,10 @@ export class SchessRules extends ChessRules {
               }
               shift = (m.appear[0].p == V.NOTHING ? 1 : 0);
               if (
-                m.appear.length >= 2 &&
+                m.appear.length >= 2 + shift &&
                 m.vanish.length == 2 &&
-                ![m.appear[shift].y, m.appear[shift+1].y].includes(m.vanish[1].y)
+                ![m.appear[shift].y, m.appear[shift+1].y]
+                  .includes(m.vanish[1].y)
               ) {
                 // Special castle case: rook flag was necessarily on
                 let pMove = JSON.parse(JSON.stringify(m));
@@ -293,11 +291,10 @@ export class SchessRules extends ChessRules {
         ([V.HAWK, V.ELEPHANT, V.NOTHING].includes(move.appear[0].p) ? 1 : 0);
       this.kingPos[color][0] = move.appear[shift].x;
       this.kingPos[color][1] = move.appear[shift].y;
-      return;
     }
     this.updateCastleFlags(move, piece);
 
-    const oppCol = V.GetOppCol(color);
+    const oppCol = this.turn;
     const firstRank = (color == 'w' ? 7 : 0);
     const oppFirstRank = 7 - firstRank;
     // Does this move turn off a piece init square flag?