From: Benjamin Auder Date: Thu, 4 Jun 2020 21:21:42 +0000 (+0200) Subject: Add Queenpawns + small fix to vs pawns variants + remove HQ inventor (webmaster but... X-Git-Url: https://git.auder.net/variants/%24%7Bvname%7D/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=9f88188c42120d985c6c280d2712a3b7f6f7c86c;p=vchess.git Add Queenpawns + small fix to vs pawns variants + remove HQ inventor (webmaster but not creator) --- diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 41c007af..42112a4f 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -244,6 +244,7 @@ export const translations = { "Protect your pawns": "Protect your pawns", "Push and pull": "Push and pull", "Queen disguised as a pawn": "Queen disguised as a pawn", + "Queen versus pawns": "Queen versus pawns", "Reach the last rank (v1)": "Reach the last rank (v1)", "Reach the last rank (v2)": "Reach the last rank (v2)", "Reposition pieces": "Reposition pieces", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index bc25339d..379daaee 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -244,6 +244,7 @@ export const translations = { "Protect your pawns": "Protege tus peones", "Push and pull": "Empujar y tirar", "Queen disguised as a pawn": "Reina disfrazada de peón", + "Queen versus pawns": "Dama contra peones", "Reach the last rank (v1)": "Llegar a la última fila (v1)", "Reach the last rank (v2)": "Llegar a la última fila (v2)", "Reposition pieces": "Reposicionar las piezas", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index 869a68d3..dce01310 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -244,6 +244,7 @@ export const translations = { "Protect your pawns": "Protégez vos pions", "Push and pull": "Pousser et tirer", "Queen disguised as a pawn": "Reine déguisée en pion", + "Queen versus pawns": "Dame contre pions", "Reach the last rank (v1)": "Atteignez la dernière rangée (v1)", "Reach the last rank (v2)": "Atteignez la dernière rangée (v2)", "Reposition pieces": "Replacer les pièces", diff --git a/client/src/translations/rules/Hiddenqueen/en.pug b/client/src/translations/rules/Hiddenqueen/en.pug index 40fb0135..07cc31ee 100644 --- a/client/src/translations/rules/Hiddenqueen/en.pug +++ b/client/src/translations/rules/Hiddenqueen/en.pug @@ -20,10 +20,7 @@ h3 Source p a(href="https://dames-cachees.herokuapp.com/rules") This website - |  introduces the rules and allow to play in live, + |  developed by Etienne Orieux (2019) + | introduces the rules and allow to play in live, | with a deterministic initial position but a user-defined | location of the hiden queen. - -p - a(href="https://github.com/orieuxe") Inventor - |  - see the repo "dames-cachees" - (2019) diff --git a/client/src/translations/rules/Hiddenqueen/es.pug b/client/src/translations/rules/Hiddenqueen/es.pug index ad7e50ea..aeb58cdb 100644 --- a/client/src/translations/rules/Hiddenqueen/es.pug +++ b/client/src/translations/rules/Hiddenqueen/es.pug @@ -21,10 +21,7 @@ h3 Fuente p a(href = "https://dames-cachees.herokuapp.com/rules") Este sitio web - |  presenta las reglas y te permite jugar en vivo, + |  desarrollado por Etienne Orieux (2019) + | presenta las reglas y te permite jugar en vivo, | con una posición inicial determinista pero dejando elegir | la ubicación de la dama escondida - -p - a(href="https://github.com/orieuxe") Inventor - |  - ver el repo "dames-cachees" - (2019) diff --git a/client/src/translations/rules/Hiddenqueen/fr.pug b/client/src/translations/rules/Hiddenqueen/fr.pug index 8e0724be..8006b340 100644 --- a/client/src/translations/rules/Hiddenqueen/fr.pug +++ b/client/src/translations/rules/Hiddenqueen/fr.pug @@ -21,10 +21,7 @@ h3 Source p a(href="https://dames-cachees.herokuapp.com/rules") Ce site web - |  présente les règles et permet de jouer en direct, + |  développé par Etienne Orieux (2019) + | présente les règles et permet de jouer en direct, | avec une position initiale déterministe mais en laissant choisir | l'emplacement de la dame cachée. - -p - a(href="https://github.com/orieuxe") Inventeur - |  - voir le repo "dames-cachees" - (2019) diff --git a/client/src/translations/rules/Queenpawns/en.pug b/client/src/translations/rules/Queenpawns/en.pug new file mode 100644 index 00000000..1eecf9d1 --- /dev/null +++ b/client/src/translations/rules/Queenpawns/en.pug @@ -0,0 +1,20 @@ +p.boxed + | A queen versus eight pawns. + +figure.diagram-container + .diagram + | fen:3q4/8/8/8/8/8/PPPPPPPP/8: + figcaption Initial position + +p. + The pawns win if one reaches the other end + without being immediately captured. + The queen wins if it captures all the pawns. + +h3 Source + +p + | Inspired by + a(href="https://chessplus.net/interactive-games/") + | Bishop vs 3 Pawns + |  on chessplus.net. diff --git a/client/src/translations/rules/Queenpawns/es.pug b/client/src/translations/rules/Queenpawns/es.pug new file mode 100644 index 00000000..e7ed7886 --- /dev/null +++ b/client/src/translations/rules/Queenpawns/es.pug @@ -0,0 +1,20 @@ +p.boxed + | Una dama contra ocho peones. + +figure.diagram-container + .diagram + | fen:3q4/8/8/8/8/8/PPPPPPPP/8: + figcaption Posición inicial + +p. + Los peones ganan si uno de ellos llega al otro lado sin ser + inmediatamente capturado. + La dama gana si se come todos los peones. + +h3 Fuente + +p + | Inspirado por + a(href="https://chessplus.net/interactive-games/") + | Bishop vs 3 Pawns + |  en chessplus.net. diff --git a/client/src/translations/rules/Queenpawns/fr.pug b/client/src/translations/rules/Queenpawns/fr.pug new file mode 100644 index 00000000..106723a2 --- /dev/null +++ b/client/src/translations/rules/Queenpawns/fr.pug @@ -0,0 +1,20 @@ +p.boxed + | Une dame contre huit pions. + +figure.diagram-container + .diagram + | fen:3q4/8/8/8/8/8/PPPPPPPP/8: + figcaption Position initiale + +p. + Les pions gagnent si l'un d'eux arrive de l'autre côté sans être + immédiatement capturé. + La dame gagne si elle mange tous les pions. + +h3 Source + +p + | Inspiré par + a(href="https://chessplus.net/interactive-games/") + | Bishop vs 3 Pawns + |  sur chessplus.net. diff --git a/client/src/variants/Bishopawns.js b/client/src/variants/Bishopawns.js index 1ee9b97a..67afe66c 100644 --- a/client/src/variants/Bishopawns.js +++ b/client/src/variants/Bishopawns.js @@ -36,8 +36,12 @@ export class BishopawnsRules extends ChessRules { } // Did a black pawn promote? Can the bishop take it? const qIdx = this.board[7].findIndex(cell => cell[1] == V.QUEEN); - if (qIdx >= 0 && !super.isAttackedByBishop([7, qIdx], 'w')) + if ( + qIdx >= 0 && + (this.turn == 'b' || !super.isAttackedByBishop([7, qIdx], 'w')) + ) { return "0-1"; + } if (!this.atLeastOneMove()) return "1/2"; return "*"; } diff --git a/client/src/variants/Knightpawns.js b/client/src/variants/Knightpawns.js index 6b7415cc..96476535 100644 --- a/client/src/variants/Knightpawns.js +++ b/client/src/variants/Knightpawns.js @@ -34,10 +34,14 @@ export class KnightpawnsRules extends ChessRules { if (this.board.every(b => b.every(cell => !cell || cell[0] != c))) return (c == 'w' ? "0-1" : "1-0"); } - // Did a black pawn promote? Can the rook take it? + // Did a black pawn promote? Can the knight take it? const qIdx = this.board[7].findIndex(cell => cell[1] == V.QUEEN); - if (qIdx >= 0 && !super.isAttackedByKnight([7, qIdx], 'w')) + if ( + qIdx >= 0 && + (this.turn == 'b' || !super.isAttackedByKnight([7, qIdx], 'w')) + ) { return "0-1"; + } if (!this.atLeastOneMove()) return "1/2"; return "*"; } diff --git a/client/src/variants/Queenpawns.js b/client/src/variants/Queenpawns.js new file mode 100644 index 00000000..8ffe111b --- /dev/null +++ b/client/src/variants/Queenpawns.js @@ -0,0 +1,55 @@ +import { ChessRules } from "@/base_rules"; + +export class QueenpawnsRules extends ChessRules { + static get PawnSpecs() { + return Object.assign( + {}, + ChessRules.PawnSpecs, + // The promotion piece doesn't matter, the game is won + { promotions: [V.QUEEN] } + ); + } + + static get HasFlags() { + return false; + } + + scanKings() {} + + static GenRandInitFen() { + return "3q4/8/8/8/8/8/PPPPPPPP/8 w 0 -"; + } + + filterValid(moves) { + return moves; + } + + getCheckSquares() { + return []; + } + + getCurrentScore() { + // If all pieces of some color vanished, the opponent wins: + for (let c of ['w', 'b']) { + if (this.board.every(b => b.every(cell => !cell || cell[0] != c))) + return (c == 'w' ? "0-1" : "1-0"); + } + // Did a white pawn promote? Can the queen (in turn) take it? + const qIdx = this.board[0].findIndex(cell => cell == "wq"); + if ( + qIdx >= 0 && + (this.turn == 'w' || !super.isAttackedByQueen([0, qIdx], 'b')) + ) { + return "1-0"; + } + if (!this.atLeastOneMove()) return "1/2"; + return "*"; + } + + postPlay() {} + postUndo() {} + + static get SEARCH_DEPTH() { + return 4; + } +}; diff --git a/client/src/variants/Rookpawns.js b/client/src/variants/Rookpawns.js index abbd7853..2d0c3a85 100644 --- a/client/src/variants/Rookpawns.js +++ b/client/src/variants/Rookpawns.js @@ -36,8 +36,12 @@ export class RookpawnsRules extends ChessRules { } // Did a black pawn promote? Can the rook take it? const qIdx = this.board[7].findIndex(cell => cell[1] == V.QUEEN); - if (qIdx >= 0 && !super.isAttackedByRook([7, qIdx], 'w')) + if ( + qIdx >= 0 && + (this.turn == 'b' || !super.isAttackedByRook([7, qIdx], 'w')) + ) { return "0-1"; + } if (!this.atLeastOneMove()) return "1/2"; return "*"; } diff --git a/server/db/populate.sql b/server/db/populate.sql index 6b664a55..f55889ae 100644 --- a/server/db/populate.sql +++ b/server/db/populate.sql @@ -86,6 +86,7 @@ insert or ignore into Variants (name, description) values ('Perfect', 'Powerful pieces'), ('Pocketknight', 'Knight in pocket'), ('Progressive', 'Play more and more moves'), + ('Queenpawns', 'Queen versus pawns'), ('Racingkings', 'Kings cross the 8x8 board'), ('Rampage', 'Move under cover'), ('Rifle', 'Shoot pieces'),