New variant idea
[xogo.git] / variants / Discoduel / class.js
CommitLineData
3232aba3
BA
1import ChessRules from "/base_rules.js";
2import {ArrayFun} from "/utils/array.js"
3
4export default class DiscoduelRules extends ChessRules {
5
6 static get Options() {
7 return {}; //nothing would make sense
8 }
9
10 get pawnPromotions() {
11 return ['p'];
12 }
13
14 get hasFlags() {
15 return false;
16 }
17
18 genRandInitBaseFen() {
19 return {
20 fen: "1n4n1/8/8/8/8/8/PPPPPPPP/8",
21 o: {}
22 };
23 }
24
25 getPotentialMovesFrom([x, y]) {
26 const moves = super.getPotentialMovesFrom([x, y]);
27 if (this.turn == 'b')
28 // Prevent pawn captures on last rank:
29 return moves.filter(m => m.vanish.length == 1 || m.vanish[1].x != 0);
30 return moves;
31 }
32
33 filterValid(moves) {
34 return moves;
35 }
36
37 getCurrentScore() {
38 // No real winning condition (promotions count...)
39 if (
40 ArrayFun.range(1, this.size.x).every(row_idx => {
4fcd7ab0
BA
41 return this.board[row_idx].every(square => {
42 return (!square || square.charAt(0) != 'w');
43 })
3232aba3
BA
44 })
45 ||
46 !this.atLeastOneMove(this.turn)
47 ) {
48 return "1/2";
49 }
50 return "*";
51 }
52
53};