X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FSuction%2Fclass.js;h=cf5ae1682b74f56431b25632926c3b4b8bfaf421;hb=f3e90e30b6e7ff416afe288bc9dd865e5daf9860;hp=f9cf26dc33ad67f822936101490d2c8cfe2442a4;hpb=f54357573d4fdf87a05b19f78506c11f16bb3a26;p=xogo.git diff --git a/variants/Suction/class.js b/variants/Suction/class.js index f9cf26d..cf5ae16 100644 --- a/variants/Suction/class.js +++ b/variants/Suction/class.js @@ -42,11 +42,14 @@ 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() { @@ -104,10 +107,19 @@ export default class SuctionRules extends ChessRules { getCurrentScore() { const color = this.turn; const kingPos = super.searchKingPos(color); - if (color == "w" && kingPos[0] == 0) return "0-1"; - if (color == "b" && kingPos[0] == this.size.x - 1) return "1-0"; + if (color == "w" && kingPos[0][0] == 0) return "0-1"; + if (color == "b" && kingPos[0][0] == this.size.x - 1) return "1-0"; // King is not on the opposite edge: game not over 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; + } + };