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