Fix incheck in BaseGame, draft Antimatter variant
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 22 Feb 2020 12:51:46 +0000 (13:51 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 22 Feb 2020 12:51:46 +0000 (13:51 +0100)
13 files changed:
client/src/components/BaseGame.vue
client/src/translations/en.js
client/src/translations/es.js
client/src/translations/fr.js
client/src/translations/rules/Antimatter/en.pug [new file with mode: 0644]
client/src/translations/rules/Antimatter/es.pug [new file with mode: 0644]
client/src/translations/rules/Antimatter/fr.pug [new file with mode: 0644]
client/src/translations/rules/Benedict/en.pug
client/src/translations/rules/Benedict/es.pug
client/src/translations/rules/Benedict/fr.pug
client/src/variants/Antimatter.js [new file with mode: 0644]
client/src/variants/Atomic.js
server/db/populate.sql

index c52f94c..42fe189 100644 (file)
@@ -393,6 +393,7 @@ export default {
       this.vr.re_init(this.moves[index].fen);
       this.cursor = index;
       this.lastMove = this.moves[index];
       this.vr.re_init(this.moves[index].fen);
       this.cursor = index;
       this.lastMove = this.moves[index];
+      this.incheck = this.vr.getCheckSquares(this.vr.turn);
     },
     gotoBegin: function() {
       if (this.cursor == -1) return;
     },
     gotoBegin: function() {
       if (this.cursor == -1) return;
@@ -404,6 +405,7 @@ export default {
         this.cursor = -1;
         this.lastMove = null;
       }
         this.cursor = -1;
         this.lastMove = null;
       }
+      this.incheck = this.vr.getCheckSquares(this.vr.turn);
     },
     gotoEnd: function() {
       if (this.cursor == this.moves.length - 1) return;
     },
     gotoEnd: function() {
       if (this.cursor == this.moves.length - 1) return;
index 64ff2b0..df3b1d2 100644 (file)
@@ -132,6 +132,7 @@ export const translations = {
   "Capture all of a kind": "Capture all of a kind",
   "Captures reborn": "Captures reborn",
   "Change colors": "Change colors",
   "Capture all of a kind": "Capture all of a kind",
   "Captures reborn": "Captures reborn",
   "Change colors": "Change colors",
+  "Dangerous collisions": "Dangerous collisions",
   "Exchange pieces positions": "Exchange pieces positions",
   "Exotic captures": "Exotic captures",
   "Explosive captures": "Explosive captures",
   "Exchange pieces positions": "Exchange pieces positions",
   "Exotic captures": "Exotic captures",
   "Explosive captures": "Explosive captures",
index 760e644..5588cbb 100644 (file)
@@ -132,6 +132,7 @@ export const translations = {
   "Capture all of a kind": "Capturar todo del mismo tipo",
   "Captures reborn": "Las capturas renacen",
   "Change colors": "Cambiar colores",
   "Capture all of a kind": "Capturar todo del mismo tipo",
   "Captures reborn": "Las capturas renacen",
   "Change colors": "Cambiar colores",
+  "Dangerous collisions": "Colisiones peligrosas",
   "Exchange pieces positions": "Intercambiar las posiciones de las piezas",
   "Exotic captures": "Capturas exóticas",
   "Explosive captures": "Capturas explosivas",
   "Exchange pieces positions": "Intercambiar las posiciones de las piezas",
   "Exotic captures": "Capturas exóticas",
   "Explosive captures": "Capturas explosivas",
index b690674..ed302ba 100644 (file)
@@ -132,6 +132,7 @@ export const translations = {
   "Capture all of a kind": "Capturez tout d'un même type",
   "Captures reborn": "Les captures renaissent",
   "Change colors": "Changer les couleurs",
   "Capture all of a kind": "Capturez tout d'un même type",
   "Captures reborn": "Les captures renaissent",
   "Change colors": "Changer les couleurs",
+  "Dangerous collisions": "Collisions dangeureuses",
   "Exchange pieces positions": "Échangez les positions des pièces",
   "Exotic captures": "Captures exotiques",
   "Explosive captures": "Captures explosives",
   "Exchange pieces positions": "Échangez les positions des pièces",
   "Exotic captures": "Captures exotiques",
   "Explosive captures": "Captures explosives",
diff --git a/client/src/translations/rules/Antimatter/en.pug b/client/src/translations/rules/Antimatter/en.pug
new file mode 100644 (file)
index 0000000..3c8e333
--- /dev/null
@@ -0,0 +1,24 @@
+p.boxed
+  | If a piece captures one of the same kind, both disappear.
+
+p.
+  The defensive power of pawns is thus increased, because they don't fear
+  captures (by other pawns).
+
+p.
+  Endings are also affected quite a lot, and sometimes new threats occur:
+  on the diagram, 3.Bxg7 wins a pawn because 3...Bxg7 would make both
+  bishops disappear.
+
+figure.diagram-container
+  .diagram
+    | fen:r1bqkbnr/pp1ppppp/2n5/2p5/8/1P6/PBPPPPPP/RN1QKBNR:
+  figcaption After 1.b3 c5 2.Bb2 Nc6
+
+p This detail excepted, the orthodox chess rules apply.
+
+h3 Source
+
+p
+  a(href="https://www.chessvariants.com/rules/antimatter-chess") Antimatter chess
+  | &nbsp;on chessvariants.com.
diff --git a/client/src/translations/rules/Antimatter/es.pug b/client/src/translations/rules/Antimatter/es.pug
new file mode 100644 (file)
index 0000000..60cf1ec
--- /dev/null
@@ -0,0 +1,25 @@
+p.boxed
+  | Si una pieza captura otra del mismo tipo, las dos desaparecen.
+
+p.
+  El poder defensivo de los peones aumenta así, ya que no temen
+  más capturas (por otros peones).
+
+p.
+  Las finales también se ven muy afectadas y, a veces, nuevas amenazas
+  ocurren: en el diagrama, 3.Bxg7 gana un peón porque 3...Bxg7 causaría
+  la desaparición de los dos alfiles.
+
+figure.diagram-container
+  .diagram
+    | fen:r1bqkbnr/pp1ppppp/2n5/2p5/8/1P6/PBPPPPPP/RN1QKBNR:
+  figcaption Después de 1.b3 c5 2.Bb2 Nc6
+
+p Excepto por este detalle, se aplican las reglas del ajedrez ortodoxo.
+
+h3 Fuente
+
+p
+  | La 
+  a(href="https://www.chessvariants.com/rules/antimatter-chess") variante Antimateria
+  | &nbsp;en chessvariants.com.
diff --git a/client/src/translations/rules/Antimatter/fr.pug b/client/src/translations/rules/Antimatter/fr.pug
new file mode 100644 (file)
index 0000000..1e2dbee
--- /dev/null
@@ -0,0 +1,25 @@
+p.boxed
+  | Si une pièce en capture une autre du même type, les deux disparaissent.
+
+p.
+  Le pouvoir défensif des pions est ainsi augmenté, puisqu'ils ne craignent
+  plus les captures (par d'autres pions).
+
+p.
+  Les finales sont aussi beaucoup affectées, et parfois de nouvelles menaces
+  surviennent : sur le diagramme, 3.Bxg7 gagne un pion car 3...Bxg7 provoquerait
+  la disparition des deux fous.
+
+figure.diagram-container
+  .diagram
+    | fen:r1bqkbnr/pp1ppppp/2n5/2p5/8/1P6/PBPPPPPP/RN1QKBNR:
+  figcaption After 1.b3 c5 2.Bb2 Nc6
+
+p Ce détail excepté, les règles des échecs orthodoxes s'appliquent.
+
+h3 Source
+
+p
+  | La 
+  a(href="https://www.chessvariants.com/rules/antimatter-chess") variante Antimatière
+  | &nbsp;sur chessvariants.com.
index 9f6da6f..856f341 100644 (file)
@@ -6,6 +6,8 @@ p.
   They change side, until the opponent in turn can attack them.
   There are no captures: only color changes.
 
   They change side, until the opponent in turn can attack them.
   There are no captures: only color changes.
 
+p Castling is possible, and flips pieces attacked by the king or rook.
+
 figure.diagram-container
   .diagram
     | fen:r1bqkbnr/ppPpPppp/2n5/3N4/8/8/PPPPPPPP/R1BQKBNR:
 figure.diagram-container
   .diagram
     | fen:r1bqkbnr/ppPpPppp/2n5/3N4/8/8/PPPPPPPP/R1BQKBNR:
index 439d5da..01c50ed 100644 (file)
@@ -2,6 +2,13 @@ p.boxed
   | Las piezas atacadas cambian de color después de cada turno.
   | El objetivo es cambiar el color del rey.
 
   | Las piezas atacadas cambian de color después de cada turno.
   | El objetivo es cambiar el color del rey.
 
+p.
+  Más precisamente, solo las piezas atacadas por la unidad móvil se voltean.
+  Cambian de lado, hasta que el oponente a su vez puede atacarlos.
+  No hay capturas: solo cambios de color.
+
+p El enroque es posible y cambia tanto las piezas atacadas por el rey como la torre.
+
 figure.diagram-container
   .diagram
     | fen:r1bqkbnr/ppPpPppp/2n5/3N4/8/8/PPPPPPPP/R1BQKBNR:
 figure.diagram-container
   .diagram
     | fen:r1bqkbnr/ppPpPppp/2n5/3N4/8/8/PPPPPPPP/R1BQKBNR:
index 542a189..cffef96 100644 (file)
@@ -2,6 +2,13 @@ p.boxed
   | Les pièces attaquées changent de couleur après chaque tour.
   | Le but est de changer la couleur du roi.
 
   | Les pièces attaquées changent de couleur après chaque tour.
   | Le but est de changer la couleur du roi.
 
+p.
+  Plus précisément, seules les pièces attaquées par le coup courant sont modifiées.
+  Elles changent de couleur, jusqu'à ce que l'adversaire au trait puisse les attaquer.
+  Il n'y a pas de captures : seulement des changements de couleur.
+
+p Le roque est possible, et change à la fois les pièces attaquées par le roi et la tour.
+
 figure.diagram-container
   .diagram
     | fen:r1bqkbnr/ppPpPppp/2n5/3N4/8/8/PPPPPPPP/R1BQKBNR:
 figure.diagram-container
   .diagram
     | fen:r1bqkbnr/ppPpPppp/2n5/3N4/8/8/PPPPPPPP/R1BQKBNR:
diff --git a/client/src/variants/Antimatter.js b/client/src/variants/Antimatter.js
new file mode 100644 (file)
index 0000000..63d5ae5
--- /dev/null
@@ -0,0 +1,20 @@
+import { ChessRules } from "@/base_rules";
+
+export const VariantRules = class AntimatterRules extends ChessRules {
+  getPotentialMovesFrom([x, y]) {
+    let moves = super.getPotentialMovesFrom([x, y]);
+
+    // Handle "matter collisions"
+    moves.forEach(m => {
+      if (
+        m.vanish.length > 1 &&
+        m.appear.length <= 1 &&
+        m.vanish[0].p == m.vanish[1].p
+      ) {
+        m.appear.pop();
+      }
+    });
+
+    return moves;
+  }
+};
index 996f2d1..2fcb5a6 100644 (file)
@@ -6,9 +6,9 @@ export const VariantRules = class AtomicRules extends ChessRules {
 
     // Handle explosions
     moves.forEach(m => {
 
     // Handle explosions
     moves.forEach(m => {
+      // NOTE: if vanish.length==2 and appear.length==2, this is castle
       if (m.vanish.length > 1 && m.appear.length <= 1) {
       if (m.vanish.length > 1 && m.appear.length <= 1) {
-        //avoid castles
-        // Explosion! OPTION (TODO?): drop moves which explode our king here
+        // Explosion! (TODO?: drop moves which explode our king here)
         let steps = [
           [-1, -1],
           [-1, 0],
         let steps = [
           [-1, -1],
           [-1, 0],
index 34d0f44..3fea093 100644 (file)
@@ -3,6 +3,7 @@
 insert or ignore into Variants (name,description) values
   ('Alice', 'Both sides of the mirror'),
   ('Antiking', 'Keep antiking in check'),
 insert or ignore into Variants (name,description) values
   ('Alice', 'Both sides of the mirror'),
   ('Antiking', 'Keep antiking in check'),
+  ('Antimatter', 'Dangerous collisions'),
   ('Atomic', 'Explosive captures'),
   ('Baroque', 'Exotic captures'),
   ('Benedict', 'Change colors'),
   ('Atomic', 'Explosive captures'),
   ('Baroque', 'Exotic captures'),
   ('Benedict', 'Change colors'),