Fix passing games
authorBenjamin Auder <benjamin.auder@somewhere>
Fri, 7 Feb 2020 10:24:29 +0000 (11:24 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Fri, 7 Feb 2020 10:24:29 +0000 (11:24 +0100)
client/src/components/ChallengeList.vue
client/src/components/GameList.vue
client/src/translations/en.js
client/src/views/Game.vue
client/src/views/Hall.vue
server/sockets.js

index 095c096..fd2a901 100644 (file)
@@ -10,7 +10,7 @@ div
     tbody
       tr(v-for="c in sortedChallenges" @click="$emit('click-challenge',c)")
         td(data-label="Variant") {{ c.vname }}
-        td(data-label="From") {{ c.from.name }}
+        td(data-label="From") {{ c.from.name || "@nonymous" }}
         td(data-label="To") {{ c.to }}
         td(data-label="Cadence") {{ c.timeControl }}
 </template>
index d0ea2f0..62c916f 100644 (file)
@@ -7,7 +7,7 @@ div
         th {{ st.tr["White"] }}
         th {{ st.tr["Black"] }}
         th {{ st.tr["Time control"] }}
-        th(v-if="showResult") Result
+        th {{ st.tr["Result"] }}
     tbody
       tr(v-for="g in sortedGames" @click="$emit('show-game',g)"
           :class="{'my-turn': g.myTurn}")
@@ -15,7 +15,7 @@ div
         td(data-label="White") {{ g.players[0].name || "@nonymous" }}
         td(data-label="Black") {{ g.players[1].name || "@nonymous" }}
         td(data-label="Time control") {{ g.timeControl }}
-        td(v-if="showResult" data-label="Result") {{ g.score }}
+        td(data-label="Result") {{ g.score }}
 </template>
 
 <script>
@@ -27,13 +27,11 @@ export default {
   data: function() {
     return {
       st: store.state,
-      showResult: false,
     };
   },
   computed: {
     sortedGames: function() {
       // Show in order: games where it's my turn, my running games, my games, other games
-      this.showResult = this.games.some(g => g.score != "*");
       let augmentedGames = this.games.map(g => {
         let priority = 0;
         if (g.players.some(p => p.uid == this.st.user.id || p.sid == this.st.user.sid))
index b84230a..8fa4547 100644 (file)
@@ -67,6 +67,7 @@ export const translations =
   "Registration complete! Please check your emails": "Registration complete! Please check your emails",
   "Resign": "Resign",
   "Resign the game?": "Resign the game?",
+  "Result": "Result",
   "Rules": "Rules",
   "Sample game": "Sample game",
   "Send": "Send",
index 35cec3a..608ac71 100644 (file)
@@ -246,6 +246,7 @@ export default {
               players: this.game.players,
               vid: this.game.vid,
               timeControl: this.game.timeControl,
+              score: this.game.score,
             };
             this.st.conn.send(JSON.stringify({code:"game",
               game:myGame, target:data.from}));
index 38ec2b3..39d7c16 100644 (file)
@@ -405,7 +405,6 @@ export default {
             newGame.type = this.classifyObject(data.game);
             newGame.vname = this.getVname(data.game.vid);
             newGame.rid = data.from;
-            newGame.score = "*";
             this.games.push(newGame);
           }
           break;
@@ -455,7 +454,7 @@ export default {
             this.st.conn.send(JSON.stringify({code:"askgame", target:data.from}));
           break;
         case "disconnect":
-        case "pdisconnect":
+        case "gdisconnect":
           this.$delete(this.people, data.from);
           if (data.code == "disconnect")
           {
index fcaab83..e7bb556 100644 (file)
@@ -123,6 +123,10 @@ module.exports = function(wss) {
           });
           break;
         }
+        case "askgame":
+          clients[obj.target].sock.send(JSON.stringify(
+            {code:"askgame", from:sid}));
+          break;
         case "askfullgame":
           clients[obj.target].sock.send(JSON.stringify(
             {code:"askfullgame", from:sid}));
@@ -167,7 +171,7 @@ module.exports = function(wss) {
           notifyRoom(clients[sid].page, "newchat", {chat:obj.chat});
           break;
         // TODO: WebRTC instead in this case (most demanding?)
-        // --> At least do a "notifyRoom"
+        // --> Or else: at least do a "notifyRoom" (also for draw, resign...)
         case "newmove":
           clients[obj.target].sock.send(JSON.stringify(
             {code:"newmove", move:obj.move}));