X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=5217c34de312a0b4bc4eddc3f05c6b494fab2a2d;hb=cafe016679ee9c14bf7bf0a37104ade7f74aff89;hp=4cb46ec98311a91547014276d5176b5819596e14;hpb=c292ebb2a014646005b01e27253c162f1d639387;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 4cb46ec9..5217c34d 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -324,6 +324,8 @@ export default { params.socketUrl + "/?sid=" + this.st.user.sid + + "&id=" + + this.st.user.id + "&tmpId=" + getRandString() + "&page=" + @@ -685,7 +687,7 @@ export default { const game = data.data; // Ignore games where I play (will go in MyGames page) if (game.players.every(p => - p.sid != this.st.user.sid || p.id != this.st.user.id)) + p.sid != this.st.user.sid || p.uid != this.st.user.id)) { let locGame = this.games.find(g => g.id == game.id); if (!locGame) { @@ -948,6 +950,16 @@ export default { }, // NOTE: when launching game, the challenge is already being deleted launchGame: function(c) { + let players = + !!c.mycolor + ? (c.mycolor == "w" ? [c.seat, c.from] : [c.from, c.seat]) + : shuffle([c.from, c.seat]); + // Convention for players IDs in stored games is 'uid' + players.forEach(p => { + let pWithUid = p; + pWithUid["uid"] = p.id; + delete pWithUid["id"]; + }); // These game informations will be shared let gameInfo = { id: getRandString(), @@ -967,6 +979,16 @@ export default { // Send game info (only if live) to everyone except me and opponent // TODO: this double message send could be avoided. this.send("newgame", { data: gameInfo, oppsid: oppsid }); + // Also to MyGames page: + this.send( + "notifynewgame", + { + data: gameInfo, + targets: gameInfo.players.map(p => { + return { sid: p.sid, uid: p.uid }; + }) + } + ); }; if (c.type == "live") { notifyNewgame();