Fix Antiking
[xogo.git] / variants / Alapo / class.js
index eb0e73f..4836413 100644 (file)
@@ -1,9 +1,16 @@
 import ChessRules from "/base_rules.js";
-import { ArrayFun } from "/utils/array.js";
-import { Random } from "/utils/alea.js";
+import {ArrayFun} from "/utils/array.js";
+import {Random} from "/utils/alea.js";
 
 export default class AlapoRules extends ChessRules {
 
+  static get Options() {
+    return {
+      select: C.Options.select,
+      styles: C.Options.styles.filter(s => s != "teleport")
+    };
+  }
+
   get hasFlags() {
     return false;
   }
@@ -81,15 +88,14 @@ export default class AlapoRules extends ChessRules {
     );
   }
 
+  // Triangles are rotated from opponent viewpoint (=> suffix "_inv")
   pieces(color, x, y) {
+    const allSpecs = super.pieces(color, x, y);
     return {
-      'r': super.pieces(color, x, y)['r'],
-      'q': super.pieces(color, x, y)['q'],
-      'b': {
-        // Triangle is rotated from opponent viewpoint
-        "class": "bishop" + (this.playerColor != color ? "_inv" : ""),
-        moves: [ { steps: [[1, 1], [1, -1], [-1, 1], [-1, -1]] } ]
-      },
+      'r': allSpecs['r'],
+      'q': allSpecs['q'],
+      'b': Object.assign({}, allSpecs['b'],
+        {"class": "bishop" + (this.playerColor != color ? "_inv" : "")}),
       's': { //"square"
         "class": "babyrook",
         moves: [
@@ -143,8 +149,14 @@ export default class AlapoRules extends ChessRules {
       won[c] = this.board[goal].some((b,j) => {
         return (
           this.getColor(goal, j) == c &&
-          this.findCapturesOn(
-            [goal, j], {one: true, oppCol: oppCol}).length == 0
+          !this.findCapturesOn(
+            [goal, j],
+            {
+              one: true,
+              oppCol: oppCol,
+              segments: this.options["cylinder"]
+            }
+          )
         );
       });
     }