1 import ChessRules
from "/base_rules.js";
3 export default class AbsorptionRules
extends ChessRules
{
7 select: C
.Options
.select
,
32 [0, 1], [0, -1], [1, 0], [-1, 0],
33 [1, 1], [1, -1], [-1, 1], [-1, -1]
38 [1, 2], [1, -2], [-1, 2], [-1, -2],
39 [2, 1], [-2, 1], [2, -1], [-2, -1]
51 [1, 0], [-1, 0], [0, 1], [0, -1]
56 [1, 2], [1, -2], [-1, 2], [-1, -2],
57 [2, 1], [-2, 1], [2, -1], [-2, -1]
69 [1, 1], [1, -1], [-1, 1], [-1, -1]
74 [1, 2], [1, -2], [-1, 2], [-1, -2],
75 [2, 1], [-2, 1], [2, -1], [-2, -1]
82 return Object
.assign(fusions
, super.pieces(color
, x
, y
));
85 static get MergeComposed() {
101 // Assumption p1 != p2
102 static Fusion(p1
, p2
) {
109 if ([p1
, p2
].includes("n")) {
110 if ([p1
, p2
].includes("q"))
112 if ([p1
, p2
].includes("r"))
114 if ([p1
, p2
].includes("b"))
116 // p1 or p2 already have knight + other piece
117 return (p1
== "n" ? p2 : p1
);
119 if ([p1
, p2
].includes("a"))
121 // No king, no pawn, no knight or amazon => 5 remaining pieces
122 return V
.MergeComposed
[[p1
, p2
].sort().join("")];
125 // TODO: interaction with rifle ?
126 postProcessPotentialMoves(moves
) {
127 // Filter out capturing promotions (except one),
128 // because they are all the same.
129 moves
= moves
.filter(m
=> {
131 m
.vanish
.length
== 1 ||
132 m
.vanish
[0].p
!= "p" ||
133 ["p", "q"].includes(m
.appear
[0].p
)
138 m
.vanish
.length
== 2 &&
139 m
.appear
.length
== 1 &&
140 m
.vanish
[0].p
!= m
.vanish
[1].p
142 // Augment pieces abilities in case of captures
143 m
.appear
[0].p
= V
.Fusion(m
.vanish
[0].p
, m
.vanish
[1].p
);
146 return super.postProcessPotentialMoves(moves
);