X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FChakart%2Fclass.js;h=a0c854b68e08b293e77cf26fae01283d8d6d3943;hb=a2bb7e0621f143f912ca505fed914fe0a5e6d611;hp=c987649711ec308da2cafa024429f22d51ded5e8;hpb=cc9fe4f154ec244cbec468d1a3b5845e56cb378d;p=xogo.git diff --git a/variants/Chakart/class.js b/variants/Chakart/class.js index c987649..a0c854b 100644 --- a/variants/Chakart/class.js +++ b/variants/Chakart/class.js @@ -306,7 +306,7 @@ export default class ChakartRules extends ChessRules { moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY])); } } - this.pawnPostProcess(moves, color, oppCol); + super.pawnPostProcess(moves, color, oppCol); // Add mushroom on before-last square moves.forEach(m => { let revStep = [m.start.x - m.end.x, m.start.y - m.end.y]; @@ -389,6 +389,22 @@ export default class ChakartRules extends ChessRules { } play(move) { + const color = this.turn; + const oppCol = C.GetOppCol(color); + 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, oppCol); + super.showChoices(moves); + return false; + } if (!move.nextComputed) { // Set potential random effects, so that play() is deterministic // from opponent viewpoint: @@ -441,8 +457,6 @@ export default class ChakartRules extends ChessRules { move.nextComputed = true; } this.egg = move.egg; - const color = this.turn; - const oppCol = C.GetOppCol(color); if (move.egg == "toadette") { this.reserve = { w: {}, b: {} }; // Randomly select a piece in pawnPromotions @@ -510,6 +524,7 @@ export default class ChakartRules extends ChessRules { this.displayBonus(move); this.playOnBoard(move); this.nextMove = move.next; + return true; } // Helper to set and apply banana/bomb effect @@ -687,9 +702,10 @@ export default class ChakartRules extends ChessRules { } playPlusVisual(move, r) { - this.moveStack.push(move); const nextLines = () => { - this.play(move); + if (!this.play(move)) + return; + this.moveStack.push(move); this.playVisual(move, r); if (this.nextMove) this.playPlusVisual(this.nextMove, r); @@ -698,7 +714,7 @@ export default class ChakartRules extends ChessRules { this.moveStack = []; } }; - if (this.moveStack.length == 1) + if (this.moveStack.length == 0) nextLines(); else this.animate(move, nextLines);