X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FBaroque%2Fclass.js;h=84331a2a29a344cccd2c303385494124437b8dfd;hb=66ab134b7ab3ba00204fb316ba7636c904331d6c;hp=edf1dd56401ee04253f57aa5c73b9efe9a9967b1;hpb=a89fb4e9c92632a2e8295048a86d7a0ae0a7ec46;p=xogo.git diff --git a/variants/Baroque/class.js b/variants/Baroque/class.js index edf1dd5..84331a2 100644 --- a/variants/Baroque/class.js +++ b/variants/Baroque/class.js @@ -1,9 +1,6 @@ -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 { @@ -36,27 +33,25 @@ 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() { @@ -104,8 +99,8 @@ export default class BaroqueRules extends AbstractSpecialCaptureRules { 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 (