// Game logic on a variant page: 3 modes, analyze, computer or human
// TODO: envoyer juste "light move", sans FEN ni notation ...etc
// TODO: if I'm an observer and player(s) disconnect/reconnect, how to find me ?
+// onClick :: ask full game to remote player, and register as an observer in game
+// (use gameId to communicate)
+// on landing on game :: if gameId not found locally, check remotely
+// ==> il manque un param dans game : "remoteId"
Vue.component('my-game', {
// gameId: to find the game in storage (assumption: it exists)
// fen: to start from a FEN without identifiers (analyze mode)
<div id="pgn-div" class="section-content">
<a id="download" href="#">
</a>
- <button id="downloadBtn" @click="download">
- {{ translate("Download PGN") }}
- </button>
+ <div class="button-group">
+ <button id="downloadBtn" @click="download">
+ {{ translate("Download PGN") }}
+ </button>
+ <button>Import game</button>
+ </div>
</div>
<my-move-list v-if="showMoves" :moves="moves" :cursor="cursor" @goto-move="gotoMove">
</my-move-list>
this.vr = new VariantRules(this.fen);
this.fenStart = this.fen;
}
+ // TODO: if I'm one of the players in game, then:
+ // Send ping to server (answer pong if opponent is connected)
+ if (true && !!this.conn)
+ {
+ this.conn.send(JSON.stringify({
+ code:"ping",oppid:this.oppid,gameId:this.gameId}));
+ }
// TODO: also handle "draw accepted" (use opponents array?)
// --> must give this info also when sending lastState...
// and, if all players agree then OK draw (end game ...etc)
}
},
loadGame: function() {
+ // TODO: ask game to remote peer if this.remoteId is set
+ // (or just if game not found locally)
+ // NOTE: if it's a corr game, ask it from server
const game = getGameFromStorage(this.gameId);
this.opponent.id = game.oppid; //opponent ID in case of running HH game
this.opponent.name = game.oppname; //maye be blank (if anonymous)