1 import ChessRules
from "/base_rules.js";
2 import PiPo
from "/utils/PiPo.js";
3 import Move
from "/utils/Move.js";
5 export default class AtomicRules
extends ChessRules
{
9 select: C
.Options
.select
,
18 label: "Falling pawn",
24 styles: C
.Options
.styles
.filter(s
=> s
!= "atomic")
29 o
.options
["atomic"] = true;
34 if (this.options
["rempawn"] && this.movesCount
== 0)
35 return (this.playerColor
== this.turn
&& this.getPiece(x
, y
) == "p");
36 return super.canIplay(x
, y
);
39 getPotentialMovesFrom([x
, y
], color
) {
40 if (this.options
["rempawn"] && this.movesCount
== 0) {
41 if ([1, 6].includes(x
)) {
42 const c
= this.getColor(x
, y
);
54 start: { x: x
, y: y
},
61 return super.getPotentialMovesFrom([x
, y
], color
);
65 if (!this.options
["rempawn"] || this.movesCount
>= 1)
66 return super.doClick(square
);
67 const [x
, y
] = [square
[0], square
[1]];
68 const moves
= this.getPotentialMovesFrom([x
, y
]);
69 return (moves
.length
>= 1 ? moves
[0] : null);