1 import { ChessRules
} from "@/base_rules";
2 import { AbsorptionRules
} from "@/variants/Absorption";
4 export class SelfabsorptionRules
extends AbsorptionRules
{
6 canTake([x1
, y1
], [x2
, y2
]) {
7 if (this.getColor(x1
, y1
) !== this.getColor(x2
, y2
)) return true;
8 const p1
= this.getPiece(x1
, y1
);
9 const p2
= this.getPiece(x2
, y2
);
12 [V
.QUEEN
, V
.ROOK
, V
.KNIGHT
, V
.BISHOP
].includes(p1
) &&
13 [V
.QUEEN
, V
.ROOK
, V
.KNIGHT
, V
.BISHOP
].includes(p2
)
17 getPotentialMovesFrom(sq
) {
19 const piece
= this.getPiece(sq
[0], sq
[1]);
23 super.getPotentialRookMoves(sq
).concat(
24 super.getPotentialKnightMoves(sq
));
28 super.getPotentialBishopMoves(sq
).concat(
29 super.getPotentialKnightMoves(sq
));
33 super.getPotentialQueenMoves(sq
).concat(
34 super.getPotentialKnightMoves(sq
));
37 moves
= super.getPotentialPawnMoves(sq
);
40 moves
= super.getPotentialRookMoves(sq
);
43 moves
= super.getPotentialKnightMoves(sq
);
46 moves
= super.getPotentialBishopMoves(sq
);
49 moves
= super.getPotentialQueenMoves(sq
);
52 moves
= super.getPotentialKingMoves(sq
);
57 m
.vanish
.length
== 2 && m
.appear
.length
== 1 &&
58 piece
!= m
.vanish
[1].p
&& m
.vanish
[0].c
== m
.vanish
[1].c
60 // Augment pieces abilities in case of self-captures
61 m
.appear
[0].p
= V
.Fusion(piece
, m
.vanish
[1].p
);