e7d3c071c7a9dd705736ed7b68c46001d478929a
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
) &&
14 (p1
!= V
.QUEEN
|| p2
== V
.KNIGHT
) &&
15 (p2
!= V
.QUEEN
|| p1
== V
.KNIGHT
)
19 getPotentialMovesFrom(sq
) {
21 const piece
= this.getPiece(sq
[0], sq
[1]);
25 super.getPotentialRookMoves(sq
).concat(
26 super.getPotentialKnightMoves(sq
));
30 super.getPotentialBishopMoves(sq
).concat(
31 super.getPotentialKnightMoves(sq
));
35 super.getPotentialQueenMoves(sq
).concat(
36 super.getPotentialKnightMoves(sq
));
39 moves
= super.getPotentialPawnMoves(sq
);
42 moves
= super.getPotentialRookMoves(sq
);
45 moves
= super.getPotentialKnightMoves(sq
);
48 moves
= super.getPotentialBishopMoves(sq
);
51 moves
= super.getPotentialQueenMoves(sq
);
54 moves
= super.getPotentialKingMoves(sq
);
59 m
.vanish
.length
== 2 && m
.appear
.length
== 1 &&
60 piece
!= m
.vanish
[1].p
&& m
.vanish
[0].c
== m
.vanish
[1].c
62 // Augment pieces abilities in case of self-captures
63 m
.appear
[0].p
= V
.Fusion(piece
, m
.vanish
[1].p
);