From b2b5a72927ce977f96569b78126165b60f23f039 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Mon, 20 Jul 2020 18:41:54 +0200
Subject: [PATCH] Add Vchess variant (draft)

---
 client/src/translations/en.js               |  1 +
 client/src/translations/es.js               |  3 ++-
 client/src/translations/fr.js               |  1 +
 client/src/translations/rules/Vchess/en.pug | 21 ++++++++++++++++++++
 client/src/translations/rules/Vchess/es.pug | 22 +++++++++++++++++++++
 client/src/translations/rules/Vchess/fr.pug | 22 +++++++++++++++++++++
 client/src/variants/Vchess.js               | 11 ++++++++++-
 server/db/populate.sql                      |  1 +
 8 files changed, 80 insertions(+), 2 deletions(-)
 create mode 100644 client/src/translations/rules/Vchess/en.pug
 create mode 100644 client/src/translations/rules/Vchess/es.pug
 create mode 100644 client/src/translations/rules/Vchess/fr.pug

diff --git a/client/src/translations/en.js b/client/src/translations/en.js
index e088adfb..f3682cc1 100644
--- a/client/src/translations/en.js
+++ b/client/src/translations/en.js
@@ -234,6 +234,7 @@ export const translations = {
   "Non-conformism and utopia": "Non-conformism and utopia",
   "Occupy the enemy palace": "Occupy the enemy palace",
   "Paralyzed pieces": "Paralyzed pieces",
+  "Pawns capture backward": "Pawns capture backward",
   "Pawns move diagonally": "Pawns move diagonally",
   "Pieces upside down": "Pieces upside down",
   "Play at the same time": "Play at the same time",
diff --git a/client/src/translations/es.js b/client/src/translations/es.js
index 605f5015..0dafd6e9 100644
--- a/client/src/translations/es.js
+++ b/client/src/translations/es.js
@@ -234,7 +234,8 @@ export const translations = {
   "Non-conformism and utopia": "No-conformismo y utopía",
   "Occupy the enemy palace": "Ocupar el palacio enemigo",
   "Paralyzed pieces": "Piezas paralizadas",
-  "Pawns move diagonally": "Peones se mueven en diagonal",
+  "Pawns capture backward": "Los peones capturan hacia atrás",
+  "Pawns move diagonally": "Los peones se mueven en diagonal",
   "Pieces upside down": "Piezas al revés",
   "Play at the same time": "Jugar al mismo tiempo",
   "Play more and more moves (v1)": "Jugar más y más movimientos (v1)",
diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js
index a35c4ca4..3a38c66c 100644
--- a/client/src/translations/fr.js
+++ b/client/src/translations/fr.js
@@ -234,6 +234,7 @@ export const translations = {
   "Non-conformism and utopia": "Non-conformisme et utopie",
   "Occupy the enemy palace": "Occuper le palais ennemi",
   "Paralyzed pieces": "Pièces paralysées",
+  "Pawns capture backward": "Les pions capturent en arrière",
   "Pawns move diagonally": "Les pions vont en diagonale",
   "Pieces upside down": "Pièces à l'envers",
   "Play at the same time": "Jouer en même temps",
diff --git a/client/src/translations/rules/Vchess/en.pug b/client/src/translations/rules/Vchess/en.pug
new file mode 100644
index 00000000..2480abd2
--- /dev/null
+++ b/client/src/translations/rules/Vchess/en.pug
@@ -0,0 +1,21 @@
+p.boxed
+  | Pawns can capture backward.
+
+p.
+  Orthodox chess, with enhanced pawns: they can capture forward as usual,
+  and also bacwkard - always by one diagonal step.
+
+figure.diagram-container
+  .diagram
+    | fen:k7/2B5/3p4/2p1p3/2P1P3/3P1N2/8/K7:
+  figcaption The bishop and the knight are under attack.
+
+h3 Source
+
+p
+  | This seems to be an original idea of José Victor Gonçalves, thus the name
+  | "Victor-Chess", abridged into Vchess.
+  | Some other variants with different pawn movements are listed 
+  a(href="https://www.chessvariants.com/other.dir/modest-pawn.html")
+    | on this page
+  | .
diff --git a/client/src/translations/rules/Vchess/es.pug b/client/src/translations/rules/Vchess/es.pug
new file mode 100644
index 00000000..93e7d347
--- /dev/null
+++ b/client/src/translations/rules/Vchess/es.pug
@@ -0,0 +1,22 @@
+p.boxed
+  | Los peones pueden capturar hacia atrás.
+
+p.
+  Se aplican reglas ortodoxas, con peones aumentados: pueden capturar hacia
+  adelante como de costumbre, pero también hacia atrás -
+  siempre con un paso diagonal.
+
+figure.diagram-container
+  .diagram
+    | fen:k7/2B5/3p4/2p1p3/2P1P3/3P1N2/8/K7:
+  figcaption El alfil y el caballo son atacados.
+
+h3 Fuente
+
+p
+  | Esta parece ser una idea original de José Victor Gonçalves, de ahí el
+  | nombre "Victor-Chess", abreviado como Vchess. Algunas otras variantes con
+  | diferentes movimientos de peones se enumeran 
+  a(href="https://www.chessvariants.com/other.dir/modest-pawn.html")
+    | en esta página
+  | .
diff --git a/client/src/translations/rules/Vchess/fr.pug b/client/src/translations/rules/Vchess/fr.pug
new file mode 100644
index 00000000..2660509e
--- /dev/null
+++ b/client/src/translations/rules/Vchess/fr.pug
@@ -0,0 +1,22 @@
+p.boxed
+  | Les pions peuvent capturer en arrière.
+
+p.
+  Les règles orthodoxes s'appliquent, avec des pions augmentés : ils peuvent
+  capturer vers l'avant comme d'habitude, mais aussi en arrière -
+  toujours d'un pas diagonal.
+
+figure.diagram-container
+  .diagram
+    | fen:k7/2B5/3p4/2p1p3/2P1P3/3P1N2/8/K7:
+  figcaption Le fou et le cavalier sont attaqués.
+
+h3 Source
+
+p
+  | Cela semble être une idée originale de José Victor Gonçalves, d'où le nom
+  | "Victor-Chess", abrégé en Vchess. Quelques autres variantes avec
+  | différents déplacements de pions sont listées 
+  a(href="https://www.chessvariants.com/other.dir/modest-pawn.html")
+    | sur cette page
+  | .
diff --git a/client/src/variants/Vchess.js b/client/src/variants/Vchess.js
index 4e84eb0e..8b59c863 100644
--- a/client/src/variants/Vchess.js
+++ b/client/src/variants/Vchess.js
@@ -11,7 +11,16 @@ export class VchessRules extends ChessRules {
 
   getNotation(move) {
     let notation = super.getNotation(move);
-    // TODO: if capture backwards, add an indication 'b'
+    // If pawn captures backward, add an indication 'b'
+    if (
+      move.appear[0].p == V.PAWN &&
+      (
+        (move.appear[0].c == 'w' && (move.end.x - move.start.x > 0)) ||
+        (move.appear[0].c == 'b' && (move.end.x - move.start.x < 0))
+      )
+    ) {
+      notation += 'b';
+    }
     return notation;
   }
 };
diff --git a/server/db/populate.sql b/server/db/populate.sql
index 1543847e..8de63af6 100644
--- a/server/db/populate.sql
+++ b/server/db/populate.sql
@@ -111,6 +111,7 @@ insert or ignore into Variants (name, description) values
   ('Threechecks', 'Give three checks'),
   ('Twokings', 'Two kings'),
   ('Upsidedown', 'Board upside down'),
+  ('Vchess', 'Pawns capture backward'),
   ('Wildebeest', 'Balanced sliders & leapers'),
   ('Wormhole', 'Squares disappear'),
   ('Zen', 'Reverse captures');
-- 
2.44.0