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