X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=ac6ed4d5ffc4d234c6897677c5fd08102577d62a;hb=8f16069a55fdbbb92f62eb385daf776bef4fc7fd;hp=68c8c94d4362f4324b6eefd109a965c2add58195;hpb=f54f4c26b4c820b14aca298e94644efb20beeed6;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 68c8c94d..ac6ed4d5 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -200,11 +200,9 @@ export default { // In case of incomplete information variant: boardDiv.style.visibility = "hidden"; this.atCreation(); - } else { + } else // Same game ID this.nextIds = JSON.parse(this.$route.query["next"] || "[]"); - this.loadGame(this.game); - } } }, // NOTE: some redundant code with Hall.vue (mostly related to people array) @@ -445,6 +443,8 @@ export default { const data = JSON.parse(msg.data); switch (data.code) { case "pollclients": + // TODO: shuffling and random filtering on server, if + // the room is really crowded. data.sockIds.forEach(sid => { if (sid != this.st.user.sid) { this.people[sid] = { focus: true }; @@ -1118,9 +1118,9 @@ export default { processMove: function(move, data) { if (!data) data = {}; const moveCol = this.vr.turn; + const colorIdx = ["w", "b"].indexOf(moveCol); + const nextIdx = 1 - colorIdx; const doProcessMove = () => { - const colorIdx = ["w", "b"].indexOf(moveCol); - const nextIdx = 1 - colorIdx; const origMovescount = this.game.moves.length; let addTime = 0; //for live games if (moveCol == this.game.mycolor && !data.receiveMyMove) { @@ -1240,6 +1240,7 @@ export default { }; if (this.game.type == "live") sendMove["clock"] = this.game.clocks[colorIdx]; + // (Live) Clocks will re-start when the opponent pingback arrive this.opponentGotMove = false; this.send("newmove", {data: sendMove}); // If the opponent doesn't reply gotmove soon enough, re-send move: @@ -1287,6 +1288,10 @@ export default { // The board might have been hidden: if (boardDiv.style.visibility == "hidden") boardDiv.style.visibility = "visible"; + if (data.score == "*") { + this.game.initime[nextIdx] = Date.now(); + this.re_setClocks(); + } } }; let el = document.querySelector("#buttonsConfirm > .acceptBtn");