X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FCheckered.js;h=bca365d097a11a374d499244cbe5aefe0a1c3539;hb=57d9b2c4f08948bd5a5fc4a01a0b62d4c80523e2;hp=882a32ac8a465ea49092dcc40f99898da47a5df7;hpb=6f2f94374f1e73c375edf732d9425e575e81fff7;p=vchess.git diff --git a/client/src/variants/Checkered.js b/client/src/variants/Checkered.js index 882a32ac..bca365d0 100644 --- a/client/src/variants/Checkered.js +++ b/client/src/variants/Checkered.js @@ -71,8 +71,8 @@ export class CheckeredRules extends ChessRules { setFlags(fenflags) { super.setFlags(fenflags); //castleFlags this.pawnFlags = { - w: [...Array(8).fill(true)], //pawns can move 2 squares? - b: [...Array(8).fill(true)] + w: [...Array(8)], //pawns can move 2 squares? + b: [...Array(8)] }; const flags = fenflags.substr(4); //skip first 4 letters, for castle for (let c of ["w", "b"]) { @@ -402,19 +402,19 @@ export class CheckeredRules extends ChessRules { getFen() { const L = this.cmoves.length; - const cmoveFen = !this.cmoves[L - 1] - ? "-" - : ChessRules.CoordsToSquare(this.cmoves[L - 1].start) + - ChessRules.CoordsToSquare(this.cmoves[L - 1].end); + const cmoveFen = + !this.cmoves[L - 1] + ? "-" + : ChessRules.CoordsToSquare(this.cmoves[L - 1].start) + + ChessRules.CoordsToSquare(this.cmoves[L - 1].end); return super.getFen() + " " + cmoveFen; } getFlagsFen() { let fen = super.getFlagsFen(); // Add pawns flags - for (let c of ["w", "b"]) { - for (let i = 0; i < 8; i++) fen += this.pawnFlags[c][i] ? "1" : "0"; - } + for (let c of ["w", "b"]) + for (let i = 0; i < 8; i++) fen += (this.pawnFlags[c][i] ? "1" : "0"); return fen; } @@ -429,37 +429,25 @@ export class CheckeredRules extends ChessRules { return "0-0"; } - // Translate final square const finalSquare = V.CoordsToSquare(move.end); - const piece = this.getPiece(move.start.x, move.start.y); + let notation = ""; if (piece == V.PAWN) { // Pawn move - let notation = ""; if (move.vanish.length > 1) { // Capture const startColumn = V.CoordToColumn(move.start.y); - notation = - startColumn + - "x" + - finalSquare + - "=" + - move.appear[0].p.toUpperCase(); - } //no capture - else { - notation = finalSquare; - if (move.appear.length > 0 && piece != move.appear[0].p) - //promotion - notation += "=" + move.appear[0].p.toUpperCase(); - } - return notation; + notation = startColumn + "x" + finalSquare; + } else notation = finalSquare; + } else { + // Piece movement + notation = + piece.toUpperCase() + + (move.vanish.length > 1 ? "x" : "") + + finalSquare; } - // Piece movement - return ( - piece.toUpperCase() + - (move.vanish.length > 1 ? "x" : "") + - finalSquare + - (move.vanish.length > 1 ? "=" + move.appear[0].p.toUpperCase() : "") - ); + if (move.appear[0].p != move.vanish[0].p) + notation += "=" + move.appear[0].p.toUpperCase(); + return notation; } };