- // Notify turn after a new move (to opponent and me on MyGames page)
- notifyTurn: function(sid) {
- const player = this.people[sid];
- const colorIdx = this.game.players.findIndex(
- p => p.sid == sid || p.uid == player.id);
- const color = ["w","b"][colorIdx];
- const movesCount = this.game.moves.length;
- const yourTurn =
- (color == "w" && movesCount % 2 == 0) ||
- (color == "b" && movesCount % 2 == 1);
- this.send("turnchange", { target: sid, yourTurn: yourTurn });
+ // Notify something after a new move (to opponent and me on MyGames page)
+ notifyMyGames: function(thing, data) {
+ this.send(
+ "notify" + thing,
+ {
+ data: data,
+ targets: this.game.players.map(p => {
+ return { sid: p.sid, uid: p.uid };
+ })
+ }
+ );