- loadGame: async function() {
- const game = GameStorage.get(this.gameRef);
- this.game = game;
- this.cursor = game.moves.length-1;
- // TODO: lastMove must be in BaseGame, not here
- this.lastMove = (game.moves.length > 0 ? game.moves[this.cursor] : null);
- const vModule = await import("@/variants/" + game.vname + ".js");
- window.V = vModule.VariantRules;
+ 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: ["w","b"][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);
+ });
+// // Poll all players except me (if I'm playing) to know online status.
+// // --> Send ping to server (answer pong if players[s] are connected)
+// if (this.gameInfo.players.some(p => p.sid == this.st.user.sid))
+// {
+// this.game.players.forEach(p => {
+// if (p.sid != this.st.user.sid)
+// this.st.conn.send(JSON.stringify({code:"ping", oppid:p.sid}));
+// });
+// }