1 import { ChessRules
, PiPo
, Move
} from "@/base_rules";
3 export class RifleRules
extends ChessRules
{
4 getEpSquare(moveOrSquare
) {
5 if (typeof moveOrSquare
!== "object" || moveOrSquare
.appear
.length
> 0)
6 return super.getEpSquare(moveOrSquare
);
7 // Capturing move: no en-passant
11 getBasicMove([sx
, sy
], [ex
, ey
], tr
) {
18 if (this.board
[ex
][ey
] != V
.EMPTY
) {
19 // No movement: just vanishing enemy piece
24 c: this.getColor(ex
, ey
),
25 p: this.getPiece(ex
, ey
)
35 c: tr
? tr
.c : this.getColor(sx
, sy
),
36 p: tr
? tr
.p : this.getPiece(sx
, sy
)
43 c: this.getColor(sx
, sy
),
44 p: this.getPiece(sx
, sy
)
52 getEnpassantCaptures([x
, y
], shiftX
) {
54 const Lep
= this.epSquares
.length
;
55 const epSquare
= this.epSquares
[Lep
- 1]; //always at least one element
58 epSquare
.x
== x
+ shiftX
&&
59 Math
.abs(epSquare
.y
- y
) == 1
61 let enpassantMove
= new Move({
65 end: {x:x
+shiftX
, y:epSquare
.y
}
67 enpassantMove
.vanish
.push({
71 c: this.getColor(x
, epSquare
.y
)
73 moves
.push(enpassantMove
);
78 static get SEARCH_DEPTH() {