X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRookpawns.js;fp=client%2Fsrc%2Fvariants%2FRookpawns.js;h=abbd78533348db654fa4f4f4e521a7f480994c61;hb=737a5dafb39740ebe304b8d0a82df85070def571;hp=0000000000000000000000000000000000000000;hpb=1b56b73614509d1dca8c4353f18fb78349940cf8;p=vchess.git diff --git a/client/src/variants/Rookpawns.js b/client/src/variants/Rookpawns.js new file mode 100644 index 00000000..abbd7853 --- /dev/null +++ b/client/src/variants/Rookpawns.js @@ -0,0 +1,51 @@ +import { ChessRules } from "@/base_rules"; + +export class RookpawnsRules 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 "8/ppppp3/8/8/8/8/8/7R 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 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')) + return "0-1"; + if (!this.atLeastOneMove()) return "1/2"; + return "*"; + } + + postPlay() {} + postUndo() {} + + static get SEARCH_DEPTH() { + return 4; + } +};