1 import ChessRules
from "/base_rules.js";
3 export default class AbstractAntikingRules
extends ChessRules
{
6 return Object
.assign({'A': AbstractAntikingRules
}, ChessRules
.Aliases
);
29 let antikingSpec
= super.pieces(color
, x
, y
)['k'];
30 antikingSpec
["class"] = "antiking";
31 return Object
.assign({'a': antikingSpec
}, super.pieces(color
, x
, y
));
36 p
= this.getPiece(x
, y
);
37 return ['k', 'a'].includes(p
);
40 // NOTE: canTake includes (wrong) captures of (anti)king,
41 // to detect attacks on (anti)kings.
42 canTake([x1
, y1
], [x2
, y2
]) {
43 const piece1
= this.getPiece(x1
, y1
);
44 const color1
= this.getColor(x1
, y1
);
45 const color2
= this.getColor(x2
, y2
);
47 (piece1
!= 'a' && color1
!= color2
) ||
48 (piece1
== 'a' && color1
== color2
)
52 // Remove captures of (anti)king (see above)
53 getPotentialMovesFrom([x
, y
]) {
54 return super.getPotentialMovesFrom([x
, y
]).filter(m
=>
55 m
.vanish
.length
== 1 || !['k', 'a'].includes(m
.vanish
[1].p
));
58 underCheck(square_s
, color
) {
60 square_s
.forEach(sq
=> {
61 switch (this.getPiece(sq
[0], sq
[1])) {
63 res
||= super.underAttack(sq
, [color
]);
66 res
||= !super.underAttack(sq
, [color
]);