X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fbase_rules.js;h=b39fe9c457aa51fefad719cae5292e69fa066471;hb=f9c36b2da005b596ad656f4b6cc4e09ef3c656f1;hp=93772b9bd48958442730c768c64dfb35d4b7ee20;hpb=7ba4a5bc5b64e19a1e7f26aa232d5c50770d07ad;p=vchess.git diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 93772b9b..b39fe9c4 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -197,12 +197,13 @@ export const ChessRules = class ChessRules { const move = moveOrSquare; const s = move.start, e = move.end; - // NOTE: next conditions are first for Atomic, and last for Checkered + // NOTE: next conditions are first for Crazyhouse, and last for Checkered + // TODO: Checkered exceptions are too weird and should move in its own file. if ( - move.appear.length > 0 && + move.vanish.length > 0 && Math.abs(s.x - e.x) == 2 && s.y == e.y && - move.appear[0].p == V.PAWN && + move.vanish[0].p == V.PAWN && ["w", "b"].includes(move.appear[0].c) ) { return { @@ -240,7 +241,6 @@ export const ChessRules = class ChessRules { // Setup the initial random (asymmetric) position static GenRandInitFen(randomness) { - if (!randomness) randomness = 2; if (randomness == 0) // Deterministic: return "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w 0 1111 -"; @@ -320,16 +320,24 @@ export const ChessRules = class ChessRules { // Return current fen (game state) getFen() { return ( - this.getBaseFen() + - " " + - this.getTurnFen() + - " " + + this.getBaseFen() + " " + + this.getTurnFen() + " " + this.movesCount + (V.HasFlags ? " " + this.getFlagsFen() : "") + (V.HasEnpassant ? " " + this.getEnpassantFen() : "") ); } + getFenForRepeat() { + // Omit movesCount, only variable allowed to differ + return ( + this.getBaseFen() + "_" + + this.getTurnFen() + + (V.HasFlags ? "_" + this.getFlagsFen() : "") + + (V.HasEnpassant ? "_" + this.getEnpassantFen() : "") + ); + } + // Position part of the FEN string getBaseFen() { let position = "";