- pgn += '[Variant "' + variant + '"]<br>';
- pgn += '[Date "' + getDate(new Date()) + '"]<br>';
- pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]<br>';
- pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]<br>';
- pgn += '[FenStart "' + fenStart + '"]<br>';
- pgn += '[Fen "' + this.getFen() + '"]<br>';
- pgn += '[Result "' + score + '"]<br><br>';
-
- // Standard PGN
- for (let i=0; i<this.moves.length; i++)
- {
- if (i % 2 == 0)
- pgn += ((i/2)+1) + ".";
- pgn += this.moves[i].notation[0] + " ";
- }
- pgn += "<br><br>";
-
- // "Complete moves" PGN (helping in ambiguous cases)
- for (let i=0; i<this.moves.length; i++)
+ pgn += '[Variant "' + variant + '"]\n';
+ pgn += '[Date "' + getDate(new Date()) + '"]\n';
+ // TODO: later when users are a bit less anonymous, use better names
+ const whiteName = ["human","computer"].includes(mode)
+ ? (mycolor=='w'?'Myself':opponent)
+ : "analyze";
+ const blackName = ["human","computer"].includes(mode)
+ ? (mycolor=='b'?'Myself':opponent)
+ : "analyze";
+ pgn += '[White "' + whiteName + '"]\n';
+ pgn += '[Black "' + blackName + '"]\n';
+ pgn += '[Fen "' + fenStart + '"]\n';
+ pgn += '[Result "' + score + '"]\n\n';
+
+ // Print moves
+ for (let i=0; i<moves.length; i++)