From de3f56254c410a7c245a50053b7c905233b58115 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Tue, 24 Mar 2020 04:51:50 +0100 Subject: [PATCH] Add Doublearmy, commoner replaces middle king, no rules description yet (TODO) --- TODO | 2 - client/public/images/pieces/Doublearmy/bc.svg | 105 ++++++++++++++++++ client/public/images/pieces/Doublearmy/wc.svg | 94 ++++++++++++++++ client/src/translations/en.js | 1 + client/src/translations/es.js | 1 + client/src/translations/fr.js | 1 + .../src/translations/rules/Doublearmy/en.pug | 2 + .../src/translations/rules/Doublearmy/es.pug | 2 + .../src/translations/rules/Doublearmy/fr.pug | 2 + client/src/variants/Doublearmy.js | 81 ++++++++++++++ server/db/populate.sql | 1 + 11 files changed, 290 insertions(+), 2 deletions(-) create mode 100644 client/public/images/pieces/Doublearmy/bc.svg create mode 100644 client/public/images/pieces/Doublearmy/wc.svg create mode 100644 client/src/translations/rules/Doublearmy/en.pug create mode 100644 client/src/translations/rules/Doublearmy/es.pug create mode 100644 client/src/translations/rules/Doublearmy/fr.pug create mode 100644 client/src/variants/Doublearmy.js 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="45" + height="45" + viewBox="0 0 11.90625 11.90625" + version="1.1" + id="svg4393" + sodipodi:docname="CommonerB_Transparent.svg" + inkscape:version="0.92.1 r15371"> + <defs + id="defs4387" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="3" + inkscape:cx="30.240069" + inkscape:cy="21.353804" + inkscape:document-units="mm" + inkscape:current-layer="layer1" + showgrid="false" + units="px" + inkscape:window-width="1600" + inkscape:window-height="837" + inkscape:window-x="-8" + inkscape:window-y="-8" + inkscape:window-maximized="1" /> + <metadata + id="metadata4390"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-285.09373)"> + <g + id="g4572" + transform="matrix(0.28921369,0,0,0.28921369,-0.54713251,283.72613)"> + <circle + id="circle4537" + r="2.5" + cy="13.5" + cx="22.5" + style="fill:#000000;stroke:#000000;stroke-width:1.5;stroke-linejoin:round" /> + <circle + id="circle4539" + r="1.5" + cy="13.5" + cx="22.5" + style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linejoin:round" /> + <g + id="g4543" + style="fill:#000000;stroke:#000000;stroke-width:1.5;stroke-linejoin:round"> + <!-- test --> + <path + id="path4541" + d="m 11.5,37 c 5.5,3.5 15.5,3.5 21,0 v -7 c 0,0 9,-4.5 6,-11 -5.5,-7 -26.5,-7 -32,0 -3,6.5 5,10.5 5,10.5 z" + inkscape:connector-curvature="0" /> + </g> + <g + id="g4553" + style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round"> + <!-- test --> + <path + id="path4545" + d="m 32,29.5 c 0,0 8.5,-4 6,-9.65 C 32.65,13 12.35,13 7,19.85 c -2.5,5.65 4.85,9 4.85,9" + inkscape:connector-curvature="0" /> + <!-- talp --> + <path + id="path4547" + d="M 11.5,30 C 17,27 27,27 32.5,30" + inkscape:connector-curvature="0" /> + <path + id="path4549" + d="m 11.5,33.5 c 5.5,-3 15.5,-3 21,0" + inkscape:connector-curvature="0" /> + <path + id="path4551" + d="M 11.5,37 C 17,34 27,34 32.5,37" + inkscape:connector-curvature="0" /> + </g> + </g> + </g> +</svg> 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="45" + height="45" + viewBox="0 0 11.90625 11.90625" + version="1.1" + id="svg4393" + inkscape:version="0.92.1 r15371" + sodipodi:docname="Commoner_Transparent.svg"> + <defs + id="defs4387" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1" + inkscape:cx="5.1998528" + inkscape:cy="24.301903" + inkscape:document-units="mm" + inkscape:current-layer="layer1" + showgrid="false" + units="px" + inkscape:window-width="1600" + inkscape:window-height="837" + inkscape:window-x="-8" + inkscape:window-y="-8" + inkscape:window-maximized="1" /> + <metadata + id="metadata4390"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-285.09373)"> + <g + id="g4499" + transform="matrix(0.28598519,0,0,0.28598519,-0.47456997,283.80785)"> + <g + id="g4399" + style="fill:#ffffff;stroke:#000000;stroke-width:1.5;stroke-linejoin:round"> + <!-- bojt --> + <circle + id="circle4395" + r="2.5" + cy="13.5" + cx="22.5" /> + <!-- test --> + <path + id="path4397" + d="m 11.5,37 c 5.5,3.5 15.5,3.5 21,0 v -7 c 0,0 9,-4.5 6,-11 -5.5,-7 -26.5,-7 -32,0 -3,6.5 5,10.5 5,10.5 z" + inkscape:connector-curvature="0" /> + </g> + <g + id="g4407" + style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:round"> + <!-- talp --> + <path + id="path4401" + d="M 11.5,30 C 17,27 27,27 32.5,30" + inkscape:connector-curvature="0" /> + <path + id="path4403" + d="m 11.5,33.5 c 5.5,-3 15.5,-3 21,0" + inkscape:connector-curvature="0" /> + <path + id="path4405" + d="M 11.5,37 C 17,34 27,34 32.5,37" + inkscape:connector-curvature="0" /> + </g> + </g> + </g> +</svg> 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'), -- 2.44.0