// TODO: envoyer juste "light move", sans FEN ni notation ...etc
+// TODO: also "observers" prop, we should send moves to them too (in a web worker ? webRTC ?)
// Game logic on a variant page: 3 modes, analyze, computer or human
Vue.component('my-game', {
// gameId: to find the game in storage (assumption: it exists)
- props: ["gameId","mode","allowChat","allowMovelist"],
+ // fen: to start from a FEN without identifiers (analyze mode)
+ props: ["gameId","fen","mode","allowChat","allowMovelist"],
data: function() {
return {
// if oppid == "computer" then mode = "computer" (otherwise human)
compWorker: new Worker('/javascripts/playCompMove.js'),
timeStart: undefined, //time when computer starts thinking
vr: null, //VariantRules object, describing the game state + rules
+
+ // orientation :: button flip
+ // userColor: given by gameId, or fen (if no game Id)
+ // gameOver: known if gameId; otherwise assue false
+ // lastMove: update after every play, initialize with last move from list (if continuation)
+ //orientation ? userColor ? gameOver ? lastMove ?
+
};
},
+ watch: {
+ fen: function(newFen) {
+ this.vr = new VariantRules(newFen);
+ },
+ },
computed: {
showChat: function() {
return this.allowChat && this.mode=='human' && this.score != '*';
`,
created: function() {
const url = socketUrl;
- this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
+
+// TODO: connexion initialized in variant.js and passed as a prop
+
// TODO: after game, archive in indexedDB
// TODO: this events listener is central. Refactor ? How ?
const socketMessageListener = msg => {
};
const socketCloseListener = () => {
- this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
this.conn.addEventListener('message', socketMessageListener);
this.conn.addEventListener('close', socketCloseListener);
};