From: Benjamin Auder Date: Sun, 11 Apr 2021 15:41:51 +0000 (+0200) Subject: Fix Musketeer, Joker, Shinobi. Start draft of Cwda X-Git-Url: https://git.auder.net/variants/%24%7Bvname%7D/current/scripts/R.css?a=commitdiff_plain;h=cee75a57d2f4f89c89d64cefbab55d839a238ed9;p=vchess.git Fix Musketeer, Joker, Shinobi. Start draft of Cwda --- diff --git a/client/public/images/pieces/Colorbound/ba.svg b/client/public/images/pieces/Cwda/ba.svg similarity index 100% rename from client/public/images/pieces/Colorbound/ba.svg rename to client/public/images/pieces/Cwda/ba.svg diff --git a/client/public/images/pieces/Colorbound/bd.svg b/client/public/images/pieces/Cwda/bd.svg similarity index 100% rename from client/public/images/pieces/Colorbound/bd.svg rename to client/public/images/pieces/Cwda/bd.svg diff --git a/client/public/images/pieces/Colorbound/bh.svg b/client/public/images/pieces/Cwda/bh.svg similarity index 100% rename from client/public/images/pieces/Colorbound/bh.svg rename to client/public/images/pieces/Cwda/bh.svg diff --git a/client/public/images/pieces/Colorbound/bs.svg b/client/public/images/pieces/Cwda/bs.svg similarity index 100% rename from client/public/images/pieces/Colorbound/bs.svg rename to client/public/images/pieces/Cwda/bs.svg diff --git a/client/public/images/pieces/Colorbound/wa.svg b/client/public/images/pieces/Cwda/wa.svg similarity index 100% rename from client/public/images/pieces/Colorbound/wa.svg rename to client/public/images/pieces/Cwda/wa.svg diff --git a/client/public/images/pieces/Colorbound/wd.svg b/client/public/images/pieces/Cwda/wd.svg similarity index 100% rename from client/public/images/pieces/Colorbound/wd.svg rename to client/public/images/pieces/Cwda/wd.svg diff --git a/client/public/images/pieces/Colorbound/wh.svg b/client/public/images/pieces/Cwda/wh.svg similarity index 100% rename from client/public/images/pieces/Colorbound/wh.svg rename to client/public/images/pieces/Cwda/wh.svg diff --git a/client/public/images/pieces/Colorbound/ws.svg b/client/public/images/pieces/Cwda/ws.svg similarity index 100% rename from client/public/images/pieces/Colorbound/ws.svg rename to client/public/images/pieces/Cwda/ws.svg diff --git a/client/public/images/pieces/Musketeer/bf.svg b/client/public/images/pieces/Musketeer/bf.svg index be83f160..e1c7520f 100644 --- a/client/public/images/pieces/Musketeer/bf.svg +++ b/client/public/images/pieces/Musketeer/bf.svg @@ -15,7 +15,7 @@ style="enable-background:new 0 0 512 512;" xml:space="preserve" sodipodi:docname="bf.svg" - inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07, custom)">image/svg+xml + inkscape:current-layer="Layer_1" + inkscape:document-rotation="0" /> @@ -129,4 +130,34 @@ id="g48" transform="matrix(0.8,0,0,0.9,51.2,25.60005)"> - + diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 43f9f266..0c20b59e 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -368,7 +368,8 @@ export const ChessRules = class ChessRules { // Setup the initial random (asymmetric) position static GenRandInitFen(options) { - if (!options.randomness || options.randomness == 0) + const randomness = parseInt(options.randomness, 10); + if (!randomness || randomness == 0) // Deterministic: return "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w 0 ahah -"; diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 133a0de6..832bcb9d 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -273,6 +273,7 @@ export const translations = { "Moving forward": "Moving forward", "Neverending rows": "Neverending rows", "New fairy pieces": "New fairy pieces", + "New teams": "New teams", "No paralyzed pieces": "No paralyzed pieces", "No-check mode": "No-check mode", "Noise and confusion (v1)": "Noise and confusion (v1)", @@ -324,7 +325,6 @@ export const translations = { "Thai Chess (v1)": "Thai Chess (v1)", "Thai Chess (v2)": "Thai Chess (v2)", "Thai Chess (v3)": "Thai Chess (v3)", - "The colorbound clobberers": "The colorbound clobberers", "The end of the world": "The end of the world", "Transform an essay": "Transform an essay", "Two kings": "Two kings", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index d3be2c1f..4c458fb3 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -273,6 +273,7 @@ export const translations = { "Moving forward": "Ir adelante", "Neverending rows": "Filas interminables", "New fairy pieces": "Nuevas piezas magicas", + "New teams": "Nuevos equipos", "No paralyzed pieces": "No piezas paralizadas", "No-check mode": "Modo sin jaque", "Noise and confusion (v1)": "Ruido y confusión (v1)", @@ -324,7 +325,6 @@ export const translations = { "Thai Chess (v1)": "Ajedrez tailandés (v1)", "Thai Chess (v2)": "Ajedrez tailandés (v2)", "Thai Chess (v3)": "Ajedrez tailandés (v3)", - "The colorbound clobberers": "Los batidores unicolor", "The end of the world": "El fin del mundo", "Transform an essay": "Transformar un ensayo", "Two kings": "Dos reyes", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index 3cef19e5..5d3dbf1d 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -273,6 +273,7 @@ export const translations = { "Moving forward": "Aller de l'avant", "Neverending rows": "Rangées sans fin", "New fairy pieces": "Nouvelles pièces féériques", + "New teams": "Nouvelles équipes", "No paralyzed pieces": "Pas de pièces paralysées", "No-check mode": "Mode sans échec", "Noise and confusion (v1)": "Bruit et confusion (v1)", @@ -324,7 +325,6 @@ export const translations = { "Thai Chess (v1)": "Échecs thai (v1)", "Thai Chess (v2)": "Échecs thai (v2)", "Thai Chess (v3)": "Échecs thai (v3)", - "The colorbound clobberers": "Les tabasseurs unicolores", "The end of the world": "La fin du monde", "Transform an essay": "Transformer un essai", "Two kings": "Deux rois", diff --git a/client/src/translations/rules/Colorbound/en.pug b/client/src/translations/rules/Cwda/en.pug similarity index 98% rename from client/src/translations/rules/Colorbound/en.pug rename to client/src/translations/rules/Cwda/en.pug index 091d83c4..603c8d7e 100644 --- a/client/src/translations/rules/Colorbound/en.pug +++ b/client/src/translations/rules/Cwda/en.pug @@ -1,4 +1,5 @@ p.boxed + | TODO: other armies as well | Black pieces are replaced by a new army, where most pieces are quite | colorbound. diff --git a/client/src/translations/rules/Colorbound/es.pug b/client/src/translations/rules/Cwda/es.pug similarity index 100% rename from client/src/translations/rules/Colorbound/es.pug rename to client/src/translations/rules/Cwda/es.pug diff --git a/client/src/translations/rules/Colorbound/fr.pug b/client/src/translations/rules/Cwda/fr.pug similarity index 100% rename from client/src/translations/rules/Colorbound/fr.pug rename to client/src/translations/rules/Cwda/fr.pug diff --git a/client/src/translations/rules/Musketeer/en.pug b/client/src/translations/rules/Musketeer/en.pug index e90cbe9b..11b265c6 100644 --- a/client/src/translations/rules/Musketeer/en.pug +++ b/client/src/translations/rules/Musketeer/en.pug @@ -62,7 +62,7 @@ ul li Cannon (C) = King + Wide Knight + Dabbabah li Unicorn (U) = Knight + Camel li Elephant (E) = King + Alfil + Dabbabh - li Hawk (H) = Alfil + Tripper + li Hawk (H) = Jumps 2 or 3 squares in any direction li Fortress (F) = Narrow Knight + Dabbabah + Bishop[3] li Spider (S) = Knight + Dabbabah + Bishop[2] @@ -70,9 +70,6 @@ p With ul li Alfil = two squares leaper in diagonal li Dabbabah = 2 squares leaper orthogonally - li - a(href="http://gambiter.com/chess/variants/Tripper_chess.html") Tripper - |  = 3 squares leaper diagonally li. Camel = extended Knight, 3 squares in one direction and then 1 to the side diff --git a/client/src/translations/rules/Musketeer/es.pug b/client/src/translations/rules/Musketeer/es.pug index 3a1534d4..f5d0fcda 100644 --- a/client/src/translations/rules/Musketeer/es.pug +++ b/client/src/translations/rules/Musketeer/es.pug @@ -65,7 +65,7 @@ ul li Canon (C) = Rey + Wide Knight + Dabbabah li Unicornio (U) = Caballo + Camello li Elefante (E) = Rey + Alfil + Dabbabah - li Halcón (H) = Alfil + Tripper + li Halcón (H) = Salta 2 o 3 casillas en cualquier dirección li Fortaleza (F) = Narrow Knight + Dabbabah + Alfil[3] li Araña (S) = Caballo + Dabbabah + Alfil[2] diff --git a/client/src/translations/rules/Musketeer/fr.pug b/client/src/translations/rules/Musketeer/fr.pug index de221b21..7fd48254 100644 --- a/client/src/translations/rules/Musketeer/fr.pug +++ b/client/src/translations/rules/Musketeer/fr.pug @@ -66,7 +66,7 @@ ul li Canon (C) = Roi + Wide Knight + Dabbabah li Licorne (U) = Cavalier + Chameau li Éléphant (E) = Roi + Alfil + Dabbabah - li Faucon (H) = Alfil + Tripper + li Faucon (H) = Saute 2 ou 3 cases dans n'importe quelle direction li Forteresse (F) = Narrow Knight + Dabbabah + Fou[3] li Araignée (S) = Cavalier + Dabbabah + Fou[2] diff --git a/client/src/translations/rules/Shinobi/en.pug b/client/src/translations/rules/Shinobi/en.pug index 0b55d722..ec54eb07 100644 --- a/client/src/translations/rules/Shinobi/en.pug +++ b/client/src/translations/rules/Shinobi/en.pug @@ -4,18 +4,18 @@ p.boxed. figure.diagram-container .diagram - | fen:rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/3CK3: + | fen:rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/LH1CK1HL: figcaption Deterministic initial position. p. Shinobi Chess is a chess variant designed in 2021 by Couch Tomato. The chess army (the "Kingdom", black) has invaded the land of the Sakura - Clan ("pink"). While initially unprepared and having very few pieces + Clan ("pink"). While initially unprepared and having few pieces available, the Clan is very resourceful and can instantly recruit and summon allies to defend at a minute's notice! p. - The Clan starts with almost all of its pieces in hand, and can drop them + The Clan starts with many of its pieces in hand, and can drop them on its side of the board (first 4 ranks) in lieu of moving a piece. p diff --git a/client/src/translations/rules/Shinobi/es.pug b/client/src/translations/rules/Shinobi/es.pug index e15dcd1a..1f69a12d 100644 --- a/client/src/translations/rules/Shinobi/es.pug +++ b/client/src/translations/rules/Shinobi/es.pug @@ -4,18 +4,18 @@ p.boxed. figure.diagram-container .diagram - | fen:rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/3CK3: + | fen:rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/LH1CK1HL: figcaption Posición inicial determinista. p. Ajedrez Shinobi es una variación desarrollada por Couch Tomato en 2021. El ejército ortodoxo (el "Reino", negras) invadió las tierras del Clan - Sakura ("rosa"). Aunque inicialmente no estaba preparado y con poca - recursos, el Clan no debe ser subestimado porque puede reclutar + Sakura ("rosa"). Aunque inicialmente no estaba preparado y con pocas + piezas, el Clan no debe ser subestimado porque puede reclutar nuevos aliados sin demora! p. - El Clan comienza con casi todas sus piezas en la mano y puede las + El Clan comienza con muchas de sus piezas en la mano y puede las paracaídas en su lado del tablero (primeras 4 filas) en lugar de mover una pieza. diff --git a/client/src/translations/rules/Shinobi/fr.pug b/client/src/translations/rules/Shinobi/fr.pug index ae6a9db4..ab57aa2b 100644 --- a/client/src/translations/rules/Shinobi/fr.pug +++ b/client/src/translations/rules/Shinobi/fr.pug @@ -4,7 +4,7 @@ p.boxed. figure.diagram-container .diagram - | fen:rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/3CK3: + | fen:rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/LH1CK1HL: figcaption Position initiale déterministe. p. @@ -15,7 +15,7 @@ p. nouveaux alliés sans délais ! p. - Le Clan démarre avec presque toutes ses pièces en main, et peut les + Le Clan démarre avec beaucoup de ses pièces en main, et peut les parachuter de son côté de l'échiquier (4 premières rangées) au lieu de déplacer une pièce. diff --git a/client/src/variants/Colorbound.js b/client/src/variants/Cwda.js similarity index 98% rename from client/src/variants/Colorbound.js rename to client/src/variants/Cwda.js index 90e54dc4..6e30e681 100644 --- a/client/src/variants/Colorbound.js +++ b/client/src/variants/Cwda.js @@ -2,7 +2,7 @@ import { ChessRules, Move, PiPo } from "@/base_rules"; import { ArrayFun } from "@/utils/array"; import { randInt } from "@/utils/alea"; -export class ColorboundRules extends ChessRules { +export class CwdaRules extends ChessRules { static get PawnSpecs() { return Object.assign( @@ -18,7 +18,7 @@ export class ColorboundRules extends ChessRules { getPpath(b) { if ([V.C_ROOK, V.C_KNIGHT, V.C_BISHOP, V.C_QUEEN].includes(b[1])) - return "Colorbound/" + b; + return "Cwda/" + b; return b; } diff --git a/client/src/variants/Joker.js b/client/src/variants/Joker.js index 137249c4..fd302bbb 100644 --- a/client/src/variants/Joker.js +++ b/client/src/variants/Joker.js @@ -76,6 +76,19 @@ export class JokerRules extends ChessRules { return moving.concat(swapping); } + postPlay(move) { + super.postPlay(move); + // Was my king swapped? + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) + this.kingPos[move.appear[1].c] = [move.appear[1].x, move.appear[1].y]; + } + + postUndo(move) { + super.postUndo(move); + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) + this.kingPos[move.vanish[1].c] = [move.vanish[1].x, move.vanish[1].y]; + } + static get VALUES() { return Object.assign({ j: 2 }, ChessRules.VALUES); } diff --git a/client/src/variants/Musketeer.js b/client/src/variants/Musketeer.js index 7fa39302..14ba9192 100644 --- a/client/src/variants/Musketeer.js +++ b/client/src/variants/Musketeer.js @@ -328,19 +328,19 @@ export class MusketeerRules extends ChessRules { outerLoop: for (let step of steps) { let i = x + step[0]; let j = y + step[1]; - let stepCounter = 1; + let stepCounter = 0; while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) { moves.push(this.getBasicMove([x, y], [i, j])); + stepCounter++; if ( !!nbSteps && // Next condition to remain compatible with super method - (isNaN(parseInt(nbSteps, 10)) || nbSteps >= stepCounter) + (stepCounter >= nbSteps || isNaN(parseInt(nbSteps, 10))) ) { continue outerLoop; } i += step[0]; j += step[1]; - stepCounter++; } if (V.OnBoard(i, j) && this.canTake([x, y], [i, j])) moves.push(this.getBasicMove([x, y], [i, j])); diff --git a/client/src/variants/Shinobi.js b/client/src/variants/Shinobi.js index dbce82c8..995d2b91 100644 --- a/client/src/variants/Shinobi.js +++ b/client/src/variants/Shinobi.js @@ -60,7 +60,7 @@ export class ShinobiRules extends ChessRules { if (!ChessRules.IsGoodFen(fen)) return false; const fenParsed = V.ParseFen(fen); // 5) Check reserve - if (!fenParsed.reserve || !fenParsed.reserve.match(/^[0-2]{6,6}$/)) + if (!fenParsed.reserve || !fenParsed.reserve.match(/^[0-2]{5,5}$/)) return false; return true; } @@ -74,12 +74,14 @@ export class ShinobiRules extends ChessRules { } // In hand initially: ninja, dragon, 2 x (monk, horse), lance, pawn. - static GenRandInitFen(randomness) { - const baseFen = ChessRules.GenRandInitFen(Math.min(randomness, 1)); - return ( - baseFen.substr(0, 35) + "3CK3 " + - "w 0 " + baseFen.substr(48, 2) + " - 112211" - ); + static GenRandInitFen(options) { + const baseFen = ChessRules.GenRandInitFen(options); + const position = baseFen.substr(0, 43) + .replace('Q', 'C') + .replace(/B/g, '1') + .replace(/R/g, 'L') + .replace(/N/g, 'H'); + return position + " w 0 " + baseFen.substr(48, 2) + " - 11211"; } getFen() { @@ -105,8 +107,7 @@ export class ShinobiRules extends ChessRules { [V.DRAGON]: reserve[1], [V.MONK]: reserve[2], [V.HORSE]: reserve[3], - [V.LANCE]: reserve[4], - [V.PAWN]: reserve[5] + [V.LANCE]: reserve[4] } }; } @@ -122,7 +123,7 @@ export class ShinobiRules extends ChessRules { } static get RESERVE_PIECES() { - return [V.NINJA, V.DRAGON, V.MONK, V.HORSE, V.LANCE, V.PAWN]; + return [V.NINJA, V.DRAGON, V.MONK, V.HORSE, V.LANCE]; } getReserveMoves([x, y]) { @@ -386,7 +387,7 @@ export class ShinobiRules extends ChessRules { { c: 4, j: 7, - d: 7, + d: 6, m: 2, h: 2, l: 2 diff --git a/client/src/variants/Suction.js b/client/src/variants/Suction.js index d12f83d2..2bf3ecf7 100644 --- a/client/src/variants/Suction.js +++ b/client/src/variants/Suction.js @@ -174,20 +174,16 @@ export class SuctionRules extends ChessRules { postPlay(move) { super.postPlay(move); - if (move.vanish.length == 2) { - // Was opponent king swapped? - if (move.vanish[1].p == V.KING) - this.kingPos[this.turn] = [move.appear[1].x, move.appear[1].y]; - } + // Was opponent king swapped? + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) + this.kingPos[this.turn] = [move.appear[1].x, move.appear[1].y]; this.cmoves.push(this.getCmove(move)); } postUndo(move) { super.postUndo(move); - if (move.appear.length == 2) { - if (move.appear[1].p == V.KING) - this.kingPos[move.vanish[1].c] = [move.vanish[1].x, move.vanish[1].y]; - } + if (move.appear.length == 2 && move.appear[1].p == V.KING) + this.kingPos[move.vanish[1].c] = [move.vanish[1].x, move.vanish[1].y]; this.cmoves.pop(); } diff --git a/server/db/populate.sql b/server/db/populate.sql index 1cb54e6a..c55a1b8b 100644 --- a/server/db/populate.sql +++ b/server/db/populate.sql @@ -48,7 +48,6 @@ insert or ignore into Variants (name, description, groupe, display) values ('Chess960', 'Standard rules', -1, 'Chess960'), ('Circular', 'Run forward', 3, 'Circular Chess'), ('Clorange', 'A Clockwork Orange', 20, 'Clockwork Orange'), - ('Colorbound', 'The colorbound clobberers', 5, 'Colorbound Clobberers'), ('Convert', 'Convert enemy pieces', 12, 'Convert'), ('Copycat', 'Borrow powers', 30, 'Copycat'), ('Coregal', 'Two royal pieces', 9, 'Coregal'), @@ -56,6 +55,7 @@ insert or ignore into Variants (name, description, groupe, display) values ('Crazyhouse', 'Captures reborn', 20, 'Crazyhouse'), ('Crossing', 'Cross the river', 27, 'Crossing'), ('Cylinder', 'Neverending rows', 3, 'Cylindrical Chess'), + ('Cwda', 'New teams', 5, 'Different armies'), ('Diamond', 'Rotating board', 4, 'Diamond'), ('Discoduel', 'Enter the disco', 0, 'Disco Duel'), ('Dobutsu', 'Let''s catch the Lion!', 0, 'Dobutsu'),