e92edab21f1c67d1b016bd520af8731ee99a7fb6
1 import ChessRules
from "/base_rules.js";
3 export default class AbstractAntikingRules
extends ChessRules
{
6 return Object
.assign({'A': AbstractAntikingRules
}, ChessRules
.Aliases
);
32 // Move like a king, no attacks
34 moves: super.pieces(color
, x
, y
)['k'].moves
,
38 super.pieces(color
, x
, y
)
44 p
= this.getPiece(x
, y
);
45 return ['k', 'a'].includes(p
);
48 // NOTE: canTake includes (wrong) captures of antiking,
49 // to not go to low-level using findDestSquares()
50 canTake([x1
, y1
], [x2
, y2
]) {
51 const piece1
= this.getPiece(x1
, y1
);
52 const color1
= this.getColor(x1
, y1
);
53 const color2
= this.getColor(x2
, y2
);
55 (piece1
!= 'a' && color1
!= color2
) ||
56 (piece1
== 'a' && color1
== color2
)
60 // Remove captures of antiking (see above)
61 getPotentialMovesFrom([x
, y
]) {
62 return super.getPotentialMovesFrom([x
, y
]).filter(m
=>
63 m
.vanish
.length
== 1 || m
.vanish
[1].p
!= 'a');
66 underCheck(squares
, color
) {
68 squares
.forEach(sq
=> {
69 switch (this.getPiece(sq
[0], sq
[1])) {
71 res
||= super.underAttack(sq
, color
);
74 res
||= !super.underAttack(sq
, color
);