From 1a8e3d26325eeffdebf3132408312f274234ce14 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 6 Mar 2021 20:17:59 +0100
Subject: [PATCH] Add Kar-Ouk

---
 client/src/translations/en.js               |  1 +
 client/src/translations/es.js               |  1 +
 client/src/translations/fr.js               |  1 +
 client/src/translations/rules/Karouk/en.pug | 12 ++++++++++++
 client/src/translations/rules/Karouk/es.pug | 12 ++++++++++++
 client/src/translations/rules/Karouk/fr.pug | 12 ++++++++++++
 client/src/translations/variants/en.pug     |  1 +
 client/src/translations/variants/es.pug     |  1 +
 client/src/translations/variants/fr.pug     |  1 +
 client/src/variants/Karouk.js               | 11 +++++++++++
 server/db/populate.sql                      |  1 +
 11 files changed, 54 insertions(+)
 create mode 100644 client/src/translations/rules/Karouk/en.pug
 create mode 100644 client/src/translations/rules/Karouk/es.pug
 create mode 100644 client/src/translations/rules/Karouk/fr.pug
 create mode 100644 client/src/variants/Karouk.js

diff --git a/client/src/translations/en.js b/client/src/translations/en.js
index acd3fdbc..502b8bb1 100644
--- a/client/src/translations/en.js
+++ b/client/src/translations/en.js
@@ -317,6 +317,7 @@ export const translations = {
   "Stun & kick pieces": "Stun & kick pieces",
   "Thai Chess (v1)": "Thai Chess (v1)",
   "Thai Chess (v2)": "Thai Chess (v2)",
+  "Thai Chess (v3)": "Thai Chess (v3)",
   "The colorbound clobberers": "The colorbound clobberers",
   "The end of the world": "The end of the world",
   "Transform an essay": "Transform an essay",
diff --git a/client/src/translations/es.js b/client/src/translations/es.js
index a648854a..7e39759e 100644
--- a/client/src/translations/es.js
+++ b/client/src/translations/es.js
@@ -316,6 +316,7 @@ export const translations = {
   "Stun & kick pieces": "Aturdir & patear piezas",
   "Thai Chess (v1)": "Ajedrez tailandés (v1)",
   "Thai Chess (v2)": "Ajedrez tailandés (v2)",
+  "Thai Chess (v3)": "Ajedrez tailandés (v3)",
   "The colorbound clobberers": "Los batidores unicolor",
   "The end of the world": "El fin del mundo",
   "Transform an essay": "Transformar un ensayo",
diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js
index 282117af..6d04f40b 100644
--- a/client/src/translations/fr.js
+++ b/client/src/translations/fr.js
@@ -316,6 +316,7 @@ export const translations = {
   "Stun & kick pieces": "Étourdissez & frappez les pièces",
   "Thai Chess (v1)": "Échecs thai (v1)",
   "Thai Chess (v2)": "Échecs thai (v2)",
+  "Thai Chess (v3)": "Échecs thai (v3)",
   "The colorbound clobberers": "Les tabasseurs unicolores",
   "The end of the world": "La fin du monde",
   "Transform an essay": "Transformer un essai",
diff --git a/client/src/translations/rules/Karouk/en.pug b/client/src/translations/rules/Karouk/en.pug
new file mode 100644
index 00000000..1486e0a1
--- /dev/null
+++ b/client/src/translations/rules/Karouk/en.pug
@@ -0,0 +1,12 @@
+p.boxed
+  | Makruk, but first check wins.
+
+p
+  | Everything goes as in 
+  a(href="/#/variants/Makruk") Makruk
+  | , but the first player giving check wins.
+
+p
+  | The variant is mentioned on 
+  a(href="https://www.chessvariants.com/link/kar-ouk") chessvariants.com
+  | .
diff --git a/client/src/translations/rules/Karouk/es.pug b/client/src/translations/rules/Karouk/es.pug
new file mode 100644
index 00000000..7fe39f32
--- /dev/null
+++ b/client/src/translations/rules/Karouk/es.pug
@@ -0,0 +1,12 @@
+p.boxed
+  | Makruk, pero el primer jaque gana.
+
+p
+  | Todo se desarrolla como en 
+  a(href="/#/variants/Makruk") Makruk
+  | , pero el primer jugador dando jaque señala el juego.
+
+p
+  | La variante se menciona en 
+  a(href="https://www.chessvariants.com/link/kar-ouk") chessvariants.com
+  | .
diff --git a/client/src/translations/rules/Karouk/fr.pug b/client/src/translations/rules/Karouk/fr.pug
new file mode 100644
index 00000000..62469e67
--- /dev/null
+++ b/client/src/translations/rules/Karouk/fr.pug
@@ -0,0 +1,12 @@
+p.boxed
+  | Makruk, mais le premier échec gagne.
+
+p
+  | Tout se déroule comme au 
+  a(href="/#/variants/Makruk") Makruk
+  | , mais le premier joueur donnant échec remporte la partie.
+
+p
+  | La variante est mentionnée sur 
+  a(href="https://www.chessvariants.com/link/kar-ouk") chessvariants.com
+  | .
diff --git a/client/src/translations/variants/en.pug b/client/src/translations/variants/en.pug
index dc9ce6e7..c380c427 100644
--- a/client/src/translations/variants/en.pug
+++ b/client/src/translations/variants/en.pug
@@ -348,6 +348,7 @@ p (Partial) Game evolution in time and space.
 -
   var varlist = [
     "Janggi",
+    "Karouk",
     "Makpong",
     "Makruk",
     "Minishogi",
diff --git a/client/src/translations/variants/es.pug b/client/src/translations/variants/es.pug
index d87eb234..6658c9b9 100644
--- a/client/src/translations/variants/es.pug
+++ b/client/src/translations/variants/es.pug
@@ -357,6 +357,7 @@ p Evolución (parcial) del juego en espacio y tiempo.
 -
   var varlist = [
     "Janggi",
+    "Karouk",
     "Makpong",
     "Makruk",
     "Minishogi",
diff --git a/client/src/translations/variants/fr.pug b/client/src/translations/variants/fr.pug
index 996f823f..7d7ab45b 100644
--- a/client/src/translations/variants/fr.pug
+++ b/client/src/translations/variants/fr.pug
@@ -356,6 +356,7 @@ p Évolution (partielle) du jeu dans l'espace et le temps.
 -
   var varlist = [
     "Janggi",
+    "Karouk",
     "Makpong",
     "Makruk",
     "Minishogi",
diff --git a/client/src/variants/Karouk.js b/client/src/variants/Karouk.js
new file mode 100644
index 00000000..05e55790
--- /dev/null
+++ b/client/src/variants/Karouk.js
@@ -0,0 +1,11 @@
+import { MakrukRules } from "@/variants/Makruk";
+
+export class KaroukRules extends MakrukRules {
+
+  getCurrentScore() {
+    const color = this.turn;
+    if (this.underCheck(color)) return (color == 'w' ? "0-1" : "1-0");
+    return super.getCurrentScore();
+  }
+
+};
diff --git a/server/db/populate.sql b/server/db/populate.sql
index 82600944..7603f1f1 100644
--- a/server/db/populate.sql
+++ b/server/db/populate.sql
@@ -87,6 +87,7 @@ insert or ignore into Variants (name, description) values
   ('Isardam', 'No paralyzed pieces'),
   ('Janggi', 'Korean Chess'),
   ('Joker', 'Replace pieces'),
+  ('Karouk', 'Thai chess (v3)'),
   ('Kinglet', 'Protect your pawns'),
   ('Kingsmaker', 'Promote into kings'),
   ('Knightmate', 'Mate the knight'),
-- 
2.44.0