5b1c80ed636f4dc58452aba9a8d8949b098f67d0
[xogo.git] / variants / Capablanca / class.js
1 import ChessRules from "/base_rules.js";
2 import {FenUtil} from "/utils/setupPieces.js";
3
4 export default class CapablancaRules extends ChessRules {
5
6 get pawnPromotions() {
7 return ['q', 'e', 's', 'r', 'n', 'b'];
8 }
9
10 pieces(color, x, y) {
11 let newPieces = {
12 'e': {
13 "class": "empress",
14 both: [
15 {
16 steps: [
17 [1, 0], [-1, 0], [0, 1], [0, -1]
18 ]
19 },
20 {
21 steps: [
22 [1, 2], [1, -2], [-1, 2], [-1, -2],
23 [2, 1], [-2, 1], [2, -1], [-2, -1]
24 ],
25 range: 1
26 }
27 ]
28 },
29 's': {
30 "class": "princess",
31 both: [
32 {
33 steps: [
34 [1, 1], [1, -1], [-1, 1], [-1, -1]
35 ]
36 },
37 {
38 steps: [
39 [1, 2], [1, -2], [-1, 2], [-1, -2],
40 [2, 1], [-2, 1], [2, -1], [-2, -1]
41 ],
42 range: 1
43 }
44 ]
45 }
46 };
47 return Object.assign(newPieces, super.pieces(color, x, y));
48 }
49
50 get size() {
51 return {
52 x: 8,
53 y: 10,
54 ratio: 1.25
55 };
56 }
57
58 genRandInitBaseFen() {
59 const s = FenUtil.setupPieces(
60 ['r', 'n', 's', 'b', 'q', 'k', 'b', 'e', 'n', 'r'],
61 {
62 randomness: this.options["randomness"],
63 between: [{p1: 'k', p2: 'r'}],
64 diffCol: ['b'],
65 flags: ['r']
66 }
67 );
68 return {
69 fen: s.b.join("") + "/pppppppppp/91/91/91/91/PPPPPPPPPP/" +
70 s.w.join("").toUpperCase(),
71 o: {flags: s.flags}
72 };
73 }
74
75 };