small cleanup of cloning user schema

This commit is contained in:
Tyler Renelle 2013-01-02 12:31:16 -05:00
parent e4afeb9b8e
commit e42971d202
2 changed files with 13 additions and 15 deletions

View file

@ -2,21 +2,19 @@ content = require './content'
moment = require 'moment'
_ = require 'lodash'
userSchema = {
balance: 2
stats: { money: 0, exp: 0, lvl: 1, hp: 50 }
items: { itemsEnabled: false, armor: 0, weapon: 0 }
tasks: {}
habitIds: []
dailyIds: []
todoIds: []
completedIds: []
rewardIds: []
}
module.exports.newUserObject = ->
module.exports.userSchema = ->
# deep clone, else further new users get duplicate objects
newUser = _.cloneDeep(userSchema)
newUser = _.cloneDeep
balance: 2
stats: { money: 0, exp: 0, lvl: 1, hp: 50 }
items: { itemsEnabled: false, armor: 0, weapon: 0 }
tasks: {}
habitIds: []
dailyIds: []
todoIds: []
completedIds: []
rewardIds: []
for task in content.defaultTasks
guid = task.id = require('racer').uuid()
newUser.tasks[guid] = task

View file

@ -49,7 +49,7 @@ strategies =
options =
domain: (if process.env.NODE_ENV == 'production' then 'https://habitrpg.com' else "http://localhost:3000")
allowPurl: true
schema: require('../app/schema').newUserObject()
schema: require('../app/schema').userSchema()
mongo_store = new MongoStore {url: process.env.NODE_DB_URI}, ->
expressApp