1 import ChessRules
from "/base_rules.js";
3 export default class CopycatRules
extends ChessRules
{
7 select: C
.Options
.select
,
8 input: C
.Options
.input
,
9 styles: C
.Options
.styles
.filter(s
=> !["madrasi", "zen"].includes(s
))
13 getStepSpec(color
, x
, y
) {
14 let res
= super.getStepSpec(color
, x
, y
);
15 const piece
= this.getPiece(x
,y
);
16 if (['p', 'k'].includes(piece
))
18 // Now check if the piece at x, y attack some friendly one (enhancement)
20 const steps
= this.pieces()[piece
].both
[0].steps
;
22 let [i
, j
] = [x
+ s
[0], y
+ s
[1]];
25 this.board
[i
][j
] == "" &&
31 if (this.onBoard(i
, j
) && this.getColor(i
, j
) == color
) {
32 const attacked
= this.getPiece(i
, j
);
33 if (['r', 'b', 'n'].includes(attacked
)) {
34 if (!movements
[attacked
])
35 movements
[attacked
] = true;
37 else if (attacked
== 'q') {
39 movements
['r'] = true;
41 movements
['b'] = true;
45 Object
.keys(movements
).forEach(type
=> {
46 if ((piece
!= 'q' && type
!= piece
) || (piece
== 'q' && type
== 'n'))
47 res
.both
.push(this.pieces()[type
].both
[0]);