X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FSuction%2Fclass.js;h=889a37ff1d0e9541f7d1e2563b4b0aca6af65788;hb=f31de5e46015a93dca20765da61670035ce8f491;hp=dbaefa0a72b81888b8fd1ed9c9a9e0228069eb4e;hpb=5f08c59b29c2173cc8b2df1a3799ee971a14e691;p=xogo.git diff --git a/variants/Suction/class.js b/variants/Suction/class.js index dbaefa0..889a37f 100644 --- a/variants/Suction/class.js +++ b/variants/Suction/class.js @@ -41,19 +41,19 @@ export default class SuctionRules extends ChessRules { } } - genRandInitFen(seed) { + genRandInitBaseFen() { const options = Object.assign({mode: "suicide"}, this.options); const gr = new GiveawayRules({options: options, genFenOnly: true}); - // Add empty cmove: - return ( - gr.genRandInitFen(seed).slice(0, -17) + '{"enpassant":"-","cmove":"-"}'); + return gr.genRandInitBaseFen(); } - 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]) { @@ -104,8 +104,8 @@ 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 "*"; }