mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 09:39:23 +00:00
habitrpg-shared: fix cron, so it doesn't run fully for new users
This commit is contained in:
parent
f0c50e1cfe
commit
fc14eadc08
1 changed files with 17 additions and 13 deletions
|
|
@ -135,17 +135,21 @@ ready (model) ->
|
||||||
require('./unlock').app(exports, model)
|
require('./unlock').app(exports, model)
|
||||||
require('./filters').app(exports, model)
|
require('./filters').app(exports, model)
|
||||||
|
|
||||||
|
###
|
||||||
|
Cron
|
||||||
|
###
|
||||||
uObj = misc.hydrate(user.get())
|
uObj = misc.hydrate(user.get())
|
||||||
cron = ->
|
# habitrpg-shared/algos requires uObj.habits, uObj.dailys etc instead of uObj.tasks
|
||||||
#return setTimeout(cron, 1) if model._txnQueue.length > 0
|
_.each ['habit','daily','todo','reward'], (type) ->
|
||||||
# habitrpg-shared/algos requires uObj.habits, uObj.dailys etc instead of uObj.tasks
|
uObj["#{type}s"] = _.where(uObj.tasks, {type:type}); true
|
||||||
_.each ['habit','daily','todo','reward'], (type) ->
|
paths = {}
|
||||||
uObj["#{type}s"] = _.where(uObj.tasks, {type:type}); true
|
algos.cron(uObj, {paths:paths})
|
||||||
paths = {}
|
if !_.isEmpty(paths)
|
||||||
algos.cron(uObj, {paths:paths})
|
if paths['lastCron'] and _.size(paths) is 1
|
||||||
lostHp = delete paths['stats.hp'] # we'll set this manually so we can get a cool animation
|
user.set "lastCron", uObj.lastCron
|
||||||
_.each paths, (v,k) -> user.pass({cron:true}).set(k,helpers.dotGet(k, uObj)); true
|
else
|
||||||
if lostHp
|
lostHp = delete paths['stats.hp'] # we'll set this manually so we can get a cool animation
|
||||||
browser.resetDom(model)
|
_.each paths, (v,k) -> user.pass({cron:true}).set(k,helpers.dotGet(k, uObj)); true
|
||||||
setTimeout (-> user.set('stats.hp', uObj.stats.hp)), 750
|
if lostHp
|
||||||
cron() if algos.shouldCron(uObj)
|
browser.resetDom(model)
|
||||||
|
setTimeout (-> user.set('stats.hp', uObj.stats.hp)), 750
|
||||||
Loading…
Reference in a new issue