Skip to content

Commit

Permalink
account for undfined lastCrons
Browse files Browse the repository at this point in the history
  • Loading branch information
lefnire committed Jan 29, 2013
1 parent 4fae8f0 commit 3242ce6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/app/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/app/schema.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 3242ce6

Please sign in to comment.