bf3684afc9f8c866096a4ec444074d40d7972c76
1 import ChessRules
from "/base_rules.js";
3 export default class CoronationRules
extends ChessRules
{
5 get hasSelfCaptures() {
9 canSelfTake([x1
, y1
], [x2
, y2
]) {
10 const c
= this.getColor(x1
, y1
);
12 this.board
.some(row
=>
14 square
[0] == c
&& square
[1] == 'q')
17 // Already a queen on the board: no coronation
20 const [p1
, p2
] = [this.getPiece(x1
, y1
), this.getPiece(x2
, y2
)];
21 return ((p1
== 'r' && p2
== 'b') || (p1
== 'b' && p2
== 'r'));
24 getPotentialMovesOf(piece
, [x
, y
]) {
25 const res
= super.getPotentialMovesOf(piece
, [x
, y
]);
26 if (['r', 'b'].includes(piece
)) {
29 m
.vanish
.length
== 2 &&
30 m
.appear
.length
== 1 &&
31 m
.vanish
[1].c
== m
.vanish
[0].c