X-Git-Url: https://git.auder.net/variants/Dynamo/complete_rules.html?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=cb00856d99739eccf6829351f5252753beae273c;hb=92b82defacccf9c4d3755924a71fcb584002ccc6;hp=b66c6ef82d66a6ebd1e15f0026b32ce6d99aab28;hpb=f41ce5806b989c06091a403d7e26ff3c457650c9;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index b66c6ef8..cb00856d 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -349,6 +349,7 @@ export default { game.clocks = [tc.mainTime, tc.mainTime]; game.initime = [0, 0]; const L = game.moves.length; + game.moves.sort((m1,m2) => m1.idx - m2.idx); //in case of if (L >= 3) { let addTime = [0, 0]; @@ -362,6 +363,18 @@ export default { } if (L >= 1) game.initime[L%2] = game.moves[L-1].played; + // Now that we used idx and played, re-format moves as for live games + game.moves = game.moves.map(m => { + const s = m.squares; + return + { + appear: s.appear, + vanish: s.vanish, + start: s.start, + end: s.end, + message: m.message, + }; + }); } const myIdx = game.players.findIndex(p => { return p.sid == this.st.user.sid || p.uid == this.st.user.id; @@ -452,8 +465,7 @@ export default { squares: filtered_move, message: this.corrMsg, //TODO played: Date.now(), //TODO: on server? - idx: this.game.moves.length - 1, - color: move.color, + idx: this.game.moves.length, }, clocks: this.game.clocks.map((t,i) => i==colorIdx ? this.game.clocks[i] + addTime