X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=22ffe45de982a0d3ce8f688837bc83d1c8f203f8;hb=8d15beb4880d40c89d893a3423fb1d0f0ffbc2c6;hp=03d34119618bb2583cf1e4a6a464e96ca28cdc6d;hpb=9a1e3abe33fff07218b17c7c799eb622a730b7c7;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 03d34119..22ffe45d 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -315,20 +315,24 @@ export default { // Automatic challenge sending, for tournaments this.loadNewchallVariant( () => { - this.newchallenge = { - fen: "", - vid: - this.st.variants - .find(v => v.name == this.$route.query["variant"]) - .id, - to: this.$route.query["challenge"], - color: this.$route.query["color"] || '', - cadence: this.$route.query["cadence"], - // Tournament: no randomness (TODO: for now at least) - randomness: 0, - memorize: false - }; - this.issueNewChallenge(); + this.newchallenge = Object.assign( + this.newchallenge, + { + fen: "", + vid: + this.st.variants + .find(v => v.name == this.$route.query["variant"]) + .id, + to: this.$route.query["challenge"], + color: this.$route.query["color"] || '', + cadence: this.$route.query["cadence"], + // Tournament: no randomness (TODO: for now at least) + randomness: 0, + memorize: false + } + ); + window.doClick("modalNewgame"); + //this.issueNewChallenge(); //NOTE: doesn't work yet. }, this.$route.query["variant"] ); @@ -441,7 +445,8 @@ export default { } } ); - } else addChallenges(); + } + else addChallenges(); } } ); @@ -701,7 +706,8 @@ export default { // For self multi-connects tests: this.newConnect[data.from[0]] = true; this.send("askidentity", { target: data.from[0], page: page }); - } else { + } + else { this.people[data.from[0]].tmpIds[data.from[1]] = { page: page, focus: true }; this.$forceUpdate(); //TODO: shouldn't be required @@ -733,7 +739,8 @@ export default { "all" ); } - } else { + } + else { // Remove the matching live game if now unreachable const gid = data.page.match(/[a-zA-Z0-9]+$/)[0]; // Corr games are always reachable: @@ -948,7 +955,8 @@ export default { ); }); this.games = this.games.concat(moreGames); - } else this.hasMore = false; + } + else this.hasMore = false; } } ); @@ -978,13 +986,13 @@ export default { .getElementById("btnC" + newChall.type) .classList.add("somethingnew"); } - if (!!chall.to) { + if (!!chall.to && chall.to == this.st.user.name) { notify( "New challenge", // fromValues.name should exist since the player is online, but // let's consider there is some chance that the challenge arrives // right after we connected and before receiving the poll result: - { body: "from " + (fromValues.name || "unknown yet...") } + { body: "from " + (fromValues.name || "@nonymous") } ); } } @@ -1016,7 +1024,8 @@ export default { position: parsedFen.position //,orientation: parsedFen.turn }); - } else this.newchallenge.diag = ""; + } + else this.newchallenge.diag = ""; }, newChallFromPreset(pchall) { this.partialResetNewchallenge(); @@ -1154,7 +1163,8 @@ export default { if (ctype == "live") { // Live challenges have a random ID finishAddChallenge(null); - } else { + } + else { // Correspondence game: send challenge to server ajax( "/challenges", @@ -1193,7 +1203,8 @@ export default { else // Corr challenge: just remove the challenge this.send("deletechallenge_s", { data: { cid: c.id } }); - } else { + } + else { const oppsid = this.getOppsid(c); if (!!oppsid) this.send("refusechallenge", { data: c.id, target: oppsid }); @@ -1300,7 +1311,14 @@ export default { if (c.type == "live") { notifyNewgame(); this.startNewGame(gameInfo); - } else { + // Increment game stats counter in DB + ajax( + "/gamestat", + "POST", + { data: { vid: gameInfo.vid } } + ); + } + else { // corr: game only on server ajax( "/games",