X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FSuction%2Fclass.js;h=ff307d4a3d4cde9e5d76255b5e36f7d27c30d63e;hb=HEAD;hp=cf5ae1682b74f56431b25632926c3b4b8bfaf421;hpb=f3e90e30b6e7ff416afe288bc9dd865e5daf9860;p=xogo.git diff --git a/variants/Suction/class.js b/variants/Suction/class.js index cf5ae16..ff307d4 100644 --- a/variants/Suction/class.js +++ b/variants/Suction/class.js @@ -1,5 +1,5 @@ import ChessRules from "/base_rules.js"; -import GiveawayRules from "/variants/Giveaway/class.js"; +import {FenUtil} from "/utils/setupPieces.js"; import PiPo from "/utils/PiPo.js"; import Move from "/utils/Move.js"; @@ -41,22 +41,28 @@ export default class SuctionRules extends ChessRules { } } - genRandInitFen(seed) { - const options = Object.assign({mode: "suicide"}, this.options); - const gr = new GiveawayRules({options: options, genFenOnly: true}); - const baseFen = gr.genRandInitFen(seed); - // Add empty cmove: - const fenParts = baseFen.split(" "); - let others = JSON.parse(fenParts[3]); - others["cmove"] = "-"; - return fenParts.slice(0, 3).join(" ") + " " + JSON.stringify(others); + genRandInitBaseFen() { + const s = FenUtil.setupPieces( + ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'], + { + randomness: this.options["randomness"], + diffCol: ['b'] + } + ); + return { + fen: s.b.join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" + + s.w.join("").toUpperCase(), + o: {} + }; } - getFen() { - const cmoveFen = !this.cmove + getPartFen(o) { + let parts = super.getPartFen(o); + const cmoveFen = o.init || !this.cmove ? "-" : C.CoordsToSquare(this.cmove.start) + C.CoordsToSquare(this.cmove.end); - return super.getFen().slice(0, -1) + ',"cmove":"' + cmoveFen + '"}'; + parts["cmove"] = cmoveFen; + return parts; } getBasicMove([sx, sy], [ex, ey]) {