X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=7c3a442de6b47e8fad388fdd153f229dbe6e95c0;hb=af041c940f747ecca5d33c42042a62efd9039f10;hp=eb8b68116cd9252ca89e531069c760ba4bd36cd1;hpb=1ebb011fa84d6877841950691a7af6aae9a8770e;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index eb8b6811..7c3a442d 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -55,7 +55,7 @@ main placeholder="5+0, 1h+30s, 5d ..." ) fieldset - label(for="selectRandomLevel") {{ st.tr["Randomness"] }} + label(for="selectRandomLevel") {{ st.tr["Randomness"] }} * select#selectRandomLevel(v-model="newchallenge.randomness") option(value="0") {{ st.tr["Deterministic"] }} option(value="1") {{ st.tr["Symmetric random"] }} @@ -93,10 +93,15 @@ main ) span {{ people[sid].name }} button.player-action( - v-if="isGamer(sid) || (st.user.id > 0 && sid!=st.user.sid)" - @click="challOrWatch(sid)" + v-if="isGamer(sid)" + @click="watchGame(sid)" ) - | {{ getActionLabel(sid) }} + | {{ st.tr["Observe"] }} + button.player-action( + v-else-if="st.user.id > 0 && sid!=st.user.sid" + @click="challenge(sid)" + ) + | {{ st.tr["Challenge"] }} p.anonymous @nonymous ({{ anonymousCount }}) #chat Chat( @@ -369,29 +374,23 @@ export default { isGamer: function(sid) { return this.people[sid].pages.some(p => p.indexOf("/game/") >= 0); }, - getActionLabel: function(sid) { - return this.people[sid].pages.some(p => p == "/game/") - ? "Observe" - : "Challenge"; + challenge: function(sid) { + // Available, in Hall (only) + this.newchallenge.to = this.people[sid].name; + document.getElementById("modalPeople").checked = false; + window.doClick("modalNewgame"); }, - challOrWatch: function(sid) { - if (this.people[sid].pages.some(p => p == "/")) { - // Available, in Hall - this.newchallenge.to = this.people[sid].name; - document.getElementById("modalPeople").checked = false; - window.doClick("modalNewgame"); - } else { - // In some game, maybe playing maybe not: show a random one - let gids = []; - this.people[sid].pages.forEach(p => { - const matchGid = p.match(/[a-zA-Z0-9]+$/); - if (matchGid) gids.push(matchGid[0]); - }); - const gid = gids[Math.floor(Math.random() * gids.length)]; - const game = this.games.find(g => g.id == gid); - if (game) this.showGame(game); - else this.$router.push("/game/" + gid); //game vs. me - } + watchGame: function(sid) { + // In some game, maybe playing maybe not: show a random one + let gids = []; + this.people[sid].pages.forEach(p => { + const matchGid = p.match(/[a-zA-Z0-9]+$/); + if (matchGid) gids.push(matchGid[0]); + }); + const gid = gids[Math.floor(Math.random() * gids.length)]; + const game = this.games.find(g => g.id == gid); + if (game) this.showGame(game); + else this.$router.push("/game/" + gid); //game vs. me }, showGame: function(g) { // NOTE: we are an observer, since only games I don't play are shown here @@ -798,6 +797,9 @@ export default { }; this.launchGame(c); } else { + +console.log(c); + this.send("refusechallenge", { data: c.id, target: c.from.sid }); } this.send("deletechallenge", { data: c.id });