diff --git a/README.md b/README.md index c78cf4efbc..a1f72f8f94 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ HabitRPG [HabitRPG](https://habitrpg.com) is an open source habit building program which treats your life like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor. Built using Angular, Express, Mongoose, Jade, Stylus, Grunt and Bower. - -# Set up HabitRPG locally + +# Set up HabitRPG locally **Windows** users should skip this section and read the one below with Windows-specific steps. @@ -35,7 +35,7 @@ If MongoDB starts up successfully, you should see the following at the end of th ```Sun Sep 01 18:10:21.233 [initandlisten] waiting for connections on port 27017 Sun Sep 01 18:10:21.233 [websvr] admin web console waiting for connections on po rt 28017``` - + 1. Install Node.js (includes npm). Steps: 1. Download and run the latest Node.js msi installation file from http://nodejs.org/download/ 1. Install [Git](https://help.github.com/articles/set-up-git). @@ -45,7 +45,7 @@ rt 28017``` 1. Install the **npm** packages: `npm install` Read below for possible error message. - + You might receive the following error during the 'npm install' command: > habitrpg@0.0.0-152 postinstall C:\Users\022498\Projects\habitrpg > ./node_modules/bower/bin/bower install -f diff --git a/src/controllers/user.js b/src/controllers/user.js index 4d9347e9f1..25919d0e4e 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -69,10 +69,9 @@ function deleteTask(user, task) { }; function addTask(user, task) { - var type = task.type || 'habit' - user[type+'s'].unshift(task); - // FIXME will likely have to use taskSchema instead, so we can populate the defaults, add the _id, and return the added task - return user[task.type+'s'][0]; + task = helpers.taskDefaults(task); + user[task.type+'s'].unshift(task); + return task; } /* @@ -109,11 +108,10 @@ api.scoreTask = function(req, res, next) { return res.json(500, {err: ":direction must be 'up' or 'down'"}); } // If exists already, score it - var existing; - if (existing = user.tasks[id]) { + if (task = user.tasks[id]) { // Set completed if type is daily or todo and task exists - if (existing.type === 'daily' || existing.type === 'todo') { - existing.completed = direction === 'up'; + if (task.type === 'daily' || task.type === 'todo') { + task.completed = direction === 'up'; } } else { // If it doesn't exist, this is likely a 3rd party up/down - create a new one, then score it @@ -130,9 +128,8 @@ api.scoreTask = function(req, res, next) { if (task.type === 'daily' || task.type === 'todo') { task.completed = direction === 'up'; } - addTask(user, task); + task = addTask(user, task); } - task = user.tasks[id]; var delta = algos.score(user, task, direction); //user.markModified('flags'); user.save(function(err, saved) {