Draft Checkless. Add 'trackKingWrap' method, untested. Use 'canSelfTake'
[xogo.git] / variants / Teleport / class.js
index 2698eaf..7ac3b34 100644 (file)
@@ -5,8 +5,12 @@ export default class TeleportRules extends ChessRules {
   static get Options() {
     return {
       select: C.Options.select,
-      // TODO? option "teleport king"?
-      input: C.Options.input,
+      input: C.Options.input.concat({
+        label: "Teleport king",
+        variable: "tpking",
+        type: "checkbox",
+        defaut: false
+      }),
       styles: C.Options.styles.filter(s => s != "teleport")
     };
   }
@@ -16,4 +20,8 @@ export default class TeleportRules extends ChessRules {
     super(o);
   }
 
+  canSelfTake([x1, y1], [x2, y2]) {
+    return (this.options["tpking"] || !this.isKing(x2, y2));
+  }
+
 };