Attempt to clarify installation instructions a little
[vchess.git] / client / src / variants / Knightpawns.js
CommitLineData
737a5daf
BA
1import { ChessRules } from "@/base_rules";
2
3export class KnightpawnsRules 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/ppp5/8/8/8/8/8/6N1 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 }
9f88188c 42 // Did a black pawn promote? Can the knight take it?
737a5daf 43 const qIdx = this.board[7].findIndex(cell => cell[1] == V.QUEEN);
9f88188c
BA
44 if (
45 qIdx >= 0 &&
46 (this.turn == 'b' || !super.isAttackedByKnight([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() {}
7e8a7ea1 56
737a5daf 57};