f996be5c372d0a282d848d7b628b2149bea6f9a0
1 import ChessRules
from "/base_rules.js";
3 // TODO: there was an issue: I forgot which.. TOFIND and TOFIX :)
5 export default class CopycatRules
extends ChessRules
{
9 select: C
.Options
.select
,
10 input: C
.Options
.input
,
11 styles: C
.Options
.styles
.filter(s
=> !["madrasi", "zen"].includes(s
))
15 getStepSpec(color
, x
, y
) {
16 let res
= super.getStepSpec(color
, x
, y
);
17 const piece
= this.getPiece(x
,y
);
18 if (['p', 'k'].includes(piece
))
20 // Now check if the piece at x, y attack some friendly one (enhancement)
22 const steps
= this.pieces()[piece
].both
[0].steps
;
24 let [i
, j
] = [x
+ s
[0], y
+ s
[1]];
27 this.board
[i
][j
] == "" &&
33 if (this.onBoard(i
, j
) && this.getColor(i
, j
) == color
) {
34 const attacked
= this.getPiece(i
, j
);
35 if (['r', 'b', 'n'].includes(attacked
)) {
36 if (!movements
[attacked
])
37 movements
[attacked
] = true;
39 else if (attacked
== 'q') {
41 movements
['r'] = true;
43 movements
['b'] = true;
47 Object
.keys(movements
).forEach(type
=> {
48 if ((piece
!= 'q' && type
!= piece
) || (piece
== 'q' && type
== 'n'))
49 res
.both
.push(this.pieces()[type
].both
[0]);