1 //https://www.chessvariants.com/large.dir/freeling.html
2 class GrandRules
extends ChessRules
6 const V
= VariantRules
;
7 return ([V
.CAMEL
,V
.WILDEBEEST
].includes(b
[1]) ? "Grand/" : "") + b
;
10 static get MARSHALL() { return 'm'; } //rook+knight
11 static get CARDINAL() { return 'c'; } //bishop+knight
13 // ------> pas les règles exactes, on démarre en 2 avec 1,2 ou 3 cases + enPassant comme Wildebeest
14 // TODO: IN epSquares (return array), not return singleton. Easy. Adapt
15 // just here for now...
18 const [sx
,sy
,ex
] = [move.start
.x
,move.start
.y
,move.end
.x
];
19 if (this.getPiece(sx
,sy
) == VariantRules
.PAWN
&& Math
.abs(sx
- ex
) == 2)
26 return undefined; //default
29 getPotentialMovesFrom([x
,y
])
31 switch (this.getPiece(x
,y
))
33 case VariantRules
.MARSHALL:
34 return this.getPotentialMarshallMoves([x
,y
]);
35 case VariantRules
.CARDINAL:
36 return this.getPotentialCardinalMoves([x
,y
]);
38 return super.getPotentialMovesFrom([x
,y
])
42 // TODO: quite many changes! Especially promotions, only to friendly pieces already captured. ==> keep track of captured material in initVariables()......
43 getPotentialPawnMoves([x
,y
])
47 getPotentialMarshallMoves(sq
)
49 const V
= VariantRules
;
50 return this.getSlideNJumpMoves(sq
, V
.steps
[V
.ROOK
]).concat(
51 this.getSlideNJumpMoves(sq
, V
.steps
[V
.KNIGHT
], "oneStep"));
54 getPotentialCardinalMoves(sq
)
56 const V
= VariantRules
;
57 return this.getSlideNJumpMoves(sq
, V
.steps
[V
.BISHOP
]).concat(
58 this.getSlideNJumpMoves(sq
, V
.steps
[V
.KNIGHT
], "oneStep"));
61 isAttacked(sq
, colors
)
63 return (super.isAttacked(sq
, colors
)
64 || this.isAttackedByMarshall(sq
, colors
)
65 || this.isAttackedByCardinal(sq
, colors
);
68 isAttackedByMarshall(sq
, colors
)
70 const V
= VariantRules
;
71 return this.isAttackedBySlideNJump(sq
, colors
, V
.MARSHALL
, V
.steps
[V
.ROOK
])
72 || this.isAttackedBySlideNJump(sq
, colors
, V
.MARSHALL
, V
.steps
[V
.KNIGHT
], "oneStep");
75 isAttackedByCardinal(sq
, colors
)
77 const V
= VariantRules
;
78 return this.isAttackedBySlideNJump(sq
, colors
, V
.CARDINAL
, V
.steps
[V
.BISHOP
])
79 || this.isAttackedBySlideNJump(sq
, colors
, V
.CARDINAL
, V
.steps
[V
.KNIGHT
], "oneStep");
85 {'c': 5, 'm': 7} //experimental
90 static GenRandInitFen()