Fix Eightpieces
[vchess.git] / client / src / variants / Queenpawns.js
CommitLineData
9f88188c
BA
1import { ChessRules } from "@/base_rules";
2
3export class QueenpawnsRules extends ChessRules {
7e8a7ea1 4
4313762d
BA
5 static get Options() {
6 return null;
7 }
8
9f88188c
BA
9 static get PawnSpecs() {
10 return Object.assign(
11 {},
12 ChessRules.PawnSpecs,
13 // The promotion piece doesn't matter, the game is won
14 { promotions: [V.QUEEN] }
15 );
16 }
17
18 static get HasFlags() {
19 return false;
20 }
21
22 scanKings() {}
23
24 static GenRandInitFen() {
25 return "3q4/8/8/8/8/8/PPPPPPPP/8 w 0 -";
26 }
27
28 filterValid(moves) {
29 return moves;
30 }
31
32 getCheckSquares() {
33 return [];
34 }
35
36 getCurrentScore() {
37 // If all pieces of some color vanished, the opponent wins:
38 for (let c of ['w', 'b']) {
39 if (this.board.every(b => b.every(cell => !cell || cell[0] != c)))
40 return (c == 'w' ? "0-1" : "1-0");
41 }
42 // Did a white pawn promote? Can the queen (in turn) take it?
43 const qIdx = this.board[0].findIndex(cell => cell == "wq");
44 if (
45 qIdx >= 0 &&
46 (this.turn == 'w' || !super.isAttackedByQueen([0, qIdx], 'b'))
47 ) {
48 return "1-0";
49 }
50 if (!this.atLeastOneMove()) return "1/2";
51 return "*";
52 }
53
54 postPlay() {}
55 postUndo() {}
56
57 static get SEARCH_DEPTH() {
58 return 4;
59 }
7e8a7ea1 60
9f88188c 61};