From: Benjamin Auder Date: Wed, 3 Jan 2024 00:40:00 +0000 (+0100) Subject: Chakart: fixing attempt X-Git-Url: https://git.auder.net/img/scripts/%7B%7B%20asset%28%27mixstore/images/DESCRIPTION?a=commitdiff_plain;h=130a166fd08355be5f2dfc923777c1c6d03f09ce;p=xogo.git Chakart: fixing attempt --- diff --git a/variants/Chakart/class.js b/variants/Chakart/class.js index 2b502b6..3454d8f 100644 --- a/variants/Chakart/class.js +++ b/variants/Chakart/class.js @@ -130,6 +130,12 @@ export default class ChakartRules extends ChessRules { ); } + isKing(x, y, p) { + if (!p) + p = this.getPiece(x, y); + return ['k', 'l'].includes(p); + } + genRandInitBaseFen() { const s = FenUtil.setupPieces( ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'], @@ -630,19 +636,25 @@ export default class ChakartRules extends ChessRules { }); break; case "koopa": - // Reverse move + // Reverse move, if possible em = new Move({ - appear: [ - new PiPo({ - x: move.start.x, y: move.start.y, c: color, p: move.appear[0].p - }) - ], + appear: [], vanish: [ new PiPo({ x: move.end.x, y: move.end.y, c: color, p: move.appear[0].p }) - ] + ], + end: {x: move.start.x, y: move.start.y} //may be irrelevant }); + em.koopa = true; //avoid applying effect + if (move.vanish.length == 0) + // After toadette+drop, just erase piece + break; + em.appear.push( + new PiPo({ + x: move.start.x, y: move.start.y, c: color, p: move.appear[0].p + }) + ); if (this.board[move.start.x][move.start.y] != "") { // Pawn or knight let something on init square em.vanish.push(new PiPo({ @@ -652,7 +664,6 @@ export default class ChakartRules extends ChessRules { p: this.getPiece(move.start.x, move.start.y) })); } - em.koopa = true; //avoid applying effect break; case "chomp": // Eat piece