From: Benjamin Auder Date: Wed, 26 Dec 2018 12:41:59 +0000 (+0100) Subject: Fix Berolina notation + Marseille PGN X-Git-Url: https://git.auder.net/doc/html/vendor/img/current/%7B%7B?a=commitdiff_plain;h=1b61a94dbd13f6a37a89e62216615d2496c760a2;p=vchess.git Fix Berolina notation + Marseille PGN --- diff --git a/public/javascripts/variants/Berolina.js b/public/javascripts/variants/Berolina.js index be72e2d5..8ea3c9cc 100644 --- a/public/javascripts/variants/Berolina.js +++ b/public/javascripts/variants/Berolina.js @@ -119,14 +119,15 @@ class BerolinaRules extends ChessRules if (piece == V.PAWN) { // Pawn move + const finalSquare = V.CoordsToSquare(move.end); let notation = ""; if (move.vanish.length == 2) //capture - notation = finalSquare; + notation = "Px" + finalSquare; else { - // No capture - const startColumn = V.CoordToColumn(move.start.y); - notation = startColumn + "x" + finalSquare; + // No capture: indicate the initial square for potential ambiguity + const startSquare = V.CoordsToSquare(move.start); + notation = startSquare + finalSquare; } if (move.appear[0].p != V.PAWN) //promotion notation += "=" + move.appear[0].p.toUpperCase(); diff --git a/public/javascripts/variants/Marseille.js b/public/javascripts/variants/Marseille.js index 02daa22b..6e72a236 100644 --- a/public/javascripts/variants/Marseille.js +++ b/public/javascripts/variants/Marseille.js @@ -148,10 +148,12 @@ class MarseilleRules extends ChessRules play(move, ingame) { -// console.log("play " + this.getNotation(move)); -// console.log(this.turn + " "+ this.subTurn); if (!!ingame) + { move.notation = [this.getNotation(move), this.getLongNotation(move)]; + // In this special case, we also need the "move color": + move.color = this.turn; + } move.flags = JSON.stringify(this.aggregateFlags()); let lastEpsq = this.epSquares[this.epSquares.length-1]; const epSq = this.getEpSquare(move); @@ -185,7 +187,6 @@ class MarseilleRules extends ChessRules this.updateVariables(move); if (!!ingame) move.hash = hex_md5(this.getFen()); - //console.log(move.checkOnSubturn1 + " " +this.turn + " "+ this.subTurn); } undo(move) @@ -220,8 +221,6 @@ class MarseilleRules extends ChessRules } this.moves.pop(); this.unupdateVariables(move); -// console.log("UNDO " + this.getNotation(move)); -// console.log(this.turn + " "+ this.subTurn); } // NOTE: GenRandInitFen() is OK, @@ -315,6 +314,55 @@ class MarseilleRules extends ChessRules return selected[0]; return selected; } + + getPGN(mycolor, score, fenStart, mode) + { + let pgn = ""; + pgn += '[Site "vchess.club"]
'; + const opponent = mode=="human" ? "Anonymous" : "Computer"; + pgn += '[Variant "' + variant + '"]
'; + pgn += '[Date "' + getDate(new Date()) + '"]
'; + pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]
'; + pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]
'; + pgn += '[FenStart "' + fenStart + '"]
'; + pgn += '[Fen "' + this.getFen() + '"]
'; + pgn += '[Result "' + score + '"]

'; + + let counter = 1; + let i = 0; + while (i < this.moves.length) + { + pgn += (counter++) + "."; + for (let color of ["w","b"]) + { + let move = ""; + while (i < this.moves.length && this.moves[i].color == color) + move += this.moves[i++].notation[0] + ","; + move = move.slice(0,-1); //remove last comma + pgn += move + (i < this.moves.length-1 ? " " : ""); + } + } + pgn += "

"; + + // "Complete moves" PGN (helping in ambiguous cases) + counter = 1; + i = 0; + while (i < this.moves.length) + { + pgn += (counter++) + "."; + for (let color of ["w","b"]) + { + let move = ""; + while (i < this.moves.length && this.moves[i].color == color) + move += this.moves[i++].notation[1] + ","; + move = move.slice(0,-1); //remove last comma + pgn += move + (i < this.moves.length-1 ? " " : ""); + } + } + + return pgn; + } + } const VariantRules = MarseilleRules; diff --git a/views/rules/Berolina/en.pug b/views/rules/Berolina/en.pug index 60080ea7..5cdfff95 100644 --- a/views/rules/Berolina/en.pug +++ b/views/rules/Berolina/en.pug @@ -14,7 +14,14 @@ ul h3 Basics p. - TODO: explain... + Only the pawn movements change, but since there are many on the board it's a + consequent change. They move diagonally instead of moving forward, and capture by + advancing to the next square vertically. The initial 2-squares jump is allowed, + as well as en-passant captures: after 1.d2b4 on the diagram, + 1...Pxc3 e.p. is possible. + +p. + Note about notation: pawns figure.diagram-container .diagram diff --git a/views/rules/Marseille/en.pug b/views/rules/Marseille/en.pug index f2a5e180..5c66e781 100644 --- a/views/rules/Marseille/en.pug +++ b/views/rules/Marseille/en.pug @@ -29,6 +29,7 @@ p. a double move in the game is indicated as two comma-separated (ordered) moves, as in 3.Na5,Bd3 e6,f4 (the two first are white moves, the two others are black moves). + Sometimes a move gives check, or stalemate occurs after subTurn 1 :: just one move figure.diagram-container .diagram