X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fgame.js;fp=public%2Fjavascripts%2Fcomponents%2Fgame.js;h=096a9e56d55256fcfbedeef0cf2b54c50691d0e9;hp=555d3924b2d18cbd66e943deb29a574dcf5a8ece;hb=d44df0b01732d1948525daef5df62211ea6e1f64;hpb=81bc1102368a5a8b9358f58b77c241f82f3c2c4b diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 555d3924..096a9e56 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -5,7 +5,7 @@ Vue.component('my-game', { // gameId: to find the game in storage (assumption: it exists) // fen: to start from a FEN without identifiers (analyze mode) - props: ["gameId","fen","mode","allowChat","allowMovelist"], + props: ["conn","gameId","fen","mode","allowChat","allowMovelist"], data: function() { return { // if oppid == "computer" then mode = "computer" (otherwise human) @@ -14,7 +14,6 @@ Vue.component('my-game', { oppid: "", //opponent ID in case of HH game score: "*", //'*' means 'unfinished' mycolor: "w", - conn: null, //socket connection (et WebRTC connection ?!) oppConnected: false, //TODO? pgnTxt: "", // sound level: 0 = no sound, 1 = sound only on newgame, 2 = always @@ -23,7 +22,10 @@ Vue.component('my-game', { compWorker: new Worker('/javascripts/playCompMove.js'), timeStart: undefined, //time when computer starts thinking vr: null, //VariantRules object, describing the game state + rules - + endgameMessage: "", + orientation: "w", + + moves: [], //TODO: initialize if gameId is defined... // orientation :: button flip // userColor: given by gameId, or fen (if no game Id) // gameOver: known if gameId; otherwise assue false @@ -36,6 +38,9 @@ Vue.component('my-game', { fen: function(newFen) { this.vr = new VariantRules(newFen); }, + gameId: function() { + this.loadGame(); + }, }, computed: { showChat: function() { @@ -70,9 +75,9 @@ Vue.component('my-game', { - + -
+

{{ vr.getFen() }}

@@ -81,7 +86,7 @@ Vue.component('my-game', {
@@ -89,10 +94,13 @@ Vue.component('my-game', {
`, created: function() { - const url = socketUrl; - -// TODO: connexion initialized in variant.js and passed as a prop +// console.log(this.fen); +// console.log(this.gameId); + if (!!this.gameId) + this.loadGame(); + else if (!!this.fen) + this.vr = new VariantRules(this.fen); // TODO: after game, archive in indexedDB // TODO: this events listener is central. Refactor ? How ? const socketMessageListener = msg => { @@ -199,10 +207,14 @@ Vue.component('my-game', { }, delay); } }, - //TODO: conn pourrait être une prop, donnée depuis variant.js + // this.conn est une prop, donnée depuis variant.js //dans variant.js (plutôt room.js) conn gère aussi les challenges // Puis en webRTC, repenser tout ça. methods: { + translate: translate, + loadGame: function() { + // TODO: load this.gameId ... + }, setEndgameMessage: function(score) { let eogMessage = "Undefined"; switch (score)