diff --git a/.meteor/packages b/.meteor/packages index f11e724..238ab32 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -1,28 +1,31 @@ # Meteor packages used by this project, one per line. + # Check this file (and the other files in this directory) into your repository. + # + # 'meteor add' and 'meteor remove' will edit this file for you, + # but you can also edit it by hand. fortawesome:fontawesome momentjs:moment -meteor-base@1.5.1 -mobile-experience@1.1.1 -mongo@1.16.8 -session@1.2.1 -tracker@1.3.3 -logging@1.3.3 -reload@1.3.1 -random@1.2.1 -ejson@1.1.3 +meteor-base@1.5.2 +mobile-experience@1.1.2 +mongo@2.0.2 +session@1.2.2 +tracker@1.3.4 +logging@1.3.5 +reload@1.3.2 +random@1.2.2 +ejson@1.1.4 spacebars -check@1.3.2 -standard-minifier-js@2.8.1 -shell-server@0.5.0 -dynamic-import@0.7.3 -underscore@1.6.0 -fourseven:scss -seba:minifiers-autoprefixer +check@1.4.2 +standard-minifier-js@3.0.0 +shell-server@0.6.0 +dynamic-import@0.7.4 +underscore@1.6.4 blaze-html-templates jquery -msavin:mongol +activitree:scss3 +standard-minifier-css diff --git a/.meteor/release b/.meteor/release index 966586c..c41cba9 100644 --- a/.meteor/release +++ b/.meteor/release @@ -1 +1 @@ -METEOR@2.15 +METEOR@3.0.3 diff --git a/.meteor/versions b/.meteor/versions index 29eb034..f7fd4ff 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,82 +1,82 @@ -allow-deny@1.1.1 -autoupdate@1.8.0 -babel-compiler@7.10.5 -babel-runtime@1.5.1 -base64@1.0.12 -binary-heap@1.0.11 -blaze@2.9.0 -blaze-html-templates@2.0.1 -blaze-tools@1.1.4 -boilerplate-generator@1.7.2 -caching-compiler@1.2.2 -caching-html-compiler@1.2.2 -callback-hook@1.5.1 -check@1.3.2 -ddp@1.4.1 -ddp-client@2.6.1 -ddp-common@1.4.0 -ddp-server@2.7.0 -diff-sequence@1.1.2 -dynamic-import@0.7.3 -ecmascript@0.16.8 -ecmascript-runtime@0.8.1 -ecmascript-runtime-client@0.12.1 -ecmascript-runtime-server@0.11.0 -ejson@1.1.3 -es5-shim@4.8.0 -fetch@0.1.4 +activitree:scss3@1.0.3 +allow-deny@2.0.0 +autoupdate@2.0.0 +babel-compiler@7.11.0 +babel-runtime@1.5.2 +base64@1.0.13 +binary-heap@1.0.12 +blaze@3.0.0 +blaze-html-templates@3.0.0 +blaze-tools@2.0.0 +boilerplate-generator@2.0.0 +caching-compiler@2.0.0 +caching-html-compiler@2.0.0 +callback-hook@1.6.0 +check@1.4.2 +core-runtime@1.0.0 +ddp@1.4.2 +ddp-client@3.0.1 +ddp-common@1.4.4 +ddp-server@3.0.1 +diff-sequence@1.1.3 +dynamic-import@0.7.4 +ecmascript@0.16.9 +ecmascript-runtime@0.8.2 +ecmascript-runtime-client@0.12.2 +ecmascript-runtime-server@0.11.1 +ejson@1.1.4 +es5-shim@4.8.1 +facts-base@1.0.2 +fetch@0.1.5 fortawesome:fontawesome@4.7.0 -fourseven:scss@4.16.0 -geojson-utils@1.0.11 -hot-code-push@1.0.4 -html-tools@1.1.4 -htmljs@1.2.1 -id-map@1.1.1 -inter-process-messaging@0.1.1 -jquery@3.0.0 -launch-screen@2.0.0 -logging@1.3.3 -meteor@1.11.5 -meteor-base@1.5.1 -meteortoys:toykit@10.0.0 -minifier-css@1.6.4 -minifier-js@2.7.5 -minimongo@1.9.3 -mobile-experience@1.1.1 -mobile-status-bar@1.1.0 -modern-browsers@0.1.10 -modules@0.20.0 -modules-runtime@0.13.1 +geojson-utils@1.0.12 +hot-code-push@1.0.5 +html-tools@2.0.0 +htmljs@2.0.1 +id-map@1.2.0 +inter-process-messaging@0.1.2 +jquery@3.0.1 +launch-screen@2.0.1 +logging@1.3.5 +meteor@2.0.1 +meteor-base@1.5.2 +minifier-css@2.0.0 +minifier-js@3.0.0 +minimongo@2.0.1 +mobile-experience@1.1.2 +mobile-status-bar@1.1.1 +modern-browsers@0.1.11 +modules@0.20.1 +modules-runtime@0.13.2 momentjs:moment@2.30.1 -mongo@1.16.9 -mongo-decimal@0.1.3 -mongo-dev-server@1.1.0 -mongo-id@1.0.8 -msavin:mongol@10.0.1 -npm-mongo@4.17.2 -observe-sequence@1.0.22 -ordered-dict@1.1.0 -promise@0.12.2 -random@1.2.1 -react-fast-refresh@0.2.8 -reactive-dict@1.3.1 -reactive-var@1.0.12 -reload@1.3.1 -retry@1.1.0 -routepolicy@1.1.1 -seba:minifiers-autoprefixer@2.0.1 -session@1.2.1 -shell-server@0.5.0 -socket-stream-client@0.5.2 -spacebars@1.6.0 -spacebars-compiler@1.3.2 -standard-minifier-js@2.8.1 -templating@1.4.3 -templating-compiler@1.4.2 -templating-runtime@1.6.4 -templating-tools@1.2.3 -tracker@1.3.3 -typescript@4.9.5 -underscore@1.6.1 -webapp@1.13.8 -webapp-hashing@1.1.1 +mongo@2.0.2 +mongo-decimal@0.1.4 +mongo-dev-server@1.1.1 +mongo-id@1.0.9 +npm-mongo@4.17.4 +observe-sequence@2.0.0 +ordered-dict@1.2.0 +promise@1.0.0 +random@1.2.2 +react-fast-refresh@0.2.9 +reactive-dict@1.3.2 +reactive-var@1.0.13 +reload@1.3.2 +retry@1.1.1 +routepolicy@1.1.2 +session@1.2.2 +shell-server@0.6.0 +socket-stream-client@0.5.3 +spacebars@2.0.0 +spacebars-compiler@2.0.0 +standard-minifier-css@1.9.3 +standard-minifier-js@3.0.0 +templating@1.4.4 +templating-compiler@2.0.0 +templating-runtime@2.0.0 +templating-tools@2.0.0 +tracker@1.3.4 +typescript@5.4.3 +underscore@1.6.4 +webapp@2.0.2 +webapp-hashing@1.1.2 diff --git a/.postcss.config.js b/.postcss.config.js new file mode 100644 index 0000000..a47ef4f --- /dev/null +++ b/.postcss.config.js @@ -0,0 +1,5 @@ +module.exports = { + plugins: { + autoprefixer: {}, + }, +}; diff --git a/client/lib/methods.js b/client/lib/methods.js index 99ca133..f2ddd7e 100644 --- a/client/lib/methods.js +++ b/client/lib/methods.js @@ -1,10 +1,10 @@ Meteor.methods({ // Meteor methods stubs to mimic real methods called on backend // for the sake of latency compensation. - flipUpCard: function(gameId, thisMove, lastMove) { - return Games.update( - {_id: gameId, 'grid.idx': thisMove.cardIdx}, - {$set: {'grid.$.class': 'turned-up player-' + thisMove.playerIdx}} + async flipUpCard(gameId, thisMove, lastMove) { + return await Games.updateAsync( + { _id: gameId, "grid.idx": thisMove.cardIdx }, + { $set: { "grid.$.class": "turned-up player-" + thisMove.playerIdx } } ); - } -}); \ No newline at end of file + }, +}); diff --git a/client/lib/startup.js b/client/lib/startup.js index 25e476f..a16dddc 100644 --- a/client/lib/startup.js +++ b/client/lib/startup.js @@ -1,34 +1,40 @@ -Meteor.startup(function() { - Session.set('message', 'test message'); - if (!(localStorage.getItem('sm_deviceId'))) { +Meteor.startup(async function () { + Session.set("message", "test message"); + if (!localStorage.getItem("sm_deviceId")) { // if no sm_deviceId, then try to get it from sm_gameId query // if search fails genereate new id - var newId = new Meteor.Collection.ObjectID; - localStorage.setItem('sm_deviceId', newId._str); + var newId = new Meteor.Collection.ObjectID(); + localStorage.setItem("sm_deviceId", newId._str); } - Session.set('deviceId', localStorage.sm_deviceId); - Session.set('gameId', localStorage.sm_gameId); - + Session.set("deviceId", localStorage.sm_deviceId); + Session.set("gameId", localStorage.sm_gameId); // override current game if linked to new game if (window.location.hash) { var urlHash = window.location.hash.substring(1); var urlOrigin = window.location.origin; if (urlHash.length === 17) { - Session.set('gameId', ''); - localStorage.setItem('sm_gameId', ''); - Games.update( - {_id: urlHash}, - {$addToSet: {players: {device: Session.get('deviceId'), matches: [], totalScore: 0, deviceName: 'Green'}}}, - function(err, res) { - Session.set('gameId', urlHash); - localStorage.setItem('sm_gameId', urlHash); - window.location.href = urlOrigin; - - Session.set('message', 'Game on! Player 2 has the first move.'); + Session.set("gameId", ""); + localStorage.setItem("sm_gameId", ""); + await Games.updateAsync( + { _id: urlHash }, + { + $addToSet: { + players: { + device: Session.get("deviceId"), + matches: [], + totalScore: 0, + deviceName: "Green", + }, + }, } ); - } + Session.set("gameId", urlHash); + localStorage.setItem("sm_gameId", urlHash); + window.location.href = urlOrigin; + + Session.set("message", "Game on! Player 2 has the first move."); + } } -}); \ No newline at end of file +}); diff --git a/client/templates/gameControl/gameContol.js b/client/templates/gameControl/gameContol.js index 3e18cbd..65082bb 100644 --- a/client/templates/gameControl/gameContol.js +++ b/client/templates/gameControl/gameContol.js @@ -1,87 +1,112 @@ -Template.GameControl.helpers ({ - gamesWaiting: function() { - var gameList = Games.find({players: {$size: 1}, gameStatus: 'fresh'}).fetch(); +Template.GameControl.helpers({ + gamesWaiting: async function () { + var gameList = await Games.find({ + players: { $size: 1 }, + gameStatus: "fresh", + }).fetchAsync(); if (gameList.length > 0) { return gameList; } }, - gameInProgress: function() { - var isDirty = Games.find({_id: Session.get('gameId'), gameStatus: 'dirty'}); - if (isDirty.count()) { - Games.remove({_id: Session.get('gameId')}); - Session.set('gameId', ''); - localStorage.setItem('sm_gameId', ''); - alert('Your opponent has left the game.'); + gameInProgress: async function () { + var dirtyCount = await Games.find({ + _id: Session.get("gameId"), + gameStatus: "dirty", + }).countAsync(); + if (dirtyCount > 0) { + await Games.removeAsync({ _id: Session.get("gameId") }); + Session.set("gameId", ""); + localStorage.setItem("sm_gameId", ""); + alert("Your opponent has left the game."); } - return Session.get('gameId'); + return Session.get("gameId"); }, - gameCompleted: function() { - - } + gameCompleted: function () {}, }); -Template.GameControl.events ({ - 'click #instructions': function(evt) { +Template.GameControl.events({ + "click #instructions": function (evt) { var instructionSymbol = document.getElementById("instructionsSymbol"); var instructionText = document.getElementById("instructionsWrapper"); if (instructionText.classList.contains("instructions-hidden")) { instructionSymbol.innerHTML = ''; instructionText.classList.remove("instructions-hidden"); - } - else { + } else { instructionSymbol.innerHTML = ''; instructionText.classList.add("instructions-hidden"); } }, - 'click section.waiting-queue': function(evt) { + "click section.waiting-queue": async function (evt) { var joinGameId = this._id; - Games.update( - {_id: joinGameId}, - {$addToSet: {players: {device: Session.get('deviceId'), matches: [], totalScore: 0, deviceName: 'Green'}}}, - function(err, res) { - Session.set('gameId', joinGameId); - localStorage.setItem('sm_gameId', joinGameId); + await Games.updateAsync( + { _id: joinGameId }, + { + $addToSet: { + players: { + device: Session.get("deviceId"), + matches: [], + totalScore: 0, + deviceName: "Green", + }, + }, } ); + Session.set("gameId", joinGameId); + localStorage.setItem("sm_gameId", joinGameId); }, - 'click #new-game-little': function(evt) { - var gameSize = 'Little'; + "click #new-game-little": async function (evt) { + var gameSize = "Little"; - Meteor.call('newGame', Session.get('deviceId'), gameSize, function(err, res) { - var newGameId = res; - Session.set('gameId', newGameId); - localStorage.setItem ('sm_gameId', Session.get('gameId')); - }); + await Meteor.callAsync("newGame", Session.get("deviceId"), gameSize).then( + function (res) { + var newGameId = res; + Session.set("gameId", newGameId); + localStorage.setItem("sm_gameId", Session.get("gameId")); + } + ); }, - 'click #new-game-big': function(evt) { - var gameSize = 'Big'; + "click #new-game-big": async function (evt) { + var gameSize = "Big"; - Meteor.call('newGame', Session.get('deviceId'), gameSize, function(err, res) { - var newGameId = res; - Session.set('gameId', newGameId); - localStorage.setItem ('sm_gameId', Session.get('gameId')); - }); + await Meteor.callAsync("newGame", Session.get("deviceId"), gameSize).then( + function (res) { + var newGameId = res; + Session.set("gameId", newGameId); + localStorage.setItem("sm_gameId", Session.get("gameId")); + } + ); }, - 'click #leave-game': function(evt) { - var conf = window.confirm('Really? End this game?'); + "click #leave-game": async function (evt) { + var conf = window.confirm("Really? End this game?"); if (conf == true) { - Meteor.call('leaveGame', Session.get('gameId'), Session.get('deviceId')); - Session.set('gameId', ''); - localStorage.setItem('sm_gameId', ''); + await Meteor.callAsync( + "leaveGame", + Session.get("gameId"), + Session.get("deviceId") + ).then(function (res) { + // console.log(res); + }); + Session.set("gameId", ""); + localStorage.setItem("sm_gameId", ""); } }, - 'click #restart-game': function(evt) { - Meteor.call('newGame', Session.get('deviceId'), null, Session.get('gameId'), function(err, res) { - console.log(res); + "click #restart-game": async function (evt) { + await Meteor.callAsync( + "newGame", + Session.get("deviceId"), + null, + Session.get("gameId") + ).then(function (res) { + // console.log(res); }); - } + }, }); diff --git a/client/templates/grid/grid.js b/client/templates/grid/grid.js index 3428d84..a75b794 100644 --- a/client/templates/grid/grid.js +++ b/client/templates/grid/grid.js @@ -1,36 +1,36 @@ -Template.Grid.helpers ({ - shuffledCards: function() { - if (Session.get('gameId')) { - var curGameId = Session.get('gameId'); - var game = Grids.findOne(curGameId); +Template.Grid.helpers({ + shuffledCards: async function () { + if (Session.get("gameId")) { + var curGameId = Session.get("gameId"); + var game = await Grids.findOneAsync(curGameId); if (game) return game.grid; return false; } - } + }, }); Template.Grid.events({ - 'click li': function(evt) { + "click li": async function (evt) { evt.preventDefault(); var thisMove = { //cardIdx: parseInt(evt.target.id.split('-')[1]), cardIdx: this.idx, - turnIdx: 1, // 1 or 2 - playerIdx: 1 // 0 or 1 + turnIdx: 1, // 1 or 2 + playerIdx: 1, // 0 or 1 }; - if (this.class.indexOf('turned-up') >= 0) return false; - var curGameData = Games.findOne({_id: Session.get('gameId')}); + if (this.class.indexOf("turned-up") >= 0) return false; + var curGameData = await Games.findOneAsync({ _id: Session.get("gameId") }); if (curGameData.players.length < 2) return false; var lastMove = curGameData.moves.pop(); - if (typeof lastMove !== 'undefined') { + if (typeof lastMove !== "undefined") { if (lastMove.turnIdx === 2) { // Next player first pick - thisMove.playerIdx = (lastMove.playerIdx) === 1 ? 0 : 1; + thisMove.playerIdx = lastMove.playerIdx === 1 ? 0 : 1; thisMove.turnIdx = 1; - Session.set('message', 'Choose a second card.'); + Session.set("message", "Choose a second card."); } else { // Same player second pick if (thisMove.cardIdx === lastMove.cardIdx) return false; @@ -39,8 +39,17 @@ Template.Grid.events({ } } - if (Session.get('deviceId') === curGameData.players[thisMove.playerIdx].device) { - Meteor.call('flipUpCard', Session.get('gameId'), thisMove, lastMove); + if ( + Session.get("deviceId") === curGameData.players[thisMove.playerIdx].device + ) { + await Meteor.callAsync( + "flipUpCard", + Session.get("gameId"), + thisMove, + lastMove + ).then(function (res) { + // console.log(res); + }); } - } + }, }); diff --git a/client/templates/matches/matches.html b/client/templates/matches/matches.html index dcd6c1d..e464def 100644 --- a/client/templates/matches/matches.html +++ b/client/templates/matches/matches.html @@ -1,19 +1,16 @@ -