3e8d391ae673f64496ffeb2ca30e978542b39db8
1 import ChessRules
from "/base_rules.js";
3 export default class AbsorptionRules
extends ChessRules
{
7 select: C
.Options
.select
,
31 [0, 1], [0, -1], [1, 0], [-1, 0],
32 [1, 1], [1, -1], [-1, 1], [-1, -1]
37 [1, 2], [1, -2], [-1, 2], [-1, -2],
38 [2, 1], [-2, 1], [2, -1], [-2, -1]
50 [1, 0], [-1, 0], [0, 1], [0, -1]
55 [1, 2], [1, -2], [-1, 2], [-1, -2],
56 [2, 1], [-2, 1], [2, -1], [-2, -1]
68 [1, 1], [1, -1], [-1, 1], [-1, -1]
73 [1, 2], [1, -2], [-1, 2], [-1, -2],
74 [2, 1], [-2, 1], [2, -1], [-2, -1]
81 return Object
.assign(fusions
, super.pieces(color
, x
, y
));
84 static get MergeComposed() {
100 // Assumption p1 != p2
101 static Fusion(p1
, p2
) {
108 if ([p1
, p2
].includes("n")) {
109 if ([p1
, p2
].includes("q"))
111 if ([p1
, p2
].includes("r"))
113 if ([p1
, p2
].includes("b"))
115 // p1 or p2 already have knight + other piece
116 return (p1
== "n" ? p2 : p1
);
118 if ([p1
, p2
].includes("a"))
120 // No king, no pawn, no knight or amazon => 5 remaining pieces
121 return V
.MergeComposed
[[p1
, p2
].sort().join("")];
124 // TODO: interaction with rifle ?
125 postProcessPotentialMoves(moves
) {
126 // Filter out capturing promotions (except one),
127 // because they are all the same.
128 moves
= moves
.filter(m
=> {
130 m
.vanish
.length
== 1 ||
131 m
.vanish
[0].p
!= "p" ||
132 ["p", "q"].includes(m
.appear
[0].p
)
137 m
.vanish
.length
== 2 &&
138 m
.appear
.length
== 1 &&
139 m
.vanish
[0].p
!= m
.vanish
[1].p
141 // Augment pieces abilities in case of captures
142 m
.appear
[0].p
= V
.Fusion(m
.vanish
[0].p
, m
.vanish
[1].p
);
145 return super.postProcessPotentialMoves(moves
);