Some fixes, draw lines on board, add 7 variants
[vchess.git] / client / src / variants / Sittuyin.js
index f37eabf..61bab56 100644 (file)
@@ -10,12 +10,22 @@ export class SittuyinRules extends ChessRules {
     return false;
   }
 
+  static get Monochrome() {
+    return true;
+  }
+
+  static get Lines() {
+    return ChessRules.Lines.concat([
+      [[0, 0], [8, 8]],
+      [[0, 8], [8, 0]]
+    ]);
+  }
+
   static get PawnSpecs() {
     return Object.assign(
       {},
       ChessRules.PawnSpecs,
       {
-        twoSquares: false,
         // Promotions are handled differently here
         promotions: [V.QUEEN]
       }
@@ -119,29 +129,20 @@ export class SittuyinRules extends ChessRules {
 
   getPotentialPawnMoves([x, y]) {
     const color = this.turn;
-    const [sizeX, sizeY] = [V.size.x, V.size.y];
     const shiftX = V.PawnSpecs.directions[color];
     let moves = [];
-    // NOTE: next condition is generally true (no pawn on last rank)
-    if (x + shiftX >= 0 && x + shiftX < sizeX) {
-      if (this.board[x + shiftX][y] == V.EMPTY) {
+    if (x + shiftX >= 0 && x + shiftX < 8) {
+      if (this.board[x + shiftX][y] == V.EMPTY)
         // One square forward
         moves.push(this.getBasicMove([x, y], [x + shiftX, y]));
-      }
       // Captures
-      if (V.PawnSpecs.canCapture) {
-        for (let shiftY of [-1, 1]) {
-          if (
-            y + shiftY >= 0 &&
-            y + shiftY < sizeY
-          ) {
-            if (
-              this.board[x + shiftX][y + shiftY] != V.EMPTY &&
-              this.canTake([x, y], [x + shiftX, y + shiftY])
-            ) {
-              moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY]));
-            }
-          }
+      for (let shiftY of [-1, 1]) {
+        if (
+          y + shiftY >= 0 && y + shiftY < 8 &&
+          this.board[x + shiftX][y + shiftY] != V.EMPTY &&
+          this.canTake([x, y], [x + shiftX, y + shiftY])
+        ) {
+          moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY]));
         }
       }
     }