X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Froom.js;h=fbf02ee189904273792d41bcc9dab3f11caf7237;hb=b955c65b942d09d24b5c3bed0d755d4f2f8f71f1;hp=47370fb28c30c6ffaa9968cefb7390ec97f1ffd5;hpb=214dfe16b01836fb19291ebf209bb7035993bafe;p=vchess.git
diff --git a/public/javascripts/components/room.js b/public/javascripts/components/room.js
index 47370fb2..fbf02ee1 100644
--- a/public/javascripts/components/room.js
+++ b/public/javascripts/components/room.js
@@ -12,17 +12,21 @@ main time should be positive (no 0+2 & cie...)
// TODO: objet game, objet challenge ? et player ?
Vue.component('my-room', {
props: ["conn","settings"],
- data: {
- gdisplay: "live",
- liveGames: [],
- corrGames: [],
- players: [], //online players
- challenges: [], //live challenges
+ data: function () {
+ return {
+ gdisplay: "live",
+ user: user,
+ liveGames: [],
+ corrGames: [],
+ players: [], //online players
+ challenges: [], //live challenges
+ people: [], //people who connect to this room (or disconnect)
+ };
},
// Modal new game, and then sub-components
template: `
-
+
-
+
-
+
+
Online players
{{ p.name }}
-
-
+
+
-
+
-
+
@@ -101,6 +108,7 @@ Vue.component('my-room', {
this.conn.onclose = socketCloseListener;
},
methods: {
+ translate: translate,
showGame: function(game) {
let hash = "#game?id=" + game.id;
if (!!game.uid)
@@ -109,7 +117,7 @@ Vue.component('my-room', {
},
challenge: function(player) {
this.conn.send(JSON.stringify({code:"sendchallenge", oppid:p.id,
- user:{name:user.name,id:user.id}));
+ user:{name:user.name,id:user.id}}));
},
clickChallenge: function(challenge) {
const index = this.challenges.findIndex(c => c.id == challenge.id);
@@ -136,11 +144,12 @@ Vue.component('my-room', {
},
// user: last person to accept the challenge
newGame: function(chall, user) {
- const fen = chall.fen || VariantRules.GenRandInitFen();
+ const fen = chall.fen || V.GenRandInitFen();
const game = {}; //TODO: fen, players, time ...
//setStorage(game); //TODO
game.players.forEach(p => {
- this.conn.send(JSON.stringify({code:"newgame", oppid:p.id, game:game});
+ this.conn.send(
+ JSON.stringify({code:"newgame", oppid:p.id, game:game}));
});
if (this.settings.sound >= 1)
new Audio("/sounds/newgame.mp3").play().catch(err => {});