mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-02 04:00:36 +00:00
update daily.value when checked off, not on cron. Better for
testability, and I'm not sure why I was doing it the other way before?
This commit is contained in:
parent
f5b7968132
commit
85eb6789ac
2 changed files with 13 additions and 19 deletions
|
|
@ -184,8 +184,7 @@ obj.score = (user, task, direction, options={}) ->
|
|||
addPoints = ->
|
||||
level = user.stats.lvl
|
||||
weaponStrength = items.items.weapon[user.items.weapon].strength
|
||||
exp += obj.expModifier(delta, weaponStrength, level, priority) / 2
|
||||
# / 2 hack for now bcause people leveling too fast
|
||||
exp += obj.expModifier(delta, weaponStrength, level, priority) / 2 # /2 hack for now, people leveling too fast
|
||||
if streak
|
||||
gp += obj.gpModifier(delta, 1, priority, streak, user)
|
||||
else
|
||||
|
|
@ -213,8 +212,7 @@ obj.score = (user, task, direction, options={}) ->
|
|||
subtractPoints()
|
||||
task.streak = 0
|
||||
else
|
||||
calculateDelta(false)
|
||||
if delta != 0
|
||||
calculateDelta()
|
||||
addPoints() # obviously for delta>0, but also a trick to undo accidental checkboxes
|
||||
if direction is 'up'
|
||||
streak = if streak then streak + 1 else 1
|
||||
|
|
@ -363,16 +361,13 @@ obj.cron = (user, options={}) ->
|
|||
|
||||
switch type
|
||||
when 'daily'
|
||||
if completed #set OHV for completed dailies
|
||||
task.value = task.value + obj.taskDeltaFormula(task.value, 'up')
|
||||
(task.history ?= []).push { date: +new Date, value: task.value }
|
||||
task.completed = false
|
||||
paths["tasks.#{task.id}.value"] = true;paths["tasks.#{task.id}.history"] = true;paths["tasks.#{task.id}.completed"] = true;
|
||||
|
||||
(task.history ?= []).push({ date: +new Date, value: task.value }); paths["tasks.#{task.id}.history"] = true
|
||||
task.completed = false; paths["tasks.#{task.id}.completed"] = true;
|
||||
when 'todo'
|
||||
#get updated value
|
||||
absVal = if (completed) then Math.abs(task.value) else task.value
|
||||
todoTally += absVal
|
||||
|
||||
user.habits.forEach (task) -> # slowly reset 'onlies' value to 0
|
||||
if task.up is false or task.down is false
|
||||
if Math.abs(task.value) < 0.1
|
||||
|
|
|
|||
|
|
@ -35,9 +35,8 @@ expectGainedPoints = (before, after, taskType) ->
|
|||
expect(after.stats.exp).to.be.greaterThan before.stats.exp
|
||||
expect(after.stats.gp).to.be.greaterThan before.stats.gp
|
||||
expect(after["#{taskType}s"][0].value).to.be.greaterThan before["#{taskType}s"][0].value
|
||||
if taskType in ['daily','habit']
|
||||
expect(_.size(after["#{taskType}s"][0].history)).to.be(1)
|
||||
# expect(after["#{taskType}s"].completed).to.be true if taskType in ['daily','todo']
|
||||
expect(_.size(after["#{taskType}s"][0].history)).to.be(1) if taskType is 'habit'
|
||||
# daily & todo histories handled on cron
|
||||
|
||||
###### Specs ######
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue