X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRecycle.js;h=de0ff5017b9cef5fa255a77ab757d29b1792e532;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=bf252632241c8ca04483a62cbb5511673b9c25aa;hpb=0e0010227e46acb7774d134c9aa345eaa0c4404d;p=vchess.git diff --git a/client/src/variants/Recycle.js b/client/src/variants/Recycle.js index bf252632..de0ff501 100644 --- a/client/src/variants/Recycle.js +++ b/client/src/variants/Recycle.js @@ -2,6 +2,7 @@ import { ChessRules, PiPo, Move } from "@/base_rules"; import { ArrayFun } from "@/utils/array"; export class RecycleRules extends ChessRules { + static get PawnSpecs() { return Object.assign( {}, @@ -27,8 +28,8 @@ export class RecycleRules extends ChessRules { ); } - static GenRandInitFen(randomness) { - return ChessRules.GenRandInitFen(randomness) + " 0000000000"; + static GenRandInitFen(options) { + return ChessRules.GenRandInitFen(options) + " 0000000000"; } getFen() { @@ -54,22 +55,23 @@ export class RecycleRules extends ChessRules { setOtherVariables(fen) { super.setOtherVariables(fen); - const fenParsed = V.ParseFen(fen); // Also init reserves (used by the interface to show landable pieces) + const reserve = + V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10)); this.reserve = { w: { - [V.PAWN]: parseInt(fenParsed.reserve[0]), - [V.ROOK]: parseInt(fenParsed.reserve[1]), - [V.KNIGHT]: parseInt(fenParsed.reserve[2]), - [V.BISHOP]: parseInt(fenParsed.reserve[3]), - [V.QUEEN]: parseInt(fenParsed.reserve[4]) + [V.PAWN]: reserve[0], + [V.ROOK]: reserve[1], + [V.KNIGHT]: reserve[2], + [V.BISHOP]: reserve[3], + [V.QUEEN]: reserve[4] }, b: { - [V.PAWN]: parseInt(fenParsed.reserve[5]), - [V.ROOK]: parseInt(fenParsed.reserve[6]), - [V.KNIGHT]: parseInt(fenParsed.reserve[7]), - [V.BISHOP]: parseInt(fenParsed.reserve[8]), - [V.QUEEN]: parseInt(fenParsed.reserve[9]) + [V.PAWN]: reserve[5], + [V.ROOK]: reserve[6], + [V.KNIGHT]: reserve[7], + [V.BISHOP]: reserve[8], + [V.QUEEN]: reserve[9] } }; } @@ -84,6 +86,14 @@ export class RecycleRules extends ChessRules { return this.board[i][j].charAt(1); } + getPPpath(m) { + if (m.vanish.length == 2 && m.appear.length == 2) { + // Castle: show castle symbol + return "Coregal/castle"; + } + return super.getPPpath(m); + } + // Used by the interface: getReservePpath(index, color) { return color + V.RESERVE_PIECES[index]; @@ -124,10 +134,9 @@ export class RecycleRules 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]); } @@ -227,4 +236,5 @@ export class RecycleRules extends ChessRules { move.appear[0].p != V.PAWN ? move.appear[0].p.toUpperCase() : ""; return piece + "@" + V.CoordsToSquare(move.end); } + };