57a6051a4eeb1eae29bddfda479ef3c9526b6f8f
[vchess.git] / client / src / variants / Bishopawns.js
1 import { ChessRules } from "@/base_rules";
2
3 export class BishopawnsRules extends ChessRules {
4
5 static get Options() {
6 return null;
7 }
8
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 "8/ppp5/8/8/8/8/8/5B2 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 black pawn promote? Can the bishop take it?
43 const qIdx = this.board[7].findIndex(cell => cell[1] == V.QUEEN);
44 if (
45 qIdx >= 0 &&
46 (this.turn == 'b' || !super.isAttackedByBishop([7, qIdx], 'w'))
47 ) {
48 return "0-1";
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 }
60
61 };