import ChessRules from "/base_rules.js";
-import AbstractAntikingRules from "/variants/AbstractAntiking.js";
-import { Random } from "/utils/alea.js";
+import AbstractAntikingRules from "/variants/_Antiking/class.js";
+import {Random} from "/utils/alea.js";
-export class Antiking2Rules extends AbstractAntikingRules {
-
- static get Aliases() {
- return Object.assign({'A': AbstractAntikingRules}, ChessRules.Aliases);
- }
+export default class Antiking2Rules extends AbstractAntikingRules {
static get Options() {
return {
+ select: C.Options.select,
styles: A.Options.styles.concat("cylinder")
};
}
- genRandInitFen(seed) {
- const baseFen = super.genRandInitFen(seed);
+ genRandInitBaseFen() {
+ const baseFen = super.genRandInitBaseFen();
// Just add an antiking on 3rd ranks
let akPos = [3, 3];
if (this.options.randomness >= 1) {
else
akPos[1] = akPos[0];
}
- const whiteLine = (akPos[0] > 0 ? akPos[0] : "") + 'A' + (akPos < this.size.y - 1 ? ...);
- const blackLine = ...
- return baseFen.replace(...)
+ const antikingLine = (color) => {
+ const [idx, symbol] = (color == 'w' ? [0, 'a'] : [1, 'A']);
+ return (
+ (akPos[idx] > 0 ? akPos[idx] : "") + symbol +
+ (akPos[idx] < this.size.y - 1
+ ? C.FenEmptySquares(this.size.y - 1 - akPos[idx])
+ : "")
+ );
+ };
+ return {
+ fen: baseFen.fen.replace("p/8", "p/" + antikingLine('b'))
+ .replace("8/P", antikingLine('w') + "/P"),
+ o: baseFen.o
+ };
+ }
+
+ getCastleMoves([x, y]) {
+ if (this.getPiece(x, y) == 'a')
+ return [];
+ return super.getCastleMoves([x, y]);
+ }
+
+ updateCastleFlags(move) {
+ if (move.vanish.length > 0 && move.vanish[0].p == 'a')
+ return;
+ super.updateCastleFlags(move);
}
};