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
,
17 label: "Falling pawn",
22 styles: C
.Options
.styles
.filter(s
=> s
!= "atomic")
28 this.options
.atomic
= true;
31 genRandInitFen(seed
) {
32 return super.genRandInitFen(seed
).slice(0, -1) + ',"rempawn":' + (this.options
.rempawn
? "1" : "0") + "}";
35 // TODO: capture king option doesn't make sense
37 setOtherVariables(fenParsed
) {
38 super.setOtherVariables(fenParsed
);
39 this.options
["rempawn"] = (fenParsed
.rempawn
== 1);
43 return super.getFen().slice(0, -1) + ',"rempawn":' + (this.options
["rempawn"] ? "1" : "0") + "}";
47 if (this.options
["rempawn"] && this.movesCount
== 0)
48 return (this.turn
== side
&& this.getPiece(x
, y
) == "p");
49 return super.canIplay(x
, y
);
52 getPotentialMovesFrom([x
, y
], color
) {
53 if (this.options
["rempawn"] && this.movesCount
== 0) {
54 if ([1, 6].includes(x
)) {
55 const c
= this.getColor(x
, y
);
67 start: { x: x
, y: y
},
74 return super.getPotentialMovesFrom([x
, y
], color
);
78 if (!this.options
["rempawn"] || this.movesCount
>= 1)
79 return super.doClick(square
);
80 const [x
, y
] = [square
[0], square
[1]];
81 const moves
= this.getPotentialMovesFrom([x
, y
]);
82 return (moves
.length
>= 1 ? moves
[0] : null);