X-Git-Url: https://git.auder.net/js/rpsls.js?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FCrazyhouse.js;h=64ce48b3a606933a5f4b3e92c3f8d53f40891a02;hb=259035ec507062fdfc7158ac62b68c722404bfdf;hp=ee485448b13f9e0db17eba4cec84c6d5c0660bac;hpb=e50a802531b99829c533f22ecd21e359e7e1e049;p=vchess.git diff --git a/client/src/variants/Crazyhouse.js b/client/src/variants/Crazyhouse.js index ee485448..64ce48b3 100644 --- a/client/src/variants/Crazyhouse.js +++ b/client/src/variants/Crazyhouse.js @@ -2,6 +2,7 @@ import { ChessRules, PiPo, Move } from "@/base_rules"; import { ArrayFun } from "@/utils/array"; export class CrazyhouseRules extends ChessRules { + static IsGoodFen(fen) { if (!ChessRules.IsGoodFen(fen)) return false; const fenParsed = V.ParseFen(fen); @@ -165,10 +166,9 @@ export class CrazyhouseRules extends ChessRules { } getPotentialMovesFrom([x, y]) { - if (x >= V.size.x) { + if (x >= V.size.x) // Reserves, outside of board: x == sizeX(+1) return this.getReserveMoves([x, y]); - } // Standard moves return super.getPotentialMovesFrom([x, y]); } @@ -188,7 +188,7 @@ export class CrazyhouseRules extends ChessRules { if (!super.atLeastOneMove()) { // Search one reserve move for (let i = 0; i < V.RESERVE_PIECES.length; i++) { - let moves = this.filterValid( + const moves = this.filterValid( this.getReserveMoves([V.size.x + (this.turn == "w" ? 0 : 1), i]) ); if (moves.length > 0) return true; @@ -253,4 +253,5 @@ export class CrazyhouseRules extends ChessRules { move.appear[0].p != V.PAWN ? move.appear[0].p.toUpperCase() : ""; return piece + "@" + V.CoordsToSquare(move.end); } + };