From: Benjamin Auder Date: Tue, 24 Mar 2020 03:51:50 +0000 (+0100) Subject: Add Doublearmy, commoner replaces middle king, no rules description yet (TODO) X-Git-Url: https://git.auder.net/variants/Chakart/css/assets/doc/current/index.css?a=commitdiff_plain;h=de3f56254c410a7c245a50053b7c905233b58115;p=vchess.git Add Doublearmy, commoner replaces middle king, no rules description yet (TODO) --- diff --git a/TODO b/TODO index 8d3eabcf..7d46a80c 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ # New variants -Doublearmy: 2 kings remaining get mated. - Landing pieces from empty board: https://www.chessvariants.com/diffsetup.dir/unachess.html Parachute v1 & 2 diff --git a/client/public/images/pieces/Doublearmy/bc.svg b/client/public/images/pieces/Doublearmy/bc.svg new file mode 100644 index 00000000..09954492 --- /dev/null +++ b/client/public/images/pieces/Doublearmy/bc.svg @@ -0,0 +1,105 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/public/images/pieces/Doublearmy/wc.svg b/client/public/images/pieces/Doublearmy/wc.svg new file mode 100644 index 00000000..12f2b27a --- /dev/null +++ b/client/public/images/pieces/Doublearmy/wc.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 815edf6a..513922a4 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -152,6 +152,7 @@ export const translations = { "Your message": "Your message", // Variants boxes: + "64 pieces on the board": "64 pieces on the board", "Ancient rules": "Ancient rules", "Attract opposite king": "Attract opposite king", "Balanced sliders & leapers": "Balanced sliders & leapers", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index f008e530..fb13e28e 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -152,6 +152,7 @@ export const translations = { "Your message": "Tu mensaje", // Variants boxes: + "64 pieces on the board": "64 piezas en el tablero", "Ancient rules": "Viejas reglas", "Attract opposite king": "Atraer al rey contrario", "Balanced sliders & leapers": "Modos de desplazamiento equilibrados", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index 1d4dbd53..8524dcb6 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -152,6 +152,7 @@ export const translations = { "Your message": "Votre message", // Variants boxes: + "64 pieces on the board": "64 pièces sur l'échiquier", "Ancient rules": "Règles anciennes", "Attract opposite king": "Attirer le roi adverse", "Balanced sliders & leapers": "Modes de déplacement équilibrés", diff --git a/client/src/translations/rules/Doublearmy/en.pug b/client/src/translations/rules/Doublearmy/en.pug new file mode 100644 index 00000000..5e0f62d3 --- /dev/null +++ b/client/src/translations/rules/Doublearmy/en.pug @@ -0,0 +1,2 @@ +p.boxed + | TODO. diff --git a/client/src/translations/rules/Doublearmy/es.pug b/client/src/translations/rules/Doublearmy/es.pug new file mode 100644 index 00000000..5e0f62d3 --- /dev/null +++ b/client/src/translations/rules/Doublearmy/es.pug @@ -0,0 +1,2 @@ +p.boxed + | TODO. diff --git a/client/src/translations/rules/Doublearmy/fr.pug b/client/src/translations/rules/Doublearmy/fr.pug new file mode 100644 index 00000000..5e0f62d3 --- /dev/null +++ b/client/src/translations/rules/Doublearmy/fr.pug @@ -0,0 +1,2 @@ +p.boxed + | TODO. diff --git a/client/src/variants/Doublearmy.js b/client/src/variants/Doublearmy.js new file mode 100644 index 00000000..0fafe96f --- /dev/null +++ b/client/src/variants/Doublearmy.js @@ -0,0 +1,81 @@ +import { ChessRules } from "@/base_rules"; + +// Ideas with 2 kings: +// Stage 1 {w, b} : 2 kings on board, value 5. +// Stage 2: only one, get mated and all that, value 1000 +// ...But the middle king will get captured quickly... + +export class DoublearmyRules extends ChessRules { + static get COMMONER() { + return "c"; + } + + static get PIECES() { + return ChessRules.PIECES.concat([V.COMMONER]); + } + + getPpath(b) { + return (b[1] == V.COMMONER ? "Doublearmy/" : "") + b; + } + + static GenRandInitFen(randomness) { + const fen = ChessRules.GenRandInitFen(randomness); + const rows = fen.split(" ")[0].split("/"); + return ( + rows[0] + "/" + + rows[1] + "/" + + rows[0].replace('k', 'c') + "/" + + rows[1] + "/" + + rows[6] + "/" + + rows[7].replace('K', 'C') + "/" + + rows[6] + "/" + + rows[7] + fen.slice(-11) + ); + } + + getPotentialMovesFrom([x, y]) { + switch (this.getPiece(x, y)) { + case V.COMMONER: + return this.getPotentialCommonerMoves([x, y]); + default: + return super.getPotentialMovesFrom([x, y]); + } + } + + getPotentialCommonerMoves(sq) { + return this.getSlideNJumpMoves( + sq, + V.steps[V.ROOK].concat(V.steps[V.BISHOP]), + "oneStep" + ); + } + + isAttacked(sq, color) { + return ( + super.isAttacked(sq, color) || + this.isAttackedByCommoner(sq, color) + ); + } + + isAttackedByCommoner(sq, color) { + return this.isAttackedBySlideNJump( + sq, + color, + V.COMMONER, + V.steps[V.ROOK].concat(V.steps[V.BISHOP]), + "oneStep" + ); + } + + static get VALUES() { + return Object.assign( + {}, + ChessRules.VALUES, + { c: 5 } + ); + } + + static get SEARCH_DEPTH() { + return 2; + } +}; diff --git a/server/db/populate.sql b/server/db/populate.sql index 72ded709..28d186cb 100644 --- a/server/db/populate.sql +++ b/server/db/populate.sql @@ -22,6 +22,7 @@ insert or ignore into Variants (name,description) values ('Crazyhouse', 'Captures reborn'), ('Cylinder', 'Neverending rows'), ('Dark', 'In the shadow'), + ('Doublearmy', '64 pieces on the board'), ('Eightpieces', 'Each piece is unique'), ('Enpassant', 'Capture en passant'), ('Extinction', 'Capture all of a kind'),