From: Benjamin Auder Date: Sat, 2 Jul 2022 13:31:56 +0000 (+0200) Subject: Fix Chakart X-Git-Url: https://git.auder.net/variants/Chakart/doc/scripts/img/pieces/index.css?a=commitdiff_plain;h=9ac672172c605f9f5ea4355b8f743bcf189601fe;p=xogo.git Fix Chakart --- diff --git a/base_rules.js b/base_rules.js index beac0bb..4296ec5 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1629,7 +1629,7 @@ export default class ChessRules { m.appear.shift(); return; } - let finalPieces = ["p"]; + let finalPieces; if ( this.options["cannibal"] && this.board[x2][y2] != "" && @@ -1643,12 +1643,9 @@ export default class ChessRules { if (initPiece == "!") //cannibal king-pawn m.appear[0].p = C.CannibalKingCode[finalPieces[0]]; for (let i=1; i 0 && - move.appear[0].p == 'p' && - ( - (color == 'w' && move.end.x == 0) || - (color == 'b' && move.end.x == this.size.x - 1) - ) - ) { - // "Forgotten" promotion, which occurred after some effect - let moves = [move]; - super.pawnPostProcess(moves, color, oppCol); - super.showChoices(moves); - return false; - } - this.postPlay(move, color, oppCol); - return true; - } - - postPlay(move, color, oppCol) { this.egg = move.egg; if (move.egg == "toadette") { this.reserve = { w: {}, b: {} }; @@ -480,6 +461,25 @@ export default class ChakartRules extends ChessRules { this.displayBonus(move); } + buildMoveStack(move, r) { + const color = this.turn; + if ( + move.appear.length > 0 && + move.appear[0].p == 'p' && + ( + (color == 'w' && move.end.x == 0) || + (color == 'b' && move.end.x == this.size.x - 1) + ) + ) { + // "Forgotten" promotion, which occurred after some effect + let moves = [move]; + super.pawnPostProcess(moves, color, C.GetOppCol(color)); + super.showChoices(moves, r); + } + else + super.buildMoveStack(move, r); + } + computeNextMove(move) { // Set potential random effects, so that play() is deterministic // from opponent viewpoint: @@ -559,8 +559,17 @@ export default class ChakartRules extends ChessRules { let bagOfPieces = []; for (let i=0; i 0) + ) + ) { bagOfPieces.push([i, j]); + } } } if (bagOfPieces.length >= 1)