X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=5785abdd481e50d19d0b109af1063b053898e33a;hp=0b31bc3b3f95ead8d8a61cfd9737af5caac1336d;hb=059228c9fd737361dc97de69811daed5abbd6254;hpb=32f6285ee325a14286562a53baefc647201df2af diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 0b31bc3b..5785abdd 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -208,7 +208,7 @@ export default { this.gameRef.id = to.params["id"]; this.gameRef.rid = to.query["rid"]; this.nextIds = JSON.parse(this.$route.query["next"] || "[]"); - this.loadGame(); + this.fetchGame(); } } }, @@ -308,17 +308,17 @@ export default { else // Socket not ready yet (initial loading) // NOTE: it's important to call callback without arguments, - // otherwise first arg is Websocket object and loadGame fails. + // otherwise first arg is Websocket object and fetchGame fails. this.conn.onopen = () => callback(); }; if (!this.gameRef.rid) // Game stored locally or on server - this.loadGame(null, () => socketInit(this.roomInit)); + this.fetchGame(null, () => socketInit(this.roomInit)); else // Game stored remotely: need socket to retrieve it // NOTE: the callback "roomInit" will be lost, so we don't provide it. // --> It will be given when receiving "fullgame" socket event. - socketInit(this.loadGame); + socketInit(this.fetchGame); }, cleanBeforeDestroy: function() { if (!!this.askLastate) @@ -434,7 +434,7 @@ export default { if (document.location.href != currentUrl) return; //page change if (!this.gameRef.rid) // This is my game: just reload. - this.loadGame(); + this.fetchGame(); else // Just ask fullgame again (once!), this is much simpler. // If this fails, the user could just reload page :/ @@ -587,7 +587,7 @@ export default { break; case "fullgame": // Callback "roomInit" to poll clients only after game is loaded - this.loadGame(data.data, this.roomInit); + this.fetchGame(data.data, this.roomInit); break; case "asklastate": // Sending informative last state if I played a move or score != "*" @@ -663,8 +663,8 @@ export default { break; } case "resign": - const score = data.side == "b" ? "1-0" : "0-1"; - const side = data.side == "w" ? "White" : "Black"; + const score = (data.data == "b" ? "1-0" : "0-1"); + const side = (data.data == "w" ? "White" : "Black"); this.gameOver(score, side + " surrender"); break; case "abort": @@ -904,8 +904,8 @@ export default { if (!this.game.mycolor || !confirm(this.st.tr["Resign the game?"])) return; this.send("resign", { data: this.game.mycolor }); - const score = this.game.mycolor == "w" ? "0-1" : "1-0"; - const side = this.game.mycolor == "w" ? "White" : "Black"; + const score = (this.game.mycolor == "w" ? "0-1" : "1-0"); + const side = (this.game.mycolor == "w" ? "White" : "Black"); this.gameOver(score, side + " surrender"); }, // 3 cases for loading a game: