Almost added TitanChess + EvolutionChess
[vchess.git] / client / src / variants / Pawnsking.js
CommitLineData
737a5daf
BA
1import { ChessRules } from "@/base_rules";
2
3export class PawnskingRules 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 static GenRandInitFen() {
19 return "4k3/pppppppp/8/8/8/8/PPPPPPPP/4K3 w 0 -";
20 }
21
22 filterValid(moves) {
23 return moves;
24 }
25
26 getCheckSquares() {
27 return [];
28 }
29
30 getCurrentScore() {
31 const color = this.turn;
32 if (this.kingPos[color][0] < 0) return (color == "w" ? "0-1" : "1-0");
33 const oppCol = V.GetOppCol(color);
34 const lastRank = (oppCol == 'w' ? 0 : 7);
35 if (this.board[lastRank].some(cell => cell[0] == oppCol))
36 // The opposing edge is reached!
37 return (oppCol == "w" ? "1-0" : "0-1");
38 if (this.atLeastOneMove()) return "*";
39 return "1/2";
40 }
41
42 postPlay(move) {
43 super.postPlay(move);
44 if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
45 this.kingPos[this.turn] = [-1, -1];
46 }
47
48 postUndo(move) {
49 super.postUndo(move);
50 if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
51 this.kingPos[move.vanish[1].c] = [move.vanish[1].x, move.vanish[1].y];
52 }
53
54 static get SEARCH_DEPTH() {
55 return 4;
56 }
7e8a7ea1 57
737a5daf 58};