Complete Antiking, add Antimatter
authorBenjamin Auder <benjamin.auder@somewhere>
Thu, 30 Jun 2022 19:44:24 +0000 (21:44 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Thu, 30 Jun 2022 19:44:24 +0000 (21:44 +0200)
variants.js
variants/Antimatter/class.js [new file with mode: 0644]
variants/Antimatter/rules.html [new file with mode: 0644]
variants/Antimatter/style.css [new file with mode: 0644]
variants/_Antiking/class.js
variants/_Antiking/rules.html

index 3705c59..4108165 100644 (file)
@@ -7,7 +7,7 @@ const variants = [
   {name: 'Ambiguous', desc: "Play opponent's pieces"},
   {name: 'Antiking1', desc: 'Keep antiking in check', disp: 'Anti-King I'},
   {name: 'Antiking2', desc: 'Keep antiking in check', disp: 'Anti-King II'},
-//  {name: 'Antimatter', desc: 'Dangerous collisions'},
+  {name: 'Antimatter', desc: 'Dangerous collisions'},
 //  {name: 'Apocalypse', desc: 'The end of the world'},
 //  {name: 'Arena', desc: 'Middle battle'},
 //  {name: 'Atarigo', desc: 'First capture wins', disp: 'Atari-Go'},
diff --git a/variants/Antimatter/class.js b/variants/Antimatter/class.js
new file mode 100644 (file)
index 0000000..b71abf7
--- /dev/null
@@ -0,0 +1,29 @@
+import ChessRules from "/base_rules.js";
+
+export default class AntimatterRules extends ChessRules {
+
+  static get Options() {
+    return {
+      select: C.Options.select,
+      input: C.Options.input,
+      styles: C.Options.styles.filter(s => !["atomic", "madrasi"].includes(s))
+    };
+  }
+
+  getPotentialMovesFrom([x, y]) {
+    let moves = super.getPotentialMovesFrom([x, y]);
+    // Handle "matter collisions"
+    moves.forEach(m => {
+      if (
+        m.vanish.length == 2 &&
+        m.appear.length == 1 &&
+        m.vanish[0].p == m.vanish[1].p &&
+        m.vanish[0].c != m.vanish[1].c //for Recycle & Teleport
+      ) {
+        m.appear.pop();
+      }
+    });
+    return moves;
+  }
+
+};
diff --git a/variants/Antimatter/rules.html b/variants/Antimatter/rules.html
new file mode 100644 (file)
index 0000000..78d8f29
--- /dev/null
@@ -0,0 +1,3 @@
+<p>If a piece captures one of the same kind, both disappear.</p>
+
+<p class="author">Claudio Martins Jaguaribe (2010).</p>
diff --git a/variants/Antimatter/style.css b/variants/Antimatter/style.css
new file mode 100644 (file)
index 0000000..a3550bc
--- /dev/null
@@ -0,0 +1 @@
+@import url("/base_pieces.css");
index e92edab..8e2173a 100644 (file)
@@ -26,17 +26,9 @@ export default class AbstractAntikingRules extends ChessRules {
   }
 
   pieces(color, x, y) {
-    return Object.assign(
-      {
-        'a': {
-          // Move like a king, no attacks
-          "class": "antiking",
-          moves: super.pieces(color, x, y)['k'].moves,
-          attack: []
-        }
-      },
-      super.pieces(color, x, y)
-    );
+    let antikingSpec = super.pieces(color, x, y)['k'];
+    antikingSpec["class"] = "antiking";
+    return Object.assign({'a': antikingSpec}, super.pieces(color, x, y));
   }
 
   isKing(x, y, p) {
index fee723a..e850c5e 100644 (file)
@@ -1 +1,25 @@
-https://www.chessvariants.com/diffobjective.dir/anti-king-chess.html
+<p>
+  The antiking (represented by an upside-down king)
+  must always remain under attack.
+  It can capture pieces of its color.
+</p>
+
+<p>
+  Win by checkmating the king, or anti-mating the antiking &mdash; that is to
+  say, making it unable to move to an attacked square.
+</p>
+
+<p>In Anti-King I,</p>
+<ul>
+  <li>Pawns are Berolina: they move diagonally and capture vertically.</li>
+  <li>
+    King and Antiking can play one non-capturing knight move,
+    as long as they never moved earlier.
+  </li>
+</ul>
+
+<a href="https://www.chessvariants.com/diffobjective.dir/anti-king-chess.html">
+  chessvariants page.
+</a>
+
+<p class="author">Peter Aronson (2002).</p>