Small fixes
[vchess.git] / client / src / variants / Rookpawns.js
CommitLineData
737a5daf
BA
1import { ChessRules } from "@/base_rules";
2
3export class RookpawnsRules extends ChessRules {
7e8a7ea1 4
4313762d
BA
5 static get Options() {
6 return null;
7 }
8
737a5daf
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 "8/ppppp3/8/8/8/8/8/7R 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 rook take it?
43 const qIdx = this.board[7].findIndex(cell => cell[1] == V.QUEEN);
9f88188c
BA
44 if (
45 qIdx >= 0 &&
46 (this.turn == 'b' || !super.isAttackedByRook([7, qIdx], 'w'))
47 ) {
737a5daf 48 return "0-1";
9f88188c 49 }
737a5daf
BA
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
737a5daf 61};