X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=860495a4236c3109bf77874172f353b7b878be2b;hb=098e8468ae7a52a55850c09f90506f52b8133567;hp=07ff7150d03ce7fad510aec628676aaa495eae47;hpb=68f5ccc8cc5e6b034b4fee199f6d353fe448a1dc;p=vchess.git diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 07ff7150..860495a4 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -10,6 +10,7 @@ class PiPo //Piece+Position } } +// TODO: for animation, moves should contains "moving" and "fading" maybe... class Move { // o: {appear, vanish, [start,] [end,]} @@ -821,7 +822,9 @@ class ChessRules this.shouldReturn = false; const maxeval = VariantRules.INFINITY; const color = this.turn; - let moves1 = this.getAllValidMoves(); + // Some variants may show a bigger moves list to the human (Switching), + // thus the argument "computer" below (which is generally ignored) + let moves1 = this.getAllValidMoves("computer"); // Can I mate in 1 ? (for Magnetic & Extinction) for (let i of _.shuffle(_.range(moves1.length))) @@ -843,7 +846,7 @@ class ChessRules { eval2 = (color=="w" ? 1 : -1) * maxeval; //initialized with checkmate value // Second half-move: - let moves2 = this.getAllValidMoves(); + let moves2 = this.getAllValidMoves("computer"); for (let j=0; j { return (x<10 ? "0" : "") + x; }; let pgn = ""; 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 += '[Date "' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + zeroPad(d.getDate()) + '"]
'; pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]
'; pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]
'; - pgn += '[Fen "' + fenStart + '"]
'; + pgn += '[FenStart "' + fenStart + '"]
'; + pgn += '[Fen "' + this.getFen() + '"]
'; pgn += '[Result "' + score + '"]

'; // Standard PGN @@ -1152,7 +1151,7 @@ class ChessRules pgn += ((i/2)+1) + "."; pgn += this.moves[i].notation[0] + " "; } - pgn += score + "

"; + pgn += "

"; // "Complete moves" PGN (helping in ambiguous cases) for (let i=0; i