Fix Emergo. Add Avalam 1 & 2
[vchess.git] / client / src / variants / Avalam1.js
1 import { ChessRules } from "@/base_rules";
2 import { Avalam2Rules } from "@/variants/Avalam2";
3
4 export class Avalam1Rules extends Avalam2Rules {
5
6 static get NOTHING() {
7 return "xx";
8 }
9
10 static board2fen(b) {
11 if (b[0] == 'x') return 'x';
12 return ChessRules.board2fen(b);
13 }
14
15 static fen2board(f) {
16 if (f == 'x') return V.NOTHING;
17 return ChessRules.fen2board(f);
18 }
19
20 getPpath(b) {
21 if (b[0] == 'x') return "Omega/nothing";
22 return "Avalam/" + b;
23 }
24
25 static GenRandInitFen() {
26 return (
27 "xxBbxxxxx/xBbBbxxxx/xbBbBbBxx/xBbBbBbBb/BbBb1bBbB/" +
28 "bBbBbBbBx/xxBbBbBbx/xxxxbBbBx/xxxxxbBxx w 0"
29 );
30 }
31
32 static get size() {
33 return { x: 9, y: 9 };
34 }
35
36 static OnBoard(x, y) {
37 if (!ChessRules.OnBoard(x, y)) return false;
38 switch (x) {
39 case 0: return [2, 3].includes(y);
40 case 1: return [1, 2, 3, 4].includes(y);
41 case 2: return [1, 2, 3, 4, 5, 6].includes(y);
42 case 3: return y >= 1;
43 case 4: return y != 4;
44 case 5: return y <= 7;
45 case 6: return [2, 3, 4, 5, 6, 7].includes(y);
46 case 7: return [4, 5, 6, 7].includes(y);
47 case 8: return [5, 6].includes(y);
48 }
49 return false; //never reached
50 }
51
52 };