X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FMyGames.vue;h=c9c34f348b68f25de69a3a97b88d3d2092b20577;hp=5faae8a5362f0189781ef51f4b99a2a8c4aeac8c;hb=6b7b2cf720e6255e4da0dc34fee363c456346a58;hpb=f5a31ba0f98d215d432b7d3c86388af749df33a4 diff --git a/client/src/views/MyGames.vue b/client/src/views/MyGames.vue index 5faae8a5..c9c34f34 100644 --- a/client/src/views/MyGames.vue +++ b/client/src/views/MyGames.vue @@ -45,7 +45,7 @@ export default { }; }, created: function() { - GameStorage.getAll(true, localGames => { + GameStorage.getAll(localGames => { localGames.forEach(g => g.type = "live"); this.decorate(localGames); this.liveGames = localGames; @@ -117,17 +117,16 @@ export default { // Called at loading to augment games with myColor + myTurn infos decorate: function(games) { games.forEach(g => { - // If game is over, myColor and myTurn are ignored: + g.myColor = + (g.type == "corr" && g.players[0].uid == this.st.user.id) || + (g.type == "live" && g.players[0].sid == this.st.user.sid) + ? 'w' + : 'b'; + // If game is over, myTurn doesn't exist: if (g.score == "*") { - g.myColor = - (g.type == "corr" && g.players[0].uid == this.st.user.id) || - (g.type == "live" && g.players[0].sid == this.st.user.sid) - ? 'w' - : 'b'; const rem = g.movesCount % 2; - if ((rem == 0 && g.myColor == 'w') || (rem == 1 && g.myColor == 'b')) { + if ((rem == 0 && g.myColor == 'w') || (rem == 1 && g.myColor == 'b')) g.myTurn = true; - } } }); },