X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FSuction%2Fclass.js;h=a66855d407bc1def69668342bb7012addb049911;hb=6b9320bb6e42ece7694df32f85aab4d2989f6a13;hp=db10e58cc4b4acea18d3aa3bdb67b4ae12e5a19f;hpb=fe234391b05ffef5e3236e82ca1391adcb784b45;p=xogo.git diff --git a/variants/Suction/class.js b/variants/Suction/class.js index db10e58..a66855d 100644 --- a/variants/Suction/class.js +++ b/variants/Suction/class.js @@ -42,18 +42,21 @@ export default class SuctionRules extends ChessRules { } genRandInitFen(seed) { - const gr = new GiveawayRules( - {mode: "suicide", options: this.options, genFenOnly: true}); + const options = Object.assign({mode: "suicide"}, this.options); + const gr = new GiveawayRules({options: options, genFenOnly: true}); + const baseFen = gr.genRandInitFen(seed); // Add empty cmove: - return ( - gr.genRandInitFen(seed).slice(0, -17) + '{"enpassant":"-","cmove":"-"}'); + const fenParts = baseFen.split(" "); + let others = JSON.parse(fenParts[3]); + others["cmove"] = "-"; + return fenParts.slice(0, 3).join(" ") + " " + JSON.stringify(others); } getFen() { const cmoveFen = !this.cmove ? "-" : C.CoordsToSquare(this.cmove.start) + C.CoordsToSquare(this.cmove.end); - return super.getFen().slice(0, -1) + ',"' + cmoveFen + '"}'; + return super.getFen().slice(0, -1) + ',"cmove":"' + cmoveFen + '"}'; } getBasicMove([sx, sy], [ex, ey]) { @@ -110,4 +113,13 @@ export default class SuctionRules extends ChessRules { return "*"; } + // Better animation for swaps + customAnimate(move, segments, cb) { + if (move.vanish.length < 2) + return 0; + super.animateMoving(move.end, move.start, null, + segments.reverse().map(s => s.reverse()), cb); + return 1; + } + };