- loadGame: async function() {
- this.gameInfo = GameStorage.get(this.gameRef);
-
-console.log(GameStorage.get(this.gameRef));
-
- this.vname = this.gameInfo.vname;
- this.mode = this.gameInfo.mode;
- const vModule = await import("@/variants/" + this.vname + ".js");
- window.V = vModule.VariantRules;
- this.vr = new V(this.gameInfo.fen);
-
+ loadGame: function() {
+ GameStorage.get(this.gameRef, async (game) => {
+ this.game = Object.assign({},
+ game,
+ // NOTE: assign mycolor here, since BaseGame could also bs VS computer
+ {mycolor: [undefined,"w","b"][1 + game.players.findIndex(
+ p => p.sid == this.st.user.sid)]},
+ );
+ const vModule = await import("@/variants/" + game.vname + ".js");
+ window.V = vModule.VariantRules;
+ this.vr = new V(game.fen);
+ // Post-processing: decorate each move with current FEN:
+ // (to be able to jump to any position quickly)
+ game.moves.forEach(move => {
+ vr.play(move); //side-effect: set move.fen
+ });
+ this.vr.re_init(game.fen);
+ });