From: Benjamin Auder Date: Mon, 22 Mar 2021 22:43:14 +0000 (+0100) Subject: Add New Zealand Chess X-Git-Url: https://git.auder.net/doc/html/%7B%7B%20asset%28%27mixstore/images/current/gitweb.css?a=commitdiff_plain;h=afa7abae33f5d0999890f8d9672525337d0bfaea;p=vchess.git Add New Zealand Chess --- diff --git a/client/src/translations/en.js b/client/src/translations/en.js index e93b434b..604fbf8e 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -245,6 +245,7 @@ export const translations = { "Kings cross the 8x8 board": "Kings cross the 8x8 board", "Kings cross the 11x11 board": "Kings cross the 11x11 board", "Knibis and Bisknis": "Knibis and Bisknis", + "Kniros and Rosknis": "Kniros and Rosknis", "Knight in pocket": "Knight in pocket", "Knight versus pawns": "Knight versus pawns", "Korean Chess": "Korean Chess", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index d776b26a..9a099a2c 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -245,6 +245,7 @@ export const translations = { "Kings cross the 8x8 board": "Los reyes cruzan el 8x8 tablero", "Kings cross the 11x11 board": "Los reyes cruzan el 11x11 tablero", "Knibis and Bisknis": "Knibis y Bisknis", + "Kniros and Rosknis": "Kniros y Rosknis", "Knight in pocket": "Caballo en bolsillo", "Knight versus pawns": "Caballo contra peones", "Korean Chess": "Ajedrez coreano", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index 4752d917..5bd4aea6 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -245,6 +245,7 @@ export const translations = { "Kings cross the 8x8 board": "Les rois traversent l'échiquier 8x8", "Kings cross the 11x11 board": "Les rois traversent l'échiquier 11x11", "Knibis and Bisknis": "Knibis et Bisknis", + "Kniros and Rosknis": "Kniros et Rosknis", "Knight in pocket": "Cavalier en poche", "Knight versus pawns": "Cavalier contre pions", "Korean Chess": "Échecs coréens", diff --git a/client/src/translations/rules/Newzealand/en.pug b/client/src/translations/rules/Newzealand/en.pug new file mode 100644 index 00000000..0405e15a --- /dev/null +++ b/client/src/translations/rules/Newzealand/en.pug @@ -0,0 +1,17 @@ +p.boxed + | Knights capture as rooks, and rooks capture as knights. + +figure.diagram-container + .diagram.diag12 + | fen:r1bqr1k1/pp2ppbp/2n2np1/1BpN4/5P2/4PN2/PPP3PP/R1BQ1RK1: + .diagram.diag22 + | fen:r1bNr1k1/pp2ppbp/2n2np1/1Bp5/5P2/4PN2/PPP3PP/R1BQ1RK1: + figcaption Before and after Nxd8. + +h3 Source + +p + | The variant is mentioned + a(href="https://www.chessvariants.com/play/erf/NewZChss.html") + | on chessvariants + | . It was probably invented around 1903. diff --git a/client/src/translations/rules/Newzealand/es.pug b/client/src/translations/rules/Newzealand/es.pug new file mode 100644 index 00000000..3a416434 --- /dev/null +++ b/client/src/translations/rules/Newzealand/es.pug @@ -0,0 +1,17 @@ +p.boxed + | Los caballos capturan como torres y las torres como caballos. + +figure.diagram-container + .diagram.diag12 + | fen:r1bqr1k1/pp2ppbp/2n2np1/1BpN4/5P2/4PN2/PPP3PP/R1BQ1RK1: + .diagram.diag22 + | fen:r1bNr1k1/pp2ppbp/2n2np1/1Bp5/5P2/4PN2/PPP3PP/R1BQ1RK1: + figcaption Antes y después de Nxd8. + +h3 Fuente + +p + | Se menciona la variante + a(href="https://www.chessvariants.com/play/erf/NewZChss.html") + | en chessvariants + | . Probablemente fue inventado alrededor de 1903. diff --git a/client/src/translations/rules/Newzealand/fr.pug b/client/src/translations/rules/Newzealand/fr.pug new file mode 100644 index 00000000..e58a693b --- /dev/null +++ b/client/src/translations/rules/Newzealand/fr.pug @@ -0,0 +1,17 @@ +p.boxed + | Les cavaliers capturent comme des tours, et les tours comme des cavaliers. + +figure.diagram-container + .diagram.diag12 + | fen:r1bqr1k1/pp2ppbp/2n2np1/1BpN4/5P2/4PN2/PPP3PP/R1BQ1RK1: + .diagram.diag22 + | fen:r1bNr1k1/pp2ppbp/2n2np1/1Bp5/5P2/4PN2/PPP3PP/R1BQ1RK1: + figcaption Avant et après Nxd8. + +h3 Source + +p + | La variante est mentionnée + a(href="https://www.chessvariants.com/play/erf/NewZChss.html") + | sur chessvariants + | . Elle a probablement été inventée vers 1903. diff --git a/client/src/translations/variants/en.pug b/client/src/translations/variants/en.pug index a6e5bd8d..5c131086 100644 --- a/client/src/translations/variants/en.pug +++ b/client/src/translations/variants/en.pug @@ -124,6 +124,7 @@ p. "Grand", "Grasshopper", "Hoppelpoppel", + "Newzealand", "Omega", "Ordamirror", "Perfect", diff --git a/client/src/translations/variants/es.pug b/client/src/translations/variants/es.pug index 2db4ef95..fa4bab94 100644 --- a/client/src/translations/variants/es.pug +++ b/client/src/translations/variants/es.pug @@ -131,6 +131,7 @@ p. "Grand", "Grasshopper", "Hoppelpoppel", + "Newzealand", "Omega", "Ordamirror", "Perfect", diff --git a/client/src/translations/variants/fr.pug b/client/src/translations/variants/fr.pug index ba52eca5..a2dccaef 100644 --- a/client/src/translations/variants/fr.pug +++ b/client/src/translations/variants/fr.pug @@ -130,6 +130,7 @@ p. "Grand", "Grasshopper", "Hoppelpoppel", + "Newzealand", "Omega", "Ordamirror", "Perfect", diff --git a/client/src/variants/Newzealand.js b/client/src/variants/Newzealand.js new file mode 100644 index 00000000..d51eda11 --- /dev/null +++ b/client/src/variants/Newzealand.js @@ -0,0 +1,65 @@ +import { ChessRules } from "@/base_rules"; + +// NOTE: a lot copy-pasted from Hoppelpoppel +export class NewzealandRules extends ChessRules { + + getSlideNJumpMoves_([x, y], steps, oneStep, options) { + options = options || {}; + let moves = []; + outerLoop: for (let step of steps) { + let i = x + step[0]; + let j = y + step[1]; + while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) { + if (!options.onlyTake) moves.push(this.getBasicMove([x, y], [i, j])); + if (!!oneStep) continue outerLoop; + i += step[0]; + j += step[1]; + } + if (V.OnBoard(i, j) && this.canTake([x, y], [i, j]) && !options.onlyMove) + moves.push(this.getBasicMove([x, y], [i, j])); + } + return moves; + } + + getPotentialKnightMoves(sq) { + // The knight captures like a rook + return ( + this.getSlideNJumpMoves_( + sq, ChessRules.steps[V.KNIGHT], "oneStep", { onlyMove: true }) + .concat( + this.getSlideNJumpMoves_( + sq, ChessRules.steps[V.ROOK], null, { onlyTake: true })) + ); + } + + getPotentialRookMoves(sq) { + // The rook captures like a knight + return ( + this.getSlideNJumpMoves_( + sq, ChessRules.steps[V.ROOK], null, { onlyMove: true }) + .concat( + this.getSlideNJumpMoves_( + sq, ChessRules.steps[V.KNIGHT], "oneStep", { onlyTake: true })) + ); + } + + isAttackedByKnight([x, y], color) { + return super.isAttackedBySlideNJump( + [x, y], + color, + V.KNIGHT, + V.steps[V.ROOK] + ); + } + + isAttackedByROOK([x, y], color) { + return super.isAttackedBySlideNJump( + [x, y], + color, + V.ROOK, + V.steps[V.KNIGHT], + "oneStep" + ); + } + +}; diff --git a/server/db/populate.sql b/server/db/populate.sql index 97ccdd66..1a13014b 100644 --- a/server/db/populate.sql +++ b/server/db/populate.sql @@ -114,6 +114,7 @@ insert or ignore into Variants (name, description) values ('Monocolor', 'All of the same color'), ('Monster', 'White move twice'), ('Musketeer', 'New fairy pieces'), + ('Newzealand', 'Kniros and Rosknis'), ('Omega', 'A wizard in the corner'), ('Orda', 'Mongolian Horde (v1)'), ('Ordamirror', 'Mongolian Horde (v2)'),