From 9a036f5fbfe3cc1df18b47e43d5db293de013e47 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 23 Jul 2022 19:00:21 +0200
Subject: [PATCH] Just save current state

---
 variants/Baroque/complete_rules.html | 190 +++++++++++++++++++++++++++
 variants/Baroque/rules.html          |  14 +-
 variants/Berolina/class.js           |  25 ++++
 3 files changed, 228 insertions(+), 1 deletion(-)
 create mode 100644 variants/Baroque/complete_rules.html
 create mode 100644 variants/Berolina/class.js

diff --git a/variants/Baroque/complete_rules.html b/variants/Baroque/complete_rules.html
new file mode 100644
index 0000000..1ac46cc
--- /dev/null
+++ b/variants/Baroque/complete_rules.html
@@ -0,0 +1,190 @@
+<html>
+<head>
+  <title>Baroque Rules</title>
+  <link href="/common.css" rel="stylesheet"/>
+  <link href="/variants/Baroque/style.css" rel="stylesheet"/>
+</head>
+<body>
+
+<div class="full-rules">
+<h1>Baroque Rules</h1>
+
+<div>
+  <h4>Pieces names</h4>
+  <p>Pieces names refer to the way they capture, which is described later.</p>
+  <ul>
+    <li>Pawn : Pawn or Pincer</li>
+    <li>Rook : Coordinator</li>
+    <li>Knight : Long Leaper</li>
+    <li>Bishop : Chameleon</li>
+    <li>Queen : Withdrawer</li>
+    <li>King : King (same behavior as in standard chess)</li>
+  </ul>
+  <p>
+    There is also a new piece : the immobilizer,
+    represented by an upside-down rook.
+  </p>
+  <figure>
+    <div class="diag"
+         data-fen='8/8/4m3/8/8/8/3M4/8 w 0'>
+    </div>
+    <figcaption>Immobilizers on d2 and e6.</figcaption>
+  </figure>
+</div>
+
+<div>
+  <h3>Non-capturing moves</h3>
+  <p>
+    Pawns move as orthodox rooks, and the king moves as usual,
+    one square in any direction.
+    All other pieces move like an orthodox queen.
+  </p>
+  <p>
+    When a piece is adjacent to an enemy immobilizer, it cannot move unless
+    the enemy immobilizer is adjacent to a friendly immobilizer or chameleon
+    (cancelling the powers of the opponent's immobilizer).
+  </p>
+  <p>
+    Note : this corresponds to the "pure rules" described on
+    <a href="http://www.inference.org.uk/mackay/ultima/ultima.html">
+      this page
+    </a>
+    , which slightly differ from the initial rules.
+    The aim is to get rid of the weird suicide rule by weakening the
+    immobilizers lock. In particular, in the original rules two adjacent
+    immobilizer are stuck forever until one is captured. Note that it's still
+    the case if all chameleons disappeared.
+  </p>
+</div>
+
+<div>
+  <h3>Capturing moves</h3>
+  <p>
+    Easy case first: the king captures as usual, by moving onto an adjacent
+    square occupied by an enemy piece. But this is the only piece following
+    orthodox rules, and also the only one which captures by moving onto an
+    occupied square. All other pieces capture passively: they land on a free
+    square and captured units are determined by some characteristics of the
+    movement.
+  </p>
+  <p>Note: the immobilizer does not capture.</p>
+
+  <h4>Pawns/Pincers</h4>
+  <p>
+    If at the end of its movement a pawn is horizontally or vertically adjacent
+    to an enemy piece, which itself is next to a friendly piece (in the same
+    direction), the "pinced" unit is removed from the board.
+  </p>
+  <figure>
+    <div class="diag"
+         data-fen='7k/5ppp/2N5/2n5/3rB3/8/PPP5/K7 w 0'>
+    </div>
+    <figcaption>1.Pc2c4 captures both coordinator and long leaper.</figcaption>
+  </figure>
+
+  <h4>Coordinators (rooks)</h4>
+  <p>
+    Imagine that rook and king of the same color are two corners of a rectangle
+    (this works if these two pieces are unaligned).
+    If at the end of a rook move an enemy piece stands in any of the two
+    remaining corners, it is captured.
+  </p>
+  <figure>
+    <div class="diag"
+         data-fen='8/2b4K/2q5/3p1N1p/8/8/2R5/k7 w 0'>
+    </div>
+    <figcaption>1.Rc5 captures on c7 and h5.</figcaption>
+  </figure>
+
+  <h4>Long leapers (knights)</h4>
+  <p>
+    A knight captures exactly as a queen in international draughts game: by
+    jumping over its enemies, as many times as it can/want but always in the
+    same direction. In this respect it is less powerful than a draughts' queen:
+    on the following diagram c8 or f6 cannot be captured.
+    However, the knight does not have to maximize the number of captured units
+    (as is the case in draughts).
+  </p>
+  <figure>
+    <div class="diag"
+         data-fen='2n4k/3r4/5b2/3p4/1m6/3b4/3N4/K7 w 0'
+         data-marks='d4,d6,d8,a5'>
+    </div>
+    <figcaption>All marked squares captures are playable from d2.</figcaption>
+  </figure>
+
+  <h4>Withdrawer (queen)</h4>
+  <p>
+    The queen captures by moving away from an adjacent enemy piece, in the
+    opposite direction (without jumping, the path must be free).
+  </p>
+  <figure>
+    <div class="diag"
+      data-fen="7k/8/8/3Qr3/8/8/8/K7 w 0"
+      data-marks="a5,b5,c5">
+    </div>
+    <figcaption>1.Qa5, 1.Qb5 or 1.Qc5 captures the black rook.</figcaption>
+  </figure>
+
+  <h4>Chameleon (bishop)</h4>
+  <p>The chameleon captures pieces in the way they would capture. So, it</p>
+  <ul>
+    <li>pinces pawns (if moving like a pawn),</li>
+    <li>withdraws from withdrawers,</li>
+    <li>leaps over long leapers,</li>
+    <li>coordinates coordinators.</li>
+  </ul>
+  <p>...and these captures can be combined.</p>
+  <p>
+    Remark: the move indicated on the diagram doesn't capture the black pincer
+    on e5, since it is a diagonal move (not like a pawn).
+  </p>
+  <figure>
+    <div class="diag"
+      data-fen="7k/8/8/r3pP2/2n5/8/B7/K7 w 0"
+      data-marks="a5,c4">
+    </div>
+    <figcaption>1.Bd5 captures the two marked pieces.</figcaption>
+  </figure>
+  <p>
+    Besides, chameleon immobilizes immobilizers (but cannot capture them since
+    they do not capture).
+  </p>
+  <p>
+    A chameleon captures the king in the same way the king captures, which
+    means that a chameleon adjacent to a king gives check.
+  </p>
+</div>
+
+<div>
+  <h3>End of the game</h3>
+  <p>
+    The game ends by checkmate or stalemate as in standard chess. Note however
+    that checks are more difficult to see, because of the exotic capturing
+    rules. For example, on the following diagram the white king cannot move to
+    e5 because then the black pawn could capture by moving next to it.
+  </p>
+  <figure>
+    <div class="diag"
+         data-fen="7k/8/8/p4r/4K3/8/8/8 w 0"
+         data-marks="e5">
+    </div>
+    <figcaption>1.Ke5 is impossible</figcaption>
+  </figure>
+</div>
+
+<div>
+  <h3>More information</h3>
+  <p>
+    The
+    <a href="https://en.wikipedia.org/wiki/Baroque_chess">Wikipedia page</a>
+    is a good starting point.
+  </p>
+</div>
+
+</div>
+
+</body>
+<script src="/utils/drawDiagrams.js"></script>
+<script>fenToDiag("Baroque");</script>
+</html>
diff --git a/variants/Baroque/rules.html b/variants/Baroque/rules.html
index c65158e..0e30307 100644
--- a/variants/Baroque/rules.html
+++ b/variants/Baroque/rules.html
@@ -1 +1,13 @@
-<p>TODO</p>
+<p>
+  Pawns move like rooks, and all other pieces move like a queen
+  (king excepted). Pieces (king excepted) capture in unusual ways:
+  please refer to the complete rules below.
+</p>
+
+<p>The goal is still to checkmate.</p>
+
+<a href="/variants/Baroque/complete_rules.html">
+  Full rules description.
+</a>
+
+<p class="author">Robert Abbott (1963).</p>
diff --git a/variants/Berolina/class.js b/variants/Berolina/class.js
new file mode 100644
index 0000000..fdca8fb
--- /dev/null
+++ b/variants/Berolina/class.js
@@ -0,0 +1,25 @@
+import ChessRules from "/base_rules.js";
+
+export default class BerolinaRules extends ChessRules {
+
+//TODO: Berolina pawns in Utils, also captures for Baroque+Fugue+...
+
+  pieces(color, x, y) {
+      const pawnShift = (color == "w" ? -1 : 1);
+      let res = super.pieces(color, x, y);
+      res['p'].moves = [
+        {
+          steps: [[pawnShift, 1], [pawnShift, -1]],
+          range: 1
+        }
+      ];
+      res['p'].attack = [
+        {
+          steps: [[pawnShift, 0]],
+          range: 1
+        }
+      ];
+      return res;
+    }
+
+};
-- 
2.44.0