mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-31 23:11:15 +00:00
habitrpg-shared: fix cron to work with habitrpg-shared d293f74
This commit is contained in:
parent
467741570a
commit
c894f87310
1 changed files with 3 additions and 3 deletions
|
|
@ -135,17 +135,17 @@ ready (model) ->
|
|||
require('./unlock').app(exports, model)
|
||||
require('./filters').app(exports, model)
|
||||
|
||||
uObj = misc.hydrate(user.get())
|
||||
cron = ->
|
||||
#return setTimeout(cron, 1) if model._txnQueue.length > 0
|
||||
uObj = misc.hydrate(user.get()) # need to clone, else derby won't catch model.set()'s after obj property sets
|
||||
# habitrpg-shared/algos requires uObj.habits, uObj.dailys etc instead of uObj.tasks
|
||||
_.each ['habit','daily','todo','reward'], (type) ->
|
||||
uObj["#{type}s"] = _.where(uObj.tasks, {type:type}); true
|
||||
paths = {}
|
||||
algos.cron(uObj, paths)
|
||||
algos.cron(uObj, {paths:paths})
|
||||
lostHp = delete paths['stats.hp'] # we'll set this manually so we can get a cool animation
|
||||
_.each paths, (v,k) -> user.pass({cron:true}).set(k,helpers.dotGet(k, uObj)); true
|
||||
if lostHp
|
||||
browser.resetDom(model)
|
||||
setTimeout (-> user.set('stats.hp', uObj.stats.hp)), 750
|
||||
cron() if algos.shouldCron {lastCron: user.get('lastCron'), preferences: user.get('preferences')}
|
||||
cron() if algos.shouldCron(uObj)
|
||||
Loading…
Reference in a new issue