account for undfined lastCrons

This commit is contained in:
Tyler Renelle 2013-01-29 00:02:30 -05:00
parent 4fae8f05a4
commit 3242ce6e95
2 changed files with 5 additions and 2 deletions

View file

@ -97,7 +97,10 @@ resetDom = (model) ->
ready (model) ->
user = model.at('_user')
user.set('lastCron', +new Date) if user.get('lastCron')=='new' #set cron immediately
#set cron immediately
lastCron = user.get('lastCron')
user.set('lastCron', +new Date) if (!lastCron or lastCron == 'new')
# Setup model in scoring functions
scoring.setModel(model)

View file

@ -5,7 +5,7 @@ _ = require 'underscore'
module.exports.userSchema = ->
# deep clone, else further new users get duplicate objects
newUser = require('lodash').cloneDeep
lastCron: 'new' #this will be replaced with a date on first run
lastCron: 'new' #this will be replaced with `+new Date` on first run
balance: 2
stats: { money: 0, exp: 0, lvl: 1, hp: 50 }
items: { itemsEnabled: false, armor: 0, weapon: 0 }