X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FChakart%2Fclass.js;h=5202b489dfeaad00f5a74cac6f4a678a87a7cc94;hb=HEAD;hp=6ddc37c6ff736f76984362eac225cc2368861101;hpb=616a8d7ae5ee96fe23d393cf6e4554b2cf3b9245;p=xogo.git diff --git a/variants/Chakart/class.js b/variants/Chakart/class.js index 6ddc37c..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'], @@ -594,6 +600,10 @@ export default class ChakartRules extends ChessRules { const coords = getRandomPiece(oldColor); if (coords) { const piece = this.getPiece(coords[0], coords[1]); + if (coords[0] == move.start.x && coords[1] == move.start.y) { + // Moving piece change color: fix coords + coords = [move.end.x, move.end.y]; + } em = new Move({ appear: [ new PiPo({x: coords[0], y: coords[1], c: newColor, p: piece}) @@ -626,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({ @@ -648,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