X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fbase_rules.js;h=b39fe9c457aa51fefad719cae5292e69fa066471;hp=d2b8a7fd98e1dab4d6531d6522687afd1fd37b7a;hb=f9c36b2da005b596ad656f4b6cc4e09ef3c656f1;hpb=8d1fcc37a933554e13bc996b5611f8307a4701e8 diff --git a/client/src/base_rules.js b/client/src/base_rules.js index d2b8a7fd..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 { @@ -319,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 = "";