X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=59d544fca6c91a21a0943acb30db9a424e0a463a;hp=2c9b4831f4f5f8f4452d76406ec375f0cda8e365;hb=25996aedafba5e983f324ada3db1da59206bec0a;hpb=a7808884ed94d0ed36347ef7f7db49ab5806725e diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 2c9b4831..59d544fc 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -130,7 +130,10 @@ export default { "GET", {uid: this.st.user.id, excluded: true}, response => { - this.games = this.games.concat(response.games); + this.games = this.games.concat(response.games.map(g => { + const tc = + return Object.assign({}, g, {mainT + }); } ); // Also ask for corr challenges (open + sent to me) @@ -312,7 +315,7 @@ export default { const pIdx = this.people.findIndex(p => p.sid == data.from); newChall.from = this.people[pIdx]; //may be anonymous newChall.added = Date.now(); //TODO: this is reception timestamp, not creation - newChall.vname = this.getVname(newChall.vid); //TODO: just send vname? + newChall.vname = this.getVname(newChall.vid); this.challenges.push(newChall); break; } @@ -401,6 +404,15 @@ export default { chall.added = Date.now(); chall.type = ctype; chall.vname = vname; + + + + +// TODO: vname and type are redundant (can be deduced from timeControl + vid) + + + + chall.from = this.st.user; this.challenges.push(chall); localStorage.setItem("challenge", JSON.stringify(chall)); @@ -482,8 +494,6 @@ export default { const vname = this.getVname(c.vid); const vModule = await import("@/variants/" + vname + ".js"); window.V = vModule.VariantRules; - // Extract times (in [milli]seconds), set clocks - const tc = extractTime(c.timeControl); // These game informations will be sent to other players const gameInfo = { @@ -492,9 +502,6 @@ export default { players: shuffle([c.from, c.seat]), //white then black vid: c.vid, timeControl: tc.timeControl, - mainTime: tc.mainTime, - increment: tc.increment, - type: c.type, }; this.st.conn.send(JSON.stringify({code:"newgame", gameInfo:gameInfo, target:c.seat.sid})); @@ -511,12 +518,12 @@ export default { }, // NOTE: for live games only (corr games are launched on server) startNewGame: function(gameInfo) { - const game = Object.assign(gameInfo, { - // More game infos: constant - vname: this.getVname(gameInfo.vid), + // Extract times (in [milli]seconds), set clocks + const tc = extractTime(c.timeControl); + const game = Object.assign({}, gameInfo, { + // (other) Game infos: constant fenStart: gameInfo.fen, - mode: "live", //function for live games only - // Game state: will be updated + // Game state (including FEN): will be updated moves: [], clocks: [tc.mainTime, tc.mainTime], initime: [Date.now(), 0],