X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShogi.js;h=ac98835a94d23bc5f7ea7b3ca0096b0e79a3cf17;hp=9104ed92d70ea59b64b95ac72bbfbcd3f06170ce;hb=723262f9b77ed0f916e5b9fcbfbae5ddfe94925c;hpb=d2a3ec5202c69db3a4d20ca026defb9e21a790f4 diff --git a/client/src/variants/Shogi.js b/client/src/variants/Shogi.js index 9104ed92..ac98835a 100644 --- a/client/src/variants/Shogi.js +++ b/client/src/variants/Shogi.js @@ -282,7 +282,9 @@ export class ShogiRules extends ChessRules { if (p == V.PAWN) { // Do not drop on checkmate: this.play(mv); - const res = (this.underCheck(oppCol) && !this.atLeastOneMove()); + const res = ( + this.underCheck(oppCol) && !this.atLeastOneMove("noReserve") + ); this.undo(mv); if (res) continue; } @@ -548,14 +550,16 @@ export class ShogiRules extends ChessRules { return this.filterValid(moves); } - atLeastOneMove() { + atLeastOneMove(noReserve) { if (!super.atLeastOneMove()) { - // Search one reserve move - for (let i = 0; i < V.RESERVE_PIECES.length; i++) { - let moves = this.filterValid( - this.getReserveMoves([V.size.x + (this.turn == "w" ? 0 : 1), i]) - ); - if (moves.length > 0) return true; + if (!noReserve) { + // Search one reserve move + for (let i = 0; i < V.RESERVE_PIECES.length; i++) { + let moves = this.filterValid( + this.getReserveMoves([V.size.x + (this.turn == "w" ? 0 : 1), i]) + ); + if (moves.length > 0) return true; + } } return false; }