From: Benjamin Auder Date: Fri, 22 Jan 2021 00:56:05 +0000 (+0100) Subject: Add Wormhole1 + ranem Wormhole --> Wormhole2. Rename Selfabsorption (too long) into... X-Git-Url: https://git.auder.net/images/assets/doc/current/app_dev.php?a=commitdiff_plain;h=1943de6b9d55716dac4ef8b5672bed803d8d43f9;p=vchess.git Add Wormhole1 + ranem Wormhole --> Wormhole2. Rename Selfabsorption (too long) into Selfabsorb --- diff --git a/client/public/images/pieces/Wormhole/bc.svg b/client/public/images/pieces/Wormhole/bc.svg new file mode 120000 index 00000000..72fcf2c6 --- /dev/null +++ b/client/public/images/pieces/Wormhole/bc.svg @@ -0,0 +1 @@ +../Omega/bc.svg \ No newline at end of file diff --git a/client/public/images/pieces/Wormhole/bm.svg b/client/public/images/pieces/Wormhole/bm.svg new file mode 120000 index 00000000..000f539e --- /dev/null +++ b/client/public/images/pieces/Wormhole/bm.svg @@ -0,0 +1 @@ +../Maxima/bg.svg \ No newline at end of file diff --git a/client/public/images/pieces/Wormhole/bw.svg b/client/public/images/pieces/Wormhole/bw.svg new file mode 120000 index 00000000..0c3782e8 --- /dev/null +++ b/client/public/images/pieces/Wormhole/bw.svg @@ -0,0 +1 @@ +../Omega/bw.svg \ No newline at end of file diff --git a/client/public/images/pieces/Wormhole/wc.svg b/client/public/images/pieces/Wormhole/wc.svg new file mode 120000 index 00000000..c6fc3f5e --- /dev/null +++ b/client/public/images/pieces/Wormhole/wc.svg @@ -0,0 +1 @@ +../Omega/wc.svg \ No newline at end of file diff --git a/client/public/images/pieces/Wormhole/wm.svg b/client/public/images/pieces/Wormhole/wm.svg new file mode 120000 index 00000000..436f84d6 --- /dev/null +++ b/client/public/images/pieces/Wormhole/wm.svg @@ -0,0 +1 @@ +../Maxima/wg.svg \ No newline at end of file diff --git a/client/public/images/pieces/Wormhole/ww.svg b/client/public/images/pieces/Wormhole/ww.svg new file mode 120000 index 00000000..d1ff6264 --- /dev/null +++ b/client/public/images/pieces/Wormhole/ww.svg @@ -0,0 +1 @@ +../Omega/ww.svg \ No newline at end of file diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 176741dc..7bf8e720 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -304,7 +304,8 @@ export const translations = { "Shogi 5 x 5": "Shogi 5 x 5", "Shoot pieces": "Shoot pieces", "Spartan versus Persians": "Spartan versus Persians", - "Squares disappear": "Squares disappear", + "Squares disappear (v1)": "Squares disappear (v1)", + "Squares disappear (v2)": "Squares disappear (v2)", "Squat last rank (v1)": "Squat last rank (v1)", "Squat last rank (v2)": "Squat last rank (v2)", "Stacking Checkers variant": "Stacking Checkers variant", diff --git a/client/src/translations/rules/Avalanche/en.pug b/client/src/translations/rules/Avalanche/en.pug index 8469d057..8321559c 100644 --- a/client/src/translations/rules/Avalanche/en.pug +++ b/client/src/translations/rules/Avalanche/en.pug @@ -32,3 +32,5 @@ p a(href="https://www.chessvariants.com/mvopponent.dir/avalanche.html") | Avalanche Chess |  on chessvariants.com. + +p Inventor: Ralph Betza (1977) diff --git a/client/src/translations/rules/Avalanche/es.pug b/client/src/translations/rules/Avalanche/es.pug index 00ccc05a..046449dd 100644 --- a/client/src/translations/rules/Avalanche/es.pug +++ b/client/src/translations/rules/Avalanche/es.pug @@ -35,3 +35,5 @@ p a(href="https://www.chessvariants.com/mvopponent.dir/avalanche.html") | Avalanche Chess |  en chessvariants.com. + +p Inventor: Ralph Betza (1977) diff --git a/client/src/translations/rules/Avalanche/fr.pug b/client/src/translations/rules/Avalanche/fr.pug index 652df0fe..e70fe790 100644 --- a/client/src/translations/rules/Avalanche/fr.pug +++ b/client/src/translations/rules/Avalanche/fr.pug @@ -34,3 +34,5 @@ p a(href="https://www.chessvariants.com/mvopponent.dir/avalanche.html") | Avalanche Chess |  sur chessvariants.com. + +p Inventeur : Ralph Betza (1977) diff --git a/client/src/translations/rules/Brotherhood/en.pug b/client/src/translations/rules/Brotherhood/en.pug index ba4971bf..7b96b7d3 100644 --- a/client/src/translations/rules/Brotherhood/en.pug +++ b/client/src/translations/rules/Brotherhood/en.pug @@ -14,3 +14,5 @@ p a(href="https://www.chessvariants.com/difftaking.dir/brotherhood.html") | Brotherhood Chess |  on chessvariants.com. + +p Inventor: Gianluca Vecchi (1993) diff --git a/client/src/translations/rules/Brotherhood/es.pug b/client/src/translations/rules/Brotherhood/es.pug index b04f4a13..752e736a 100644 --- a/client/src/translations/rules/Brotherhood/es.pug +++ b/client/src/translations/rules/Brotherhood/es.pug @@ -14,3 +14,5 @@ p a(href="https://www.chessvariants.com/difftaking.dir/brotherhood.html") | Brotherhood Chess |  en chessvariants.com. + +p Inventor: Gianluca Vecchi (1993) diff --git a/client/src/translations/rules/Brotherhood/fr.pug b/client/src/translations/rules/Brotherhood/fr.pug index 4565643e..aa80f0ad 100644 --- a/client/src/translations/rules/Brotherhood/fr.pug +++ b/client/src/translations/rules/Brotherhood/fr.pug @@ -14,3 +14,5 @@ p a(href="https://www.chessvariants.com/difftaking.dir/brotherhood.html") | Brotherhood Chess |  sur chessvariants.com. + +p Inventeur : Gianluca Vecchi (1993) diff --git a/client/src/translations/rules/Hidden/en.pug b/client/src/translations/rules/Hidden/en.pug index f1a24b3b..e67441c1 100644 --- a/client/src/translations/rules/Hidden/en.pug +++ b/client/src/translations/rules/Hidden/en.pug @@ -33,4 +33,4 @@ p a(href="https://www.chessvariants.com/rules/strate-go-chess") Strate-Go chess |  on chessvariants.com. -p Inventor: John Lewis (2005) +p Inventor: John Kipling Lewis (2005) diff --git a/client/src/translations/rules/Hidden/es.pug b/client/src/translations/rules/Hidden/es.pug index d11369e2..703b31ee 100644 --- a/client/src/translations/rules/Hidden/es.pug +++ b/client/src/translations/rules/Hidden/es.pug @@ -37,4 +37,4 @@ p | variante Strate-Go |  en chessvariants.com. -p Inventor: John Lewis (2005) +p Inventor: John Kipling Lewis (2005) diff --git a/client/src/translations/rules/Hidden/fr.pug b/client/src/translations/rules/Hidden/fr.pug index b822b728..28753b8f 100644 --- a/client/src/translations/rules/Hidden/fr.pug +++ b/client/src/translations/rules/Hidden/fr.pug @@ -37,4 +37,4 @@ p | variante Strate-Go |  sur chessvariants.com. -p Inventeur : John Lewis (2005) +p Inventeur : John Kipling Lewis (2005) diff --git a/client/src/translations/rules/Pawnsking/en.pug b/client/src/translations/rules/Pawnsking/en.pug index 1c239514..74df57d1 100644 --- a/client/src/translations/rules/Pawnsking/en.pug +++ b/client/src/translations/rules/Pawnsking/en.pug @@ -11,7 +11,7 @@ p a(href="/#/variants/Pawns") Pawns |  Game. A king is added to its starting square. He moves as usual. | The first person to reach the other side with a pawn or king is the winner. - | You can also win if you capture the enemy king. + | You can also win by capturing the enemy king. h3 Source diff --git a/client/src/translations/rules/Selfabsorption/en.pug b/client/src/translations/rules/Selfabsorb/en.pug similarity index 100% rename from client/src/translations/rules/Selfabsorption/en.pug rename to client/src/translations/rules/Selfabsorb/en.pug diff --git a/client/src/translations/rules/Selfabsorption/es.pug b/client/src/translations/rules/Selfabsorb/es.pug similarity index 100% rename from client/src/translations/rules/Selfabsorption/es.pug rename to client/src/translations/rules/Selfabsorb/es.pug diff --git a/client/src/translations/rules/Selfabsorption/fr.pug b/client/src/translations/rules/Selfabsorb/fr.pug similarity index 100% rename from client/src/translations/rules/Selfabsorption/fr.pug rename to client/src/translations/rules/Selfabsorb/fr.pug diff --git a/client/src/translations/rules/Wildebeest/en.pug b/client/src/translations/rules/Wildebeest/en.pug index aee7cbf0..5f0b6311 100644 --- a/client/src/translations/rules/Wildebeest/en.pug +++ b/client/src/translations/rules/Wildebeest/en.pug @@ -35,4 +35,4 @@ p | Wildebeest page |  on chessvariants.com. -p Inventor: R. Wayne Schmittberger (1992) +p Inventor: R. Wayne Schmittberger (1987) diff --git a/client/src/translations/rules/Wildebeest/es.pug b/client/src/translations/rules/Wildebeest/es.pug index 9b4580dd..a407e332 100644 --- a/client/src/translations/rules/Wildebeest/es.pug +++ b/client/src/translations/rules/Wildebeest/es.pug @@ -34,4 +34,4 @@ p | Variante Wildebeest |  en chessvariants.com. -p Inventor: R. Wayne Schmittberger (1992) +p Inventor: R. Wayne Schmittberger (1987) diff --git a/client/src/translations/rules/Wildebeest/fr.pug b/client/src/translations/rules/Wildebeest/fr.pug index 63ccdabd..fb04759a 100644 --- a/client/src/translations/rules/Wildebeest/fr.pug +++ b/client/src/translations/rules/Wildebeest/fr.pug @@ -36,4 +36,4 @@ p | variante Wildebeest |  sur chessvariants.com. -p Inventeur : R. Wayne Schmittberger (1992) +p Inventeur : R. Wayne Schmittberger (1987) diff --git a/client/src/translations/rules/Wormhole/en.pug b/client/src/translations/rules/Wormhole1/en.pug similarity index 66% rename from client/src/translations/rules/Wormhole/en.pug rename to client/src/translations/rules/Wormhole1/en.pug index d52cda91..b14363a9 100644 --- a/client/src/translations/rules/Wormhole/en.pug +++ b/client/src/translations/rules/Wormhole1/en.pug @@ -21,7 +21,7 @@ p. figure.diagram-container .diagram - | fen:rbkxxxbn/ppxppppx/2qxxB2/4x2p/3P1x2/3n1x2/PPPxPPPP/RBxxxNKR b2,f2,b4,c5,g5,f6: + | fen:cwkxxxwn/ppxppppx/2mxxW2/4x2p/3P1x2/3n1x2/PPPxPPPP/CWxxxNKC b2,f2,b4,c5,g5,f6: figcaption Possible moves for the knight on d3. p. @@ -30,10 +30,24 @@ p. h3 Pieces movements +p Three new pieces replace usual sliders: + +figure.showPieces.text-center + img(src="/images/pieces/Wormhole/wc.png" style="width:60px") + img(src="/images/pieces/Wormhole/ww.png" style="width:60px") + img(src="/images/pieces/Wormhole/wm.png" style="width:60px") + figcaption Left to right: Champion, Wizard, Murray Lion. + ul - li The rook moves one or two squares vertically or horizontally. - li The bishop moves one or two squares diagonally. - li The queen moves either like a rook or like a bishop. + li. + The champion moves two squares in any direction, + or one square orthogonally. + li. + The wizard moves like an extended knight: two squares in an orthogonal + direction, and then one diagonal step. Or, a single diagonal step. + li. + The Murray Lion can move two squares in any direction. + He can also capture (only) by one square like a king. li The other pieces move like in orthodox chess. p All pieces can jump over others when moving by two squares. @@ -47,11 +61,9 @@ p a(href="https://www.chessvariants.com/32turn.dir/wormhole.html") | Wormhole chess |  on chessvariants.com. - | I changed the pieces movements because I have a better feeling with the - | moves described earlier. It might evolve. p - | Inventor (with other pieces' movements): Fergus Duniho (2000). + | Inventor: Fergus Duniho (2000). | Similar to a(href="https://www.chessvariants.com/boardrules.dir/cheshir.html") | Cheshire Cat Chess diff --git a/client/src/translations/rules/Wormhole/es.pug b/client/src/translations/rules/Wormhole1/es.pug similarity index 66% rename from client/src/translations/rules/Wormhole/es.pug rename to client/src/translations/rules/Wormhole1/es.pug index 3e823856..0ec75c19 100644 --- a/client/src/translations/rules/Wormhole/es.pug +++ b/client/src/translations/rules/Wormhole1/es.pug @@ -22,7 +22,7 @@ p. figure.diagram-container .diagram - | fen:rbkxxxbn/ppxppppx/2qxxB2/4x2p/3P1x2/3n1x2/PPPxPPPP/RBxxxNKR b2,f2,b4,c5,g5,f6: + | fen:cwkxxxwn/ppxppppx/2mxxW2/4x2p/3P1x2/3n1x2/PPPxPPPP/CWxxxNKC b2,f2,b4,c5,g5,f6: figcaption Posibles movimientos para el caballo en d3. p. @@ -31,10 +31,24 @@ p. h3 ¿Como las piezas se mueven? +p Tres piezas nuevas reemplazan los "deslizadores" habituales: + +figure.showPieces.text-center + img(src="/images/pieces/Wormhole/wc.png" style="width:60px") + img(src="/images/pieces/Wormhole/ww.png" style="width:60px") + img(src="/images/pieces/Wormhole/wm.png" style="width:60px") + figcaption De izquierda a derecha: Campeón, Hechicero, León "Murray". + ul - li La torre se mueve de una o dos casillas verticalmente u horizontalmente. - li El alfil se mueve de una o dos casillas en diagonal. - li La dama puede moverse como una torre o un alfil. + li. + El campeón se mueve dos casillas en cualquier dirección, + o bien una casilla ortogonalmente. + li. + El hechicero se mueve como un caballo reclinado: dos cuadrados en uno + dirección ortogonal, luego un paso diagonal. O solo un paso en diagonal. + li. + El león "Murray" se mueve dos cuadrados en cualquier dirección. + También puede (solo) capturar de una casilla como un rey. li Las otras piezas se mueven como en el ajedrez ortodoxo. p Todas las piezas pueden saltar sobre otras cuando se mueven dos espacios. @@ -48,11 +62,9 @@ h3 Fuente a(href="https://www.chessvariants.com/32turn.dir/wormhole.html") | variante Wormhole |  en chessvariants.com. - | Cambié los movimientos de las piezas porque las descritas aquí - | Parece más adecuado. Esto podría evolucionar. p - | Inventor (con otros movimientos de piezas): Fergus Duniho (2000). + | Inventor: Fergus Duniho (2000). | Similar a a(href="https://www.chessvariants.com/boardrules.dir/cheshir.html") | Cheshire Cat Chess diff --git a/client/src/translations/rules/Wormhole/fr.pug b/client/src/translations/rules/Wormhole1/fr.pug similarity index 66% rename from client/src/translations/rules/Wormhole/fr.pug rename to client/src/translations/rules/Wormhole1/fr.pug index fc0e0f17..56df229e 100644 --- a/client/src/translations/rules/Wormhole/fr.pug +++ b/client/src/translations/rules/Wormhole1/fr.pug @@ -22,7 +22,7 @@ p. figure.diagram-container .diagram - | fen:rbkxxxbn/ppxppppx/2qxxB2/4x2p/3P1x2/3n1x2/PPPxPPPP/RBxxxNKR b2,f2,b4,c5,g5,f6: + | fen:cwkxxxwn/ppxppppx/2mxxW2/4x2p/3P1x2/3n1x2/PPPxPPPP/CWxxxNKC b2,f2,b4,c5,g5,f6: figcaption Coups possibles pour le cavalier en d3. p. @@ -31,10 +31,24 @@ p. h3 Déplacement des pièces +p Trois nouvelles pièces remplacent les "glisseurs" usuels : + +figure.showPieces.text-center + img(src="/images/pieces/Wormhole/wc.png" style="width:60px") + img(src="/images/pieces/Wormhole/ww.png" style="width:60px") + img(src="/images/pieces/Wormhole/wm.png" style="width:60px") + figcaption De gauche à droite : Champion, Sorcier, Lion "Murray". + ul - li La tour se déplace d'une ou deux cases verticalement ou horizontalement. - li Le fous se déplace d'une ou deux cases en diagonale. - li La dame peut se mouvoir comme une tour ou un fou. + li. + Le champion se déplace de deux cases dans n'importe quelle direction, + ou bien d'une case orthogonalement. + li. + Le sorcier se déplace comme un cavalier allongé : deux cases dans une + direction orthogonale, puis un pas diagonal. Ou, un seul pas diagonal. + li. + Le lion "Murray" se déplace de deux cases dans n'importe quelle direction. + Il peut aussi (seulement) capturer d'une case comme un roi. li Les autres pièces se déplacent comme aux échecs orthodoxes. p. Toutes les pièces peuvent sauter par dessus d'autres @@ -51,11 +65,9 @@ p a(href="https://www.chessvariants.com/32turn.dir/wormhole.html") | variante Wormhole |  sur chessvariants.com. - | J'ai changé les déplacements des pièces car ceux décrits ici me - | paraissent mieux adaptés. Ceci pourrait évoluer. p - | Inventeur (avec d'autres déplacements de pièces) : Fergus Duniho (2000). + | Inventeur : Fergus Duniho (2000). | Similaire à a(href="https://www.chessvariants.com/boardrules.dir/cheshir.html") | Cheshire Cat Chess diff --git a/client/src/translations/rules/Wormhole2/en.pug b/client/src/translations/rules/Wormhole2/en.pug new file mode 100644 index 00000000..6e1370e3 --- /dev/null +++ b/client/src/translations/rules/Wormhole2/en.pug @@ -0,0 +1,14 @@ +p.boxed + | When a piece moves, the initial square disappears. It creates a + a(href="https://en.wikipedia.org/wiki/Wormhole") "wormhole" + | . + +p + a(href="/#/variants/Wormhole1") Wormhole1 + |  variant, with more standard pieces' movements: +ul + li The rook moves one or two squares vertically or horizontally. + li The bishop moves one or two squares diagonally. + li The queen moves either like a rook or like a bishop. + li The other pieces move like in orthodox chess. +p All pieces can jump over others when moving by two squares. diff --git a/client/src/translations/rules/Wormhole2/es.pug b/client/src/translations/rules/Wormhole2/es.pug new file mode 100644 index 00000000..ba458009 --- /dev/null +++ b/client/src/translations/rules/Wormhole2/es.pug @@ -0,0 +1,14 @@ +p.boxed + | Cuando una pieza se mueve, la casilla inicial desaparece. Esto crea un + a(href="https://es.wikipedia.org/wiki/Agujero_de_gusano") "agujero de gusano" + | . + +p + a(href="/#/variants/Wormhole1") Wormhole1 + |  variant, con movimientos de piezas más estándar: +ul + li La torre se mueve de una o dos casillas verticalmente u horizontalmente. + li El alfil se mueve de una o dos casillas en diagonal. + li La dama puede moverse como una torre o un alfil. + li Las otras piezas se mueven como en el ajedrez ortodoxo. +p Todas las piezas pueden saltar sobre otras cuando se mueven dos espacios. diff --git a/client/src/translations/rules/Wormhole2/fr.pug b/client/src/translations/rules/Wormhole2/fr.pug new file mode 100644 index 00000000..eb94134e --- /dev/null +++ b/client/src/translations/rules/Wormhole2/fr.pug @@ -0,0 +1,16 @@ +p.boxed + | Quand une pièce se déplace, la case initiale disparaît. Cela crée un + a(href="https://fr.wikipedia.org/wiki/Trou_de_ver") "trou de ver" + | . + +p + a(href="/#/variants/Wormhole1") Wormhole1 + |  variant, avec des mouvements de pièces plus standard : +ul + li La tour se déplace d'une ou deux cases verticalement ou horizontalement. + li Le fou se déplace d'une ou deux cases en diagonale. + li La dame peut se mouvoir comme une tour ou un fou. + li Les autres pièces se déplacent comme aux échecs orthodoxes. +p. + Toutes les pièces peuvent sauter par dessus d'autres + quand elles se déplacent de deux cases. diff --git a/client/src/translations/variants/en.pug b/client/src/translations/variants/en.pug index edb525a3..2c14ba6d 100644 --- a/client/src/translations/variants/en.pug +++ b/client/src/translations/variants/en.pug @@ -472,9 +472,10 @@ p. "Refusal", "Relayup", "Rollerball", - "Selfabsorption", + "Selfabsorb", "Takenmake", - "Wormhole" + "Wormhole1", + "Wormhole2" ] ul for v in varlist diff --git a/client/src/translations/variants/es.pug b/client/src/translations/variants/es.pug index 28ba251a..69756b12 100644 --- a/client/src/translations/variants/es.pug +++ b/client/src/translations/variants/es.pug @@ -482,9 +482,10 @@ p. "Refusal", "Relayup", "Rollerball", - "Selfabsorption", + "Selfabsorb", "Takenmake", - "Wormhole" + "Wormhole1", + "Wormhole2" ] ul for v in varlist diff --git a/client/src/translations/variants/fr.pug b/client/src/translations/variants/fr.pug index 9c881eb9..91585e93 100644 --- a/client/src/translations/variants/fr.pug +++ b/client/src/translations/variants/fr.pug @@ -480,9 +480,10 @@ p. "Refusal", "Relayup", "Rollerball", - "Selfabsorption", + "Selfabsorb", "Takenmake", - "Wormhole" + "Wormhole1", + "Wormhole2" ] ul for v in varlist diff --git a/client/src/variants/Selfabsorption.js b/client/src/variants/Selfabsorb.js similarity index 97% rename from client/src/variants/Selfabsorption.js rename to client/src/variants/Selfabsorb.js index 6f15d48c..0a8a7473 100644 --- a/client/src/variants/Selfabsorption.js +++ b/client/src/variants/Selfabsorb.js @@ -1,7 +1,7 @@ import { ChessRules } from "@/base_rules"; import { AbsorptionRules } from "@/variants/Absorption"; -export class SelfabsorptionRules extends AbsorptionRules { +export class SelfabsorbRules extends AbsorptionRules { canTake([x1, y1], [x2, y2]) { if (this.getColor(x1, y1) !== this.getColor(x2, y2)) return true; diff --git a/client/src/variants/Wormhole1.js b/client/src/variants/Wormhole1.js new file mode 100644 index 00000000..8219d28b --- /dev/null +++ b/client/src/variants/Wormhole1.js @@ -0,0 +1,192 @@ +import { ChessRules } from "@/base_rules"; +import { Wormhole2Rules } from "@/variants/Wormhole2"; + +export class Wormhole1Rules extends Wormhole2Rules { + + static get PawnSpecs() { + return Object.assign( + {}, + ChessRules.PawnSpecs, + { promotions: [V.LION, V.CHAMPION, V.WIZARD, V.KNIGHT] } + ); + } + + static get LION() { + return 'm'; + } + static get WIZARD() { + return 'w'; + } + static get CHAMPION() { + return 'c'; + } + + static get PIECES() { + return [V.PAWN, V.CHAMPION, V.KNIGHT, V.WIZARD, V.LION, V.KING]; + } + + getPpath(b) { + if (b[0] == 'x') return "Wormhole/hole"; + if ([V.LION, V.CHAMPION, V.WIZARD].includes(b[1])) + return "Wormhole/" + b; + return b; + } + + static get steps() { + return { + w: [ + [ [-2, 0], [-1, -1] ], + [ [-2, 0], [-1, 1] ], + [ [0, -2], [-1, -1] ], + [ [0, 2], [-1, 1] ], + [ [0, -2], [1, -1] ], + [ [0, 2], [1, 1] ], + [ [2, 0], [1, -1] ], + [ [2, 0], [1, 1] ] + ], + d: [ + [-2, 0], + [0, -2], + [2, 0], + [0, 2] + ], + a: [ + [2, 2], + [2, -2], + [-2, 2], + [-2, -2] + ], + f: [ + [-1, -1], + [-1, 1], + [1, -1], + [1, 1] + ], + z: [ + [-1, 0], + [1, 0], + [0, -1], + [0, 1] + ], + n: Wormhole2Rules.steps[V.KNIGHT], + k: Wormhole2Rules.steps[V.KING] + }; + } + + static GenRandInitFen(randomness) { + if (randomness == 0) + return "cnwmkwnc/pppppppp/8/8/8/8/PPPPPPPP/CNWMKWNC w 0"; + + // Mapping new --> standard: + const piecesMap = { + 'r': 'c', + 'n': 'n', + 'b': 'w', + 'q': 'm', + 'k': 'k' + }; + + const baseFen = ChessRules.GenRandInitFen(randomness); + return ( + baseFen.substr(0, 8).split('').map(p => piecesMap[p]).join('') + + baseFen.substr(8, 27) + + baseFen.substr(35, 43).split('') + .map(p => piecesMap[p]).join('').toUpperCase() + + " w 0" + ); + } + + getPotentialMovesFrom(sq) { + switch (this.getPiece(sq[0], sq[1])) { + case V.PAWN: return super.getPotentialPawnMoves(sq); + case V.CHAMPION: return this.getPotentialChampionMoves(sq); + case V.KNIGHT: return super.getPotentialKnightMoves(sq); + case V.WIZARD: return this.getPotentialWizardMoves(sq); + case V.LION: return this.getPotentialLionMoves(sq); + case V.KING: return super.getPotentialKingMoves(sq); + } + return []; + } + + getJumpMoves([x, y], steps, onlyTake) { + let moves = []; + for (let step of steps) { + const sq = this.getSquareAfter([x,y], step); + if (sq && + ( + (!onlyTake && this.board[sq[0]][sq[1]] == V.EMPTY) || + (this.board[sq[0]][sq[1]] != V.EMPTY && this.canTake([x, y], sq)) + ) + ) { + moves.push(this.getBasicMove([x, y], sq)); + } + } + return moves; + } + + getPotentialChampionMoves(sq) { + const steps = V.steps['d'].concat(V.steps['a']).concat(V.steps['z']); + return this.getJumpMoves(sq, steps); + } + + getPotentialWizardMoves(sq) { + const steps = V.steps['w'].concat(V.steps['f']); + return this.getJumpMoves(sq, steps); + } + + getPotentialLionMoves(sq) { + let steps = V.steps['d'].concat(V.steps['a']); + const moves1 = this.getJumpMoves(sq, steps); + steps = V.steps['f'].concat(V.steps['z']); + const moves2 = this.getJumpMoves(sq, steps, "onlyTake"); + return moves1.concat(moves2); + } + + isAttacked(sq, color) { + return ( + super.isAttackedByPawn(sq, color) || + this.isAttackedByChampion(sq, color) || + super.isAttackedByKnight(sq, color) || + this.isAttackedByWizard(sq, color) || + this.isAttackedByLion(sq, color) || + super.isAttackedByKing(sq, color) + ); + } + + isAttackedByWizard(sq, color) { + return ( + this.isAttackedByJump(sq, color, V.WIZARD, V.steps['f']) || + // NOTE: wizard attack is not symmetric in this variant: + // steps order need to be reversed. + this.isAttackedByJump( + sq, + color, + V.WIZARD, + V.steps['w'].map(s => s.reverse()) + ) + ); + } + + isAttackedByChampion(sq, color) { + const steps = V.steps['d'].concat(V.steps['a']).concat(V.steps['z']); + return this.isAttackedByJump(sq, color, V.CHAMPION, steps); + } + + isAttackedByLion(sq, color) { + const steps = V.steps['d'].concat(V.steps['a']) + .concat(V.steps['f']).concat(V.steps['z']); + return this.isAttackedByJump(sq, color, V.LION, steps); + } + + static get VALUES() { + return { + p: 1, + n: 3, + c: 8, + m: 9, + w: 3, + k: 1000 + }; + } + +}; diff --git a/client/src/variants/Wormhole.js b/client/src/variants/Wormhole2.js similarity index 98% rename from client/src/variants/Wormhole.js rename to client/src/variants/Wormhole2.js index 05d8f2ae..06b7fb60 100644 --- a/client/src/variants/Wormhole.js +++ b/client/src/variants/Wormhole2.js @@ -1,6 +1,6 @@ import { ChessRules } from "@/base_rules"; -export class WormholeRules extends ChessRules { +export class Wormhole2Rules extends ChessRules { static get HasFlags() { return false; @@ -150,7 +150,7 @@ export class WormholeRules extends ChessRules { this.canTake([x, y], sq) ) ) { - moves.push(this.getBasicMove([x, y], sq)); + moves.push(this.getBasicMove([x, y], sq)); } } return moves; @@ -186,7 +186,7 @@ export class WormholeRules extends ChessRules { this.canTake([x, y], [sq[0], sq[1]]) ) { const finalPieces = sq[0] == lastRank - ? [V.ROOK, V.KNIGHT, V.BISHOP, V.QUEEN] + ? V.PawnSpecs.promotions : [V.PAWN]; for (let piece of finalPieces) { moves.push( diff --git a/server/db/populate.sql b/server/db/populate.sql index 142ef4a6..56483794 100644 --- a/server/db/populate.sql +++ b/server/db/populate.sql @@ -136,7 +136,7 @@ insert or ignore into Variants (name, description) values ('Rugby', 'Transform an essay'), ('Schess', 'Seirawan-Harper Chess'), ('Screen', 'Free initial setup'), - ('Selfabsorption', 'Fusion pieces (v2)'), + ('Selfabsorb', 'Fusion pieces (v2)'), ('Shako', 'Non-conformism and utopia'), ('Shatranj', 'Ancient rules'), ('Shogi', 'Japanese Chess'), @@ -159,7 +159,8 @@ insert or ignore into Variants (name, description) values ('Upsidedown', 'Board upside down'), ('Vchess', 'Pawns capture backward'), ('Wildebeest', 'Balanced sliders & leapers'), - ('Wormhole', 'Squares disappear'), + ('Wormhole1', 'Squares disappear (v1)'), + ('Wormhole2', 'Squares disappear (v2)'), ('Xiangqi', 'Chinese Chess'), ('Yote', 'African Draughts'), ('Zen', 'Reverse captures');