a1b62284192e16f6b85b3ae4fd5f2ac1edeeb79a
1 import { ChessRules
} from "@/base_rules";
3 export const VariantRules
= class ChaturangaRules
extends ChessRules
{
4 static get HasFlags() {
8 static get HasEnpassant() {
12 static get ElephantSteps() {
21 static GenRandInitFen() {
22 return ChessRules
.GenRandInitFen().replace("w 1111 -", "w");
25 getPotentialPawnMoves([x
, y
]) {
26 const color
= this.turn
;
28 const [sizeX
, sizeY
] = [V
.size
.x
, V
.size
.y
];
29 const shiftX
= color
== "w" ? -1 : 1;
30 const startRank
= color
== "w" ? sizeX
- 2 : 1;
31 const lastRank
= color
== "w" ? 0 : sizeX
- 1;
32 // Promotion in minister (queen) only:
33 const finalPiece
= x
+ shiftX
== lastRank
? V
.QUEEN : V
.PAWN
;
35 if (this.board
[x
+ shiftX
][y
] == V
.EMPTY
) {
38 this.getBasicMove([x
, y
], [x
+ shiftX
, y
], {
45 for (let shiftY
of [-1, 1]) {
49 this.board
[x
+ shiftX
][y
+ shiftY
] != V
.EMPTY
&&
50 this.canTake([x
, y
], [x
+ shiftX
, y
+ shiftY
])
53 this.getBasicMove([x
, y
], [x
+ shiftX
, y
+ shiftY
], {
64 getPotentialBishopMoves(sq
) {
65 let moves
= this.getSlideNJumpMoves(sq
, V
.ElephantSteps
, "oneStep");
66 // Complete with "repositioning moves": like a queen, without capture
67 let repositioningMoves
= this.getSlideNJumpMoves(
71 ).filter(m
=> m
.vanish
.length
== 1);
72 return moves
.concat(repositioningMoves
);
75 getPotentialQueenMoves(sq
) {
76 return this.getSlideNJumpMoves(
83 getPotentialKingMoves(sq
) {
84 return this.getSlideNJumpMoves(
86 V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]),
91 isAttackedByBishop(sq
, colors
) {
92 return this.isAttackedBySlideNJump(
101 isAttackedByQueen(sq
, colors
) {
102 return this.isAttackedBySlideNJump(
111 static get VALUES() {