X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=d88ac1e2aa8dfc2d0d0b916e20337774ca90d2aa;hb=9a1e3abe33fff07218b17c7c799eb622a730b7c7;hp=fa7ab3b29f67d7e9ef498e9c5cf5545b7ba52612;hpb=bf588c57bdac8525f57c2017b6e70e9390e06700;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index fa7ab3b2..d88ac1e2 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -196,6 +196,7 @@ import { getDiagram, replaceByDiag } from "@/utils/printDiagram"; import { processModalClick } from "@/utils/modalClick"; import { playMove, getFilteredMove } from "@/utils/playUndo"; import { ArrayFun } from "@/utils/array"; +import afterRawLoad from "@/utils/afterRawLoad"; import params from "@/parameters"; export default { name: "my-game", @@ -522,11 +523,7 @@ export default { }, getGameType: function(game) { if (!!game.id.toString().match(/^i/)) return "import"; - return ( - game.cadence.indexOf("d") >= 0 - ? "corr" - : (game.cadence.indexOf("/") >= 0 ? "simul" : "live") - ); + return (game.cadence.indexOf("d") >= 0 ? "corr" : "live"); }, // Notify something after a new move (to opponent and me on MyGames page) notifyMyGames: function(thing, data) { @@ -755,9 +752,9 @@ export default { case "newmove": { // DEBUG: -console.log("Receive move"); -console.log(data.data); -//moveslist not updated when receiving a move? (see in baseGame) +//console.log("Receive move"); +//console.log(data.data); +//moveslist not updated when receiving a move? (see in BaseGame) const movePlus = data.data; const movesCount = this.game.moves.length; @@ -1047,6 +1044,7 @@ console.log(data.data); let gameInfo = { id: getRandString(), //ignored if corr fen: V.GenRandInitFen(this.game.randomness), + randomness: this.game.randomness, players: [this.game.players[1], this.game.players[0]], vid: this.game.vid, cadence: this.game.cadence @@ -1068,7 +1066,6 @@ console.log(data.data); "/games", "POST", { - // cid is useful to delete the challenge: data: { gameInfo: gameInfo }, success: (response) => { gameInfo.id = response.gameId; @@ -1270,19 +1267,13 @@ console.log(data.data); window.V = vModule[game.vname + "Rules"]; this.loadGame(game, callback); }); - // (AJAX) Request to get rules content (plain text, HTML) this.rulesContent = - require( - "raw-loader!@/translations/rules/" + - game.vname + "/" + - this.st.lang + ".pug" - ) - // Next two lines fix a weird issue after last update (2019-11) - .replace(/\\n/g, " ") - .replace(/\\"/g, '"') - .replace('module.exports = "', "") - .replace(/"$/, "") - .replace(/(fen:)([^:]*):/g, replaceByDiag); + afterRawLoad( + require( + "raw-loader!@/translations/rules/" + + game.vname + "/" + this.st.lang + ".pug" + ).default + ).replace(/(fen:)([^:]*):/g, replaceByDiag); }, // 3 cases for loading a game: // - from indexedDB (running or completed live game I play) @@ -1400,7 +1391,11 @@ console.log(data.data); !!this.repeat[fenObj] ? this.repeat[fenObj] + 1 : 1; - if (this.repeat[fenObj] >= 3) this.drawOffer = "threerep"; + if (this.repeat[fenObj] >= 3) { + if (V.LoseOnRepetition) + this.gameOver(moveCol == "w" ? "0-1" : "1-0", "Repetition"); + else this.drawOffer = "threerep"; + } else if (this.drawOffer == "threerep") this.drawOffer = ""; if (!!this.game.mycolor && !data.receiveMyMove) { // NOTE: 'var' to see that variable outside this block @@ -1524,7 +1519,6 @@ console.log(data.data); }; if ( this.game.type == "corr" && - V.CorrConfirm && moveCol == this.game.mycolor && !data.receiveMyMove ) { @@ -1540,6 +1534,10 @@ console.log(data.data); if (data.score == "*") this.re_setClocks(); } }; + if (!V.CorrConfirm) { + afterSetScore(); + return; + } let el = document.querySelector("#buttonsConfirm > .acceptBtn"); // We may play several moves in a row: in case of, remove listener: let elClone = el.cloneNode(true);