-import ChessRules from "/base_rules.js";
-import GiveawayRules from "/variants/Giveaway/class.js";
-import AbstractSpecialCaptureRules from "/variants/_SpecialCaptures.js";
+import AbstractSpecialCaptureRules from "/variants/_SpecialCaptures/class.js";
+import {FenUtil} from "/utils/setupPieces.js";
import {Random} from "/utils/alea.js";
-import PiPo from "/utils/PiPo.js";
-import Move from "/utils/Move.js";
export default class BaroqueRules extends AbstractSpecialCaptureRules {
}
genRandInitBaseFen() {
- if (this.options["randomness"] == 0)
- return "rnbkqbnm/pppppppp/8/8/8/8/PPPPPPPP/MNBQKBNR";
- const options = Object.assign({mode: "suicide"}, this.options);
- const gr = new GiveawayRules({options: options, genFenOnly: true});
- let res = gr.genRandInitBaseFen();
- let immPos = {};
- for (let c of ['w', 'b']) {
- const rookChar = (c == 'w' ? 'R' : 'r');
- switch (Random.randInt(2)) {
- case 0:
- immPos[c] = res.fen.indexOf(rookChar);
- break;
- case 1:
- immPos[c] = res.fen.lastIndexOf(rookChar);
- break;
+ const s = FenUtil.setupPieces(
+ ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'i'],
+ {
+ randomness: this.options["randomness"],
+ diffCol: ['b']
}
+ );
+ if (this.options["randomness"] <= 1) {
+ // Fix immobilizers/rooks pattern
+ const toExchange1 = s.w.indexOf('r'),
+ toExchange2 = s.w.indexOf('i');
+ s.w[toExchange1] = 'i';
+ s.w[toExchange2] = 'r';
}
- res.fen = res.fen.substring(0, immPos['b']) + 'i' +
- res.fen.substring(immPos['b'] + 1, immPos['w']) + 'I' +
- res.fen.substring(immPos['w'] + 1);
- return res;
+ return {
+ fen: s.b.join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" +
+ s.w.join("").toUpperCase(),
+ o: {}
+ };
}
pieces() {
isImmobilized([x, y]) {
const piece = this.getPiece(x, y);
const color = this.getColor(x, y);
- const oppCol = C.GetOppCol(color);
- const adjacentSteps = this.pieces()['k'].moves[0].steps;
+ const oppCol = C.GetOppTurn(color);
+ const adjacentSteps = this.pieces()['k'].both[0].steps;
for (let step of adjacentSteps) {
const [i, j] = [x + step[0], this.getY(y + step[1])];
if (