Improved PGN and game seek
[vchess.git] / public / javascripts / base_rules.js
index f08c272..c0dc826 100644 (file)
@@ -51,9 +51,9 @@ class ChessRules
        {
                this.moves = moves;
                // Use fen string to initialize variables, flags and board
-               this.initVariables(fen);
                this.board = VariantRules.GetBoard(fen);
                this.flags = VariantRules.GetFlags(fen);
+               this.initVariables(fen);
        }
 
        initVariables(fen)
@@ -712,7 +712,7 @@ class ChessRules
                VariantRules.PlayOnBoard(this.board, move);
        }
 
-       undo(move, ingame)
+       undo(move)
        {
                VariantRules.UndoOnBoard(this.board, move);
                this.epSquares.pop();
@@ -1037,14 +1037,15 @@ class ChessRules
        }
 
        // The score is already computed when calling this function
-       getPGN(mycolor, score, fenStart)
+       getPGN(mycolor, score, fenStart, mode)
        {
                let pgn = "";
                pgn += '[Site "vchess.club"]<br>';
                const d = new Date();
+               const opponent = this.mode=="human" ? "Anonymous" : "Computer";
                pgn += '[Date "' + d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate() + '"]<br>';
-               pgn += '[White "' + (mycolor=='w'?'Myself':'Anonymous') + '"]<br>';
-               pgn += '[Black "' + (mycolor=='b'?'Myself':'Anonymous') + '"]<br>';
+               pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]<br>';
+               pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]<br>';
                pgn += '[Fen "' + fenStart + '"]<br>';
                pgn += '[Result "' + score + '"]<br><br>';