ea91a2785ad00e2e9f71bb66ab324c715bbf7868
1 import ChessRules
from "/base_rules.js";
3 export default class AbsorptionRules
extends ChessRules
{
7 select: C
.Options
.select
,
8 input: C
.Options
.input
,
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]
49 [1, 0], [-1, 0], [0, 1], [0, -1]
54 [1, 2], [1, -2], [-1, 2], [-1, -2],
55 [2, 1], [-2, 1], [2, -1], [-2, -1]
66 [1, 1], [1, -1], [-1, 1], [-1, -1]
71 [1, 2], [1, -2], [-1, 2], [-1, -2],
72 [2, 1], [-2, 1], [2, -1], [-2, -1]
79 return Object
.assign(fusions
, super.pieces(color
, x
, y
));
82 static get MergeComposed() {
98 // Assumption p1 != p2
99 static Fusion(p1
, p2
) {
106 if ([p1
, p2
].includes("n")) {
107 if ([p1
, p2
].includes("q"))
109 if ([p1
, p2
].includes("r"))
111 if ([p1
, p2
].includes("b"))
113 // p1 or p2 already have knight + other piece
114 return (p1
== "n" ? p2 : p1
);
116 if ([p1
, p2
].includes("a"))
118 // No king, no pawn, no knight or amazon => 5 remaining pieces
119 return V
.MergeComposed
[[p1
, p2
].sort().join("")];
122 // TODO: interaction with rifle ?
123 postProcessPotentialMoves(moves
) {
124 // Filter out capturing promotions (except one),
125 // because they are all the same.
126 moves
= moves
.filter(m
=> {
128 m
.vanish
.length
== 1 ||
129 m
.vanish
[0].p
!= "p" ||
130 ["p", "q"].includes(m
.appear
[0].p
)
135 m
.vanish
.length
== 2 &&
136 m
.appear
.length
== 1 &&
137 m
.vanish
[0].p
!= m
.vanish
[1].p
139 // Augment pieces abilities in case of captures
140 m
.appear
[0].p
= V
.Fusion(m
.vanish
[0].p
, m
.vanish
[1].p
);
143 return super.postProcessPotentialMoves(moves
);