From 0f51ef985c094530a63d242dddf514e66d23959b Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Fri, 23 Nov 2018 18:16:51 +0100 Subject: [PATCH] Improve Alice notation, PGN. Add debugging instruction for Alice --- TODO.pgn | 11 ++ public/images/pieces/Grand/bm.svg | 205 +++++++++++++++++++++++++++ public/javascripts/base_rules.js | 1 + public/javascripts/variants/Alice.js | 54 +++---- 4 files changed, 246 insertions(+), 25 deletions(-) create mode 100644 TODO.pgn create mode 100644 public/images/pieces/Grand/bm.svg diff --git a/TODO.pgn b/TODO.pgn new file mode 100644 index 00000000..dfffdf12 --- /dev/null +++ b/TODO.pgn @@ -0,0 +1,11 @@ +[Site "vchess.club"] +[Variant "Alice"] +[Date "2018-11-23"] +[White "Computer"] +[Black "Myself"] +[Fen "nrkbbqrn/pppppppp/8/8/8/8/PPPPPPPP/BRKQRNNB"] +[Result "1-0"] + +1.Pb4 Pc5 2.Sbxc5 Pb5 3.Rxb8 1-0 + +Move 3.Rxb8 erronously flip b5 pawn diff --git a/public/images/pieces/Grand/bm.svg b/public/images/pieces/Grand/bm.svg new file mode 100644 index 00000000..fd548016 --- /dev/null +++ b/public/images/pieces/Grand/bm.svg @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index c24c84c6..ec5f9372 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -1047,6 +1047,7 @@ class ChessRules pgn += '[Site "vchess.club"]
'; const d = new Date(); const opponent = mode=="human" ? "Anonymous" : "Computer"; + pgn += '[Variant "' + variant + '"]
'; pgn += '[Date "' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate() + '"]
'; pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]
'; pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]
'; diff --git a/public/javascripts/variants/Alice.js b/public/javascripts/variants/Alice.js index 3d79580f..a15c30c3 100644 --- a/public/javascripts/variants/Alice.js +++ b/public/javascripts/variants/Alice.js @@ -189,31 +189,6 @@ class AliceRules extends ChessRules this.kingPos[c] = [move.start.x, move.start.y]; } - getNotation(move) - { - if (move.appear.length == 2 && move.appear[0].p == VariantRules.KING) - { - if (move.end.y < move.start.y) - return "0-0-0"; - else - return "0-0"; - } - - const finalSquare = - String.fromCharCode(97 + move.end.y) + (VariantRules.size[0]-move.end.x); - const piece = this.getPiece(move.start.x, move.start.y); - - // Piece or pawn movement - let notation = piece.toUpperCase() + - (move.vanish.length > move.appear.length ? "x" : "") + finalSquare; - if (['s','p'].includes(piece) && !['s','p'].includes(move.appear[0].p)) - { - // Promotion - notation += "=" + move.appear[0].p.toUpperCase(); - } - return notation; - } - checkGameEnd() { const color = this.turn; @@ -245,4 +220,33 @@ class AliceRules extends ChessRules 'l': 1000 }; } + + getNotation(move) + { + if (move.appear.length == 2 && move.appear[0].p == VariantRules.KING) + { + if (move.end.y < move.start.y) + return "0-0-0"; + else + return "0-0"; + } + + const finalSquare = + String.fromCharCode(97 + move.end.y) + (VariantRules.size[0]-move.end.x); + const piece = this.getPiece(move.start.x, move.start.y); + + const captureMark = (move.vanish.length > move.appear.length ? "x" : ""); + let pawnMark = ""; + if (["p","s"].includes(piece) && captureMark.length == 1) + pawnMark = String.fromCharCode(97 + move.start.y); //start column + + // Piece or pawn movement + let notation = piece.toUpperCase() + pawnMark + captureMark + finalSquare; + if (['s','p'].includes(piece) && !['s','p'].includes(move.appear[0].p)) + { + // Promotion + notation += "=" + move.appear[0].p.toUpperCase(); + } + return notation; + } } -- 2.44.0