X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShogi.js;h=bca37627025f6dde7caa9a835da4863813b9d4c2;hb=cee75a57d2f4f89c89d64cefbab55d839a238ed9;hp=63c0d726642f40f974bb4741ae7b31688ffc0681;hpb=6c00a6e55209930057bcf040cf444f40e7d47030;p=vchess.git diff --git a/client/src/variants/Shogi.js b/client/src/variants/Shogi.js index 63c0d726..bca37627 100644 --- a/client/src/variants/Shogi.js +++ b/client/src/variants/Shogi.js @@ -16,10 +16,19 @@ export class ShogiRules extends ChessRules { return true; } + get showFirstTurn() { + return true; + } + static get Notoodark() { return true; } + loseOnRepetition() { + // If current side is under check: lost + return this.underCheck(this.turn); + } + static IsGoodFen(fen) { if (!ChessRules.IsGoodFen(fen)) return false; const fenParsed = V.ParseFen(fen); @@ -278,7 +287,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; } @@ -544,14 +555,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; }