- setEndgameMessage: function(score) {
- let eogMessage = "Undefined";
- switch (score)
- {
- case "1-0":
- eogMessage = translations["White win"];
- break;
- case "0-1":
- eogMessage = translations["Black win"];
- break;
- case "1/2":
- eogMessage = translations["Draw"];
- break;
- case "?":
- eogMessage = "Unfinished";
- break;
- }
- this.endgameMessage = eogMessage;
+ re_setVariables: function() {
+ this.endgameMessage = "";
+ this.orientation = this.game.mycolor || "w"; //default orientation for observed games
+ this.score = this.game.score || "*"; //mutable (if initially "*")
+ this.moves = JSON.parse(JSON.stringify(this.game.moves || []));
+ // Post-processing: decorate each move with color + current FEN:
+ // (to be able to jump to any position quickly)
+ this.moves.forEach(move => {
+ // NOTE: this is doing manually what play() function below achieve,
+ // but in a lighter "fast-forward" way
+ move.color = this.vr.turn;
+ move.notation = this.vr.getNotation(move);
+ this.vr.play(move);
+ move.fen = this.vr.getFen();
+ });
+ const L = this.moves.length;
+ this.cursor = L-1;
+ this.lastMove = (L > 0 ? this.moves[L-1] : null);