X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=88f2b5e2fa73252d701b265e6b4f419143f65d59;hb=89021f181ac0689bbc785ce0ebd9a910e66352b0;hp=b7cc1fc08ef1ccb72852b9f926b331d8df1101a4;hpb=a154d45ebb7e409cd714d0c517e79c8147bdea69;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index b7cc1fc0..88f2b5e2 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -134,7 +134,11 @@ export default { if (!!this.conn && this.conn.readyState == 1) //1 == OPEN state callback(); else //socket not ready yet (initial loading) - this.conn.onopen = callback; + { + // NOTE: it's important to call callback without arguments, + // otherwise first arg is Websocket object and loadGame fails. + this.conn.onopen = () => { return callback() }; + } }; if (!this.gameRef.rid) //game stored locally or on server this.loadGame(null, () => socketInit(this.roomInit)); @@ -540,7 +544,8 @@ export default { }); if (this.repeat[repIdx] >= 3) this.drawOffer = "threerep"; - callback(); + if (!!callback) + callback(); }; if (!!game) return afterRetrieval(game); @@ -555,8 +560,13 @@ export default { GameStorage.get(this.gameRef.id, afterRetrieval); } }, - // Post-process a move (which was just played) + // Post-process a move (which was just played in BaseGame) processMove: function(move) { + if (this.game.type == "corr" && move.color == this.game.mycolor) + { + if (!confirm(this.st.tr["Are you sure?"])) + return this.$set(this.game, "moveToUndo", move); + } // Update storage (corr or live) if I play in the game const colorIdx = ["w","b"].indexOf(move.color); const nextIdx = ["w","b"].indexOf(this.vr.turn); @@ -681,6 +691,8 @@ export default { { GameStorage.update(this.gameRef.id, {score: score, scoreMsg: scoreMsg}); + // Notify the score to main Hall. TODO: only one player (currently double send) + this.send("result", {gid:this.game.id, score:score}); } }, },