Add Cleopatra option to Benedict chess
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 21 Jun 2022 17:36:14 +0000 (19:36 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 21 Jun 2022 17:36:14 +0000 (19:36 +0200)
pieces/Benedict/black_cleopatra.svg [new file with mode: 0644]
pieces/Benedict/white_cleopatra.svg [new file with mode: 0644]
variants.js
variants/Benedict/CREDITS [new file with mode: 0644]
variants/Benedict/class.js
variants/Benedict/rules.html
variants/Benedict/style.css

diff --git a/pieces/Benedict/black_cleopatra.svg b/pieces/Benedict/black_cleopatra.svg
new file mode 100644 (file)
index 0000000..4360044
--- /dev/null
@@ -0,0 +1 @@
+<svg width="512px" height="512px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#000" d="M247.6 17l-14.4 94.6 14.9 59.7c2.9 2.8 5.6 5.5 7 6.7.6.4.7.4.9.6.2-.2.3-.2.9-.6 1.4-1.2 4.1-3.9 7-6.7l14.9-59.7L264.4 17h-16.8zm-18.7 10.61c-36.1 6.78-71.8 26.1-101.4 49.45-5.7 4.49-11.1 9.14-16.3 13.88 34.4 3.96 70 6.44 105.9 7.49l11.8-70.82zm54.1.03l11.9 70.76c35.9-1.02 71.5-3.49 105.8-7.44-5.2-4.75-10.7-9.4-16.4-13.9-29.6-23.32-65.1-42.61-101.3-49.42zM94.81 107.1c-9.8 10.4-18.14 20.7-24.63 30.2 52.52 5.3 103.12 8.4 153.22 9.4l-7.6-30.3c-41.2-1.3-81.9-4.3-120.99-9.3zm322.19 0c-39 5-79.7 8-120.8 9.2l-7.6 30.4c50.1-1 100.6-4.1 153.1-9.4-6.5-9.4-14.8-19.8-24.7-30.2zM60.08 154.3c-1.43 2.9-2.58 5.6-3.44 8.1-7.98 40.7-7.5 86.3-5.27 132.1 11.55 11.4 22.95 22 34.03 30.3 11 8.2 21.6 14.1 31.5 16.7 1.9-39.3 2-86.5 2-149.5v-13.3l12.3 4.9c77.7 31.1 171.7 31.1 249.4 0l12.3-4.9V192c0 63 .1 110.3 2 149.5 10-2.6 20.6-8.4 31.7-16.7 10.9-8.2 22.1-18.6 33.5-29.8 2.5-50.6 3.3-99.3-4.8-132.4-.9-2.5-2-5.3-3.5-8.3-57.6 6.1-112.9 9.5-167.7 10.4l-4 15.9-1.7 1.8c-4 4-7.1 7.1-10.3 9.6-3.2 2.6-7.1 5-12.1 5s-8.9-2.4-12.1-5c-3.2-2.5-6.3-5.6-10.3-9.6l-1.7-1.8-4-15.9c-54.9-.9-110.2-4.3-167.82-10.4zm76.82 50.6c0 22.4 0 42.9-.2 61.8 8.7-12.8 18.2-21.2 28.4-25.6 5.1-2.3 10.4-3.4 15.6-3.7 1.3-.1 2.5-.1 3.8-.1 3.8.1 7.6.6 11.3 1.4 19.3 4.5 35.8 17.4 49 25.7l-9.6 15.2c-6-3.8-12.3-8-18.6-11.8.3 1.4.4 2.8.4 4.2 0 13.7-11.3 25-25 25s-25-11.3-25-25c0-5.2 1.6-10 4.4-14-6.2 2.8-12.9 8.5-19.9 19l-14.8-9.9c-.1 17.4-.4 33.5-.8 48.5 6.9 24.8 16.8 47.1 29 65.5C189 417.6 221.2 439 256 439s67-21.4 91.1-57.9c12.1-18.3 22-40.4 28.8-65-.4-15.1-.7-31.3-.8-48.8l-14.6 9.7c-7-10.5-13.7-16.2-19.9-19 2.8 4 4.4 8.8 4.4 14 0 13.7-11.3 25-25 25s-25-11.3-25-25c0-1.4.1-2.8.4-4.2-6.3 3.8-12.6 8-18.6 11.8l-9.6-15.2c13.2-8.3 29.7-21.2 49-25.7 3.7-.8 7.5-1.3 11.3-1.4 1.3 0 2.5 0 3.8.1 5.2.3 10.5 1.4 15.6 3.7 10.1 4.3 19.6 12.6 28.2 25.3-.2-18.8-.2-39.2-.2-61.5-75.5 26.8-162.5 26.8-238 0zM192 265c-4 0-7 3-7 7s3 7 7 7 7-3 7-7-3-7-7-7zm128 0c-4 0-7 3-7 7s3 7 7 7 7-3 7-7-3-7-7-7zm-89.9 48.4c9.1 8.4 17.6 13 25.2 13.6 7.6.5 15.7-2.4 26.2-13.3l13 12.6c-12.9 13.3-26.9 19.6-40.5 18.6-13.6-.9-25.4-8.4-36.1-18.3l12.2-13.2zm-177.31 7.4c.8 13.8 1.64 27.5 2.35 41.1L112 398.7c1.6-12.3 2.9-25.2 3.8-39-14.4-2.9-28.06-10.6-41.2-20.5-7.37-5.5-14.63-11.8-21.81-18.4zm405.91.5c-7 6.4-14.1 12.5-21.3 17.9-13.2 9.9-26.9 17.7-41.4 20.6.9 13.8 2.2 26.7 3.9 39l56.7-36.8c.6-13.3 1.4-27 2.1-40.7zm-220.5 38.6c.6 0 1.2 0 1.8.1 7.5.7 16 12 16 12s8.5-11.3 16-12c19.1-1.9 48 24 48 24s-40.1 32-64 32-64-32-64-32 27.1-24.3 46.2-24.1zm-104.4 2.3c-1.4 19.5-3.4 37.2-6.2 54.3H170c-7.3-7.6-14.1-16.2-20.2-25.5-5.8-8.9-11.2-18.6-16-28.8zm244.2.3c-4.7 10.2-10 19.7-15.8 28.5-6.1 9.3-12.9 17.9-20.2 25.5h42.2c-2.8-17-4.8-34.6-6.2-54zM56.16 384.1c.34 8.9.58 17.7.65 26.3l48.79 24.4c1.2-5.5 2.3-11 3.3-16.5l-52.74-34.2zm399.44.1l-52.7 34.2c1 5.5 2.1 11 3.3 16.4l48.8-24.4c.1-8.4.3-17.2.6-26.2zm-262.3 52.3c-3.7 15-9.7 30.1-20.9 45.1L161.6 496h188.8l-10.8-14.4c-11.2-15-17.2-30.1-20.9-45.1-18.9 13.1-40.1 20.5-62.7 20.5s-43.8-7.4-62.7-20.5z"/></svg>
\ No newline at end of file
diff --git a/pieces/Benedict/white_cleopatra.svg b/pieces/Benedict/white_cleopatra.svg
new file mode 100644 (file)
index 0000000..fd7f323
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 512px; width: 512px;"><path d="M0 0h512v512H0z" fill="#000" fill-opacity="1"></path><g class="" transform="translate(0,0)" style=""><path d="M247.6 17l-14.4 94.6 14.9 59.7c2.9 2.8 5.6 5.5 7 6.7.6.4.7.4.9.6.2-.2.3-.2.9-.6 1.4-1.2 4.1-3.9 7-6.7l14.9-59.7L264.4 17h-16.8zm-18.7 10.61c-36.1 6.78-71.8 26.1-101.4 49.45-5.7 4.49-11.1 9.14-16.3 13.88 34.4 3.96 70 6.44 105.9 7.49l11.8-70.82zm54.1.03l11.9 70.76c35.9-1.02 71.5-3.49 105.8-7.44-5.2-4.75-10.7-9.4-16.4-13.9-29.6-23.32-65.1-42.61-101.3-49.42zM94.81 107.1c-9.8 10.4-18.14 20.7-24.63 30.2 52.52 5.3 103.12 8.4 153.22 9.4l-7.6-30.3c-41.2-1.3-81.9-4.3-120.99-9.3zm322.19 0c-39 5-79.7 8-120.8 9.2l-7.6 30.4c50.1-1 100.6-4.1 153.1-9.4-6.5-9.4-14.8-19.8-24.7-30.2zM60.08 154.3c-1.43 2.9-2.58 5.6-3.44 8.1-7.98 40.7-7.5 86.3-5.27 132.1 11.55 11.4 22.95 22 34.03 30.3 11 8.2 21.6 14.1 31.5 16.7 1.9-39.3 2-86.5 2-149.5v-13.3l12.3 4.9c77.7 31.1 171.7 31.1 249.4 0l12.3-4.9V192c0 63 .1 110.3 2 149.5 10-2.6 20.6-8.4 31.7-16.7 10.9-8.2 22.1-18.6 33.5-29.8 2.5-50.6 3.3-99.3-4.8-132.4-.9-2.5-2-5.3-3.5-8.3-57.6 6.1-112.9 9.5-167.7 10.4l-4 15.9-1.7 1.8c-4 4-7.1 7.1-10.3 9.6-3.2 2.6-7.1 5-12.1 5s-8.9-2.4-12.1-5c-3.2-2.5-6.3-5.6-10.3-9.6l-1.7-1.8-4-15.9c-54.9-.9-110.2-4.3-167.82-10.4zm76.82 50.6c0 22.4 0 42.9-.2 61.8 8.7-12.8 18.2-21.2 28.4-25.6 5.1-2.3 10.4-3.4 15.6-3.7 1.3-.1 2.5-.1 3.8-.1 3.8.1 7.6.6 11.3 1.4 19.3 4.5 35.8 17.4 49 25.7l-9.6 15.2c-6-3.8-12.3-8-18.6-11.8.3 1.4.4 2.8.4 4.2 0 13.7-11.3 25-25 25s-25-11.3-25-25c0-5.2 1.6-10 4.4-14-6.2 2.8-12.9 8.5-19.9 19l-14.8-9.9c-.1 17.4-.4 33.5-.8 48.5 6.9 24.8 16.8 47.1 29 65.5C189 417.6 221.2 439 256 439s67-21.4 91.1-57.9c12.1-18.3 22-40.4 28.8-65-.4-15.1-.7-31.3-.8-48.8l-14.6 9.7c-7-10.5-13.7-16.2-19.9-19 2.8 4 4.4 8.8 4.4 14 0 13.7-11.3 25-25 25s-25-11.3-25-25c0-1.4.1-2.8.4-4.2-6.3 3.8-12.6 8-18.6 11.8l-9.6-15.2c13.2-8.3 29.7-21.2 49-25.7 3.7-.8 7.5-1.3 11.3-1.4 1.3 0 2.5 0 3.8.1 5.2.3 10.5 1.4 15.6 3.7 10.1 4.3 19.6 12.6 28.2 25.3-.2-18.8-.2-39.2-.2-61.5-75.5 26.8-162.5 26.8-238 0zM192 265c-4 0-7 3-7 7s3 7 7 7 7-3 7-7-3-7-7-7zm128 0c-4 0-7 3-7 7s3 7 7 7 7-3 7-7-3-7-7-7zm-89.9 48.4c9.1 8.4 17.6 13 25.2 13.6 7.6.5 15.7-2.4 26.2-13.3l13 12.6c-12.9 13.3-26.9 19.6-40.5 18.6-13.6-.9-25.4-8.4-36.1-18.3l12.2-13.2zm-177.31 7.4c.8 13.8 1.64 27.5 2.35 41.1L112 398.7c1.6-12.3 2.9-25.2 3.8-39-14.4-2.9-28.06-10.6-41.2-20.5-7.37-5.5-14.63-11.8-21.81-18.4zm405.91.5c-7 6.4-14.1 12.5-21.3 17.9-13.2 9.9-26.9 17.7-41.4 20.6.9 13.8 2.2 26.7 3.9 39l56.7-36.8c.6-13.3 1.4-27 2.1-40.7zm-220.5 38.6c.6 0 1.2 0 1.8.1 7.5.7 16 12 16 12s8.5-11.3 16-12c19.1-1.9 48 24 48 24s-40.1 32-64 32-64-32-64-32 27.1-24.3 46.2-24.1zm-104.4 2.3c-1.4 19.5-3.4 37.2-6.2 54.3H170c-7.3-7.6-14.1-16.2-20.2-25.5-5.8-8.9-11.2-18.6-16-28.8zm244.2.3c-4.7 10.2-10 19.7-15.8 28.5-6.1 9.3-12.9 17.9-20.2 25.5h42.2c-2.8-17-4.8-34.6-6.2-54zM56.16 384.1c.34 8.9.58 17.7.65 26.3l48.79 24.4c1.2-5.5 2.3-11 3.3-16.5l-52.74-34.2zm399.44.1l-52.7 34.2c1 5.5 2.1 11 3.3 16.4l48.8-24.4c.1-8.4.3-17.2.6-26.2zm-262.3 52.3c-3.7 15-9.7 30.1-20.9 45.1L161.6 496h188.8l-10.8-14.4c-11.2-15-17.2-30.1-20.9-45.1-18.9 13.1-40.1 20.5-62.7 20.5s-43.8-7.4-62.7-20.5z" fill="#fff" fill-opacity="1"></path></g></svg>
\ No newline at end of file
index 90e9244..59a69c0 100644 (file)
@@ -1,5 +1,4 @@
 const variants = [
-  // TODO: https://mancala.fandom.com/wiki/William_Daniel_Troyka Cleopatra chess
   {name: 'Absorption', desc: 'Absorb powers'},
   {name: 'Alapo', desc: 'Geometric Chess'},
 //  {name: 'Alice', desc: 'Both sides of the mirror'},
diff --git a/variants/Benedict/CREDITS b/variants/Benedict/CREDITS
new file mode 100644 (file)
index 0000000..e936f02
--- /dev/null
@@ -0,0 +1,4 @@
+Images:
+
+https://game-icons.net/1x1/delapouite/cleopatra.html
+https://www.svgrepo.com/svg/322047/cleopatra
index 81fee87..2bc60e7 100644 (file)
@@ -6,6 +6,14 @@ export default class BenedictRules extends ChessRules {
   static get Options() {
     return {
       select: C.Options.select,
+      input: [
+        {
+          label: "Cleopatra",
+          variable: "cleopatra",
+          type: "checkbox",
+          defaut: false
+        }
+      ],
       styles: [
         "balance",
         "cylinder",
@@ -25,6 +33,24 @@ export default class BenedictRules extends ChessRules {
     return false;
   }
 
+  pieces(color, x, y) {
+    if (!this.options["cleopatra"])
+      return super.pieces(color, x, y);
+    return Object.assign({}, super.pieces(color, x, y), {
+      'q': {
+        "class": "cleopatra",
+        moves: [
+          {
+            steps: [
+              [0, 1], [0, -1], [1, 0], [-1, 0],
+              [1, 1], [1, -1], [-1, 1], [-1, -1]
+            ]
+          }
+        ]
+      },
+    });
+  }
+
   // Find potential captures from a square
   // follow steps from x,y until something is met.
   findAttacks([x, y]) {
@@ -56,20 +82,22 @@ export default class BenedictRules extends ChessRules {
 
   postProcessPotentialMoves(moves) {
     moves.forEach(m => {
-      super.playOnBoard(m);
-      let attacks = this.findAttacks([m.end.x, m.end.y])
-      if (this.options["zen"]) {
-        let endSquares = {};
-        super.findCapturesOn([m.end.x, m.end.y], {zen: true}).forEach(c => {
-          endSquares[C.CoordsToSquare(c.end)] = true;
+      m.flips = [];
+      if (!this.options["cleopatra"] || m.vanish[0].p == 'q') {
+        super.playOnBoard(m);
+        let attacks = this.findAttacks([m.end.x, m.end.y])
+        if (this.options["zen"]) {
+          let endSquares = {};
+          super.findCapturesOn([m.end.x, m.end.y], {zen: true}).forEach(c => {
+            endSquares[C.CoordsToSquare(c.end)] = true;
+          });
+          Array.prototype.push.apply(attacks, Object.keys(endSquares));
+        }
+        super.undoOnBoard(m);
+        attacks.map(C.SquareToCoords).forEach(a => {
+          m.flips.push({x: a.x, y: a.y});
         });
-        Array.prototype.push.apply(attacks, Object.keys(endSquares));
       }
-      super.undoOnBoard(m);
-      m.flips = [];
-      attacks.map(C.SquareToCoords).forEach(a => {
-        m.flips.push({x: a.x, y: a.y});
-      });
     });
     return moves;
   }
index 1a21c0c..92f633e 100644 (file)
@@ -2,4 +2,12 @@
 
 <p>Goal: change the enemy king's color.</p>
 
+<p>
+  The "Cleopatra" option follow
+  <a href="https://www.chessvariants.com/difftaking.dir/cleopatra.html">
+    these rules
+  </a>
+  where only the queen can change the color of enemy pieces.
+</p>
+
 <p class="author">William Daniel Troyka (2001).</p>
index a3550bc..0923e9e 100644 (file)
@@ -1 +1,9 @@
 @import url("/base_pieces.css");
+
+piece.black.cleopatra {
+  background-image: url('/pieces/Benedict/black_cleopatra.svg');
+}
+
+piece.white.cleopatra {
+  background-image: url('/pieces/Benedict/white_cleopatra.svg');
+}