From: Benjamin Auder Date: Fri, 1 May 2020 11:33:55 +0000 (+0200) Subject: Add Balaklava variant X-Git-Url: https://git.auder.net/variants/current/doc/scripts/pieces/css/index.css?a=commitdiff_plain;h=a0224b03c91dd83a6e133378b85591a1a64e427b;p=vchess.git Add Balaklava variant --- diff --git a/client/public/images/pieces/Balaklava/bm.svg b/client/public/images/pieces/Balaklava/bm.svg new file mode 100644 index 00000000..48add199 --- /dev/null +++ b/client/public/images/pieces/Balaklava/bm.svg @@ -0,0 +1,184 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/public/images/pieces/Balaklava/wm.svg b/client/public/images/pieces/Balaklava/wm.svg new file mode 100644 index 00000000..5535a15c --- /dev/null +++ b/client/public/images/pieces/Balaklava/wm.svg @@ -0,0 +1,172 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/public/images/pieces/SOURCE b/client/public/images/pieces/SOURCE index 727a6a15..8854bad4 100644 --- a/client/public/images/pieces/SOURCE +++ b/client/public/images/pieces/SOURCE @@ -9,3 +9,4 @@ He also designed all the Horde pieces in Orda, the Shako Cannon and Elephant, the black Colorbound + Sittuyin pieces set, and he sent me the wizard and champion SVG files as well (modified from Wikipedia) Letter D: https://svgsilh.com/image/2051714.html +Mammoth: https://www.flaticon.com/free-icon/mammoth_925138 diff --git a/client/src/translations/en.js b/client/src/translations/en.js index c9d6efad..91667a74 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -206,6 +206,7 @@ export const translations = { "Mate any piece (v1)": "Mate any piece (v1)", "Mate any piece (v2)": "Mate any piece (v2)", "Mate the knight": "Mate the knight", + "Meet the Mammoth": "Meet the Mammoth", "Middle battle": "Middle battle", "Mongolian Horde": "Mongolian Horde", "Move like a knight (v1)": "Move like a knight (v1)", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index 986adb1f..daf09aef 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -206,6 +206,7 @@ export const translations = { "Mate any piece (v1)": "Matar cualquier pieza (v1)", "Mate any piece (v2)": "Matar cualquier pieza (v2)", "Mate the knight": "Matar el caballo", + "Meet the Mammoth": "Conoce al Mamut", "Middle battle": "Batalla media", "Mongolian Horde": "Horda mongol", "Move like a knight (v1)": "Moverse como un caballo (v1)", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index 95ad59b7..6b57c329 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -206,6 +206,7 @@ export const translations = { "Mate any piece (v1)": "Matez n'importe quelle pièce (v1)", "Mate any piece (v2)": "Matez n'importe quelle pièce (v2)", "Mate the knight": "Matez le cavalier", + "Meet the Mammoth": "Rencontrez le Mammouth", "Middle battle": "Bataille du milieu", "Mongolian Horde": "Horde mongole", "Move like a knight (v1)": "Bouger comme un cavalier (v1)", diff --git a/client/src/translations/rules/Balaklava/en.pug b/client/src/translations/rules/Balaklava/en.pug new file mode 100644 index 00000000..6ed42f5b --- /dev/null +++ b/client/src/translations/rules/Balaklava/en.pug @@ -0,0 +1,28 @@ +p.boxed + | Pieces can also move as a knight. The knight is replaced by a mammoth. + +p. + In addition to their usual abilities, pawns and non-royal pieces (eveything + but the king) may make non-capturing knight moves. + +p. + The new piece instead of the knight is a Mammoth: it leaps two squares in + any direction, as illustrated below. + +figure.diagram-container + .diagram + | fen:8/8/2pP4/4MP2/4p3/3p4/8/8 c7,d7,e7,f7,g7,g6,g5,g4,g3,f3,e3,c3,c4,c5: + figcaption Movements of the Mammoth + +ul + li A pawn cannot promote with a knight move. + li No en passant captures. + +h3 Source + +p + a(href="https://www.chessvariants.com/diffmove.dir/balaklava.html") + | Balaklava Chess + |  on chessvariants.com. + +p Inventor: Gianluca Vecchi (1994) diff --git a/client/src/translations/rules/Balaklava/es.pug b/client/src/translations/rules/Balaklava/es.pug new file mode 100644 index 00000000..1218cf44 --- /dev/null +++ b/client/src/translations/rules/Balaklava/es.pug @@ -0,0 +1,30 @@ +p.boxed + | Las piezas también pueden moverse como un caballo. + | El caballo es reemplazado por un mamut. + +p. + Además de sus habilidades habituales, peones y piezas no reales + (todo excepto el rey) puede hacer saltos de caballo non capturado. + +p. + La nueva pieza reemplaza para el caballo es un Mamut: salta dos + casillas en todas las direcciones, como se muestra a continuación. + +figure.diagram-container + .diagram + | fen:8/8/2pP4/4MP2/4p3/3p4/8/8 c7,d7,e7,f7,g7,g6,g5,g4,g3,f3,e3,c3,c4,c5: + figcaption Movimientos del Mamut. + +ul + li Un peón no puede ser promovido a través de un salto de caballo. + li No hay capturas en passant. + +h3 Fuente + +p + | La + a(href="https://www.chessvariants.com/diffmove.dir/balaklava.html") + | variante Balaklava + |  en chessvariants.com. + +p Inventor: Gianluca Vecchi (1994) diff --git a/client/src/translations/rules/Balaklava/fr.pug b/client/src/translations/rules/Balaklava/fr.pug new file mode 100644 index 00000000..8b22d698 --- /dev/null +++ b/client/src/translations/rules/Balaklava/fr.pug @@ -0,0 +1,30 @@ +p.boxed + | Les pièces peuvent aussi se déplacer comme un cavalier. + | Le cavalier est remplacé par un mammouth. + +p. + En plus de leurs capacités habituelles, les pions et pièces non royales + (tout sauf le roi) peuvent effectuer des coups de cavalier non capturants. + +p. + La nouvelle pièce remplaçant le cavalier est un Mammouth : il saute de deux + cases dans toutes les directions, comme illustré ci-dessous. + +figure.diagram-container + .diagram + | fen:8/8/2pP4/4MP2/4p3/3p4/8/8 c7,d7,e7,f7,g7,g6,g5,g4,g3,f3,e3,c3,c4,c5: + figcaption Déplacements du Mammouth + +ul + li Un pion ne peut se promouvoir via un saut de cavalier. + li Pas de prises en passant. + +h3 Source + +p + | La + a(href="https://www.chessvariants.com/diffmove.dir/balaklava.html") + | variante Balaklava + |  sur chessvariants.com. + +p Inventeur : Gianluca Vecchi (1994) diff --git a/client/src/variants/Balaklava.js b/client/src/variants/Balaklava.js new file mode 100644 index 00000000..3a04e1d0 --- /dev/null +++ b/client/src/variants/Balaklava.js @@ -0,0 +1,109 @@ +import { ChessRules } from "@/base_rules"; + +export class BalaklavaRules extends ChessRules { + static get PawnSpecs() { + return Object.assign( + {}, + ChessRules.PawnSpecs, + { promotions: [V.ROOK, V.MAMMOTH, V.BISHOP, V.QUEEN] } + ); + } + + static get HasEnpassant() { + return false; + } + + getPpath(b) { + return (b[1] == V.MAMMOTH ? "Balaklava/" : "") + b; + } + + // Alfil + Dabbaba: + static get MAMMOTH() { + return "m"; + } + + static get PIECES() { + return [V.PAWN, V.ROOK, V.MAMMOTH, V.BISHOP, V.QUEEN, V.KING]; + } + + static get steps() { + return Object.assign( + {}, + ChessRules.steps, + { + m: [ + [-2, -2], + [-2, 0], + [-2, 2], + [0, -2], + [0, 2], + [2, -2], + [2, 0], + [2, 2], + ] + } + ); + } + + static GenRandInitFen(randomness) { + // No collision between 'n' and castle flags, so next replacement is fine + return ( + ChessRules.GenRandInitFen(randomness) + .replace(/n/g, 'm').replace(/N/g, 'M') + ); + } + + getPotentialMovesFrom([x, y]) { + const piece = this.getPiece(x, y); + let moves = + piece == V.MAMMOTH + ? this.getPotentialMammothMoves([x, y]) + : super.getPotentialMovesFrom([x, y]); + if (piece != V.KING) { + // Add non-capturing knight movements + const lastRank = (this.turn == 'w' ? 0 : 7); + V.steps[V.KNIGHT].forEach(step => { + const [i, j] = [x + step[0], y + step[1]]; + if ( + V.OnBoard(i, j) && + this.board[i][j] == V.EMPTY && + // Pawns don't promote with a knight move + (piece != V.PAWN || i != lastRank) + ) { + moves.push(this.getBasicMove([x, y], [i, j])); + } + }); + } + return moves; + } + + getPotentialMammothMoves(sq) { + return this.getSlideNJumpMoves(sq, V.steps[V.MAMMOTH], "oneStep"); + } + + isAttacked(sq, color) { + return ( + super.isAttacked(sq, color) || + this.isAttackedByMammoth(sq, color) + ); + } + + isAttackedByMammoth(sq, color) { + return ( + this.isAttackedBySlideNJump( + sq, color, V.MAMMOTH, V.steps[V.MAMMOTH], "oneStep") + ); + } + + static get SEARCH_DEPTH() { + return 2; + } + + static get VALUES() { + return Object.assign( + // A mammoth is probably worth a little more than a knight + { m: 4 }, + ChessRules.VALUES + ); + } +}; diff --git a/server/db/populate.sql b/server/db/populate.sql index 51e1a225..49419674 100644 --- a/server/db/populate.sql +++ b/server/db/populate.sql @@ -20,6 +20,7 @@ insert or ignore into Variants (name, description) values ('Arena', 'Middle battle'), ('Atomic', 'Explosive captures'), ('Ball', 'Score a goal'), + ('Balaklava', 'Meet the Mammoth'), ('Baroque', 'Exotic captures'), ('Benedict', 'Change colors'), ('Berolina', 'Pawns move diagonally'),