X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRecycle.js;h=bf252632241c8ca04483a62cbb5511673b9c25aa;hb=ad2494bd14f9a2fd068d713df0f8ac1fb3c3743f;hp=8980c721c6698cabd3ea7de6ea9611962585aba2;hpb=32f6285ee325a14286562a53baefc647201df2af;p=vchess.git diff --git a/client/src/variants/Recycle.js b/client/src/variants/Recycle.js index 8980c721..bf252632 100644 --- a/client/src/variants/Recycle.js +++ b/client/src/variants/Recycle.js @@ -21,16 +21,10 @@ export class RecycleRules extends ChessRules { static ParseFen(fen) { const fenParts = fen.split(" "); - return Object.assign(ChessRules.ParseFen(fen), { - reserve: fenParts[5] - }); - } - - getEpSquare(moveOrSquare) { - if (typeof moveOrSquare !== "object" || moveOrSquare.vanish.length > 0) - return super.getEpSquare(moveOrSquare); - // Landing move: no en-passant - return undefined; + return Object.assign( + ChessRules.ParseFen(fen), + { reserve: fenParts[5] } + ); } static GenRandInitFen(randomness) { @@ -150,12 +144,13 @@ export class RecycleRules extends ChessRules { } getAllValidMoves() { - let moves = super.getAllValidMoves(); + let moves = super.getAllPotentialMoves(); const color = this.turn; - for (let i = 0; i < V.RESERVE_PIECES.length; i++) + for (let i = 0; i < V.RESERVE_PIECES.length; i++) { moves = moves.concat( this.getReserveMoves([V.size.x + (color == "w" ? 0 : 1), i]) ); + } return this.filterValid(moves); } @@ -180,7 +175,8 @@ export class RecycleRules extends ChessRules { prePlay(move) { super.prePlay(move); - if (move.vanish.length == 2 && move.appear.length == 2) return; //skip castle + // Skip castle: + if (move.vanish.length == 2 && move.appear.length == 2) return; const color = this.turn; if (move.vanish.length == 0) this.reserve[color][move.appear[0].p]--; else if (move.vanish.length == 2 && move.vanish[1].c == color)