mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-16 17:02:18 +00:00
initial changes to cause cron to count multiple missed days as one missed day
This commit is contained in:
parent
2069936603
commit
c3d65f0bcf
3 changed files with 31 additions and 10 deletions
|
|
@ -1722,12 +1722,16 @@ api.wrap = (user, main=true) ->
|
|||
daily.completed = false
|
||||
return
|
||||
|
||||
multiDaysCountAsOneDay = true
|
||||
# If the user does not log in for two or more days, cron (mostly) acts as if it were only one day.
|
||||
# When site-wide difficulty settings are introduced, this can be a user preference option.
|
||||
|
||||
# Tally each task
|
||||
todoTally = 0
|
||||
user.todos.forEach (task) -> # make uncompleted todos redder
|
||||
return unless task
|
||||
{id, completed} = task
|
||||
delta = user.ops.score({params:{id:task.id, direction:'down'}, query:{times:(daysMissed), cron:true}})
|
||||
delta = user.ops.score({params:{id:task.id, direction:'down'}, query:{times:(multiDaysCountAsOneDay ? 1 : daysMissed), cron:true}})
|
||||
absVal = if (completed) then Math.abs(task.value) else task.value
|
||||
todoTally += absVal
|
||||
|
||||
|
|
@ -1745,14 +1749,22 @@ api.wrap = (user, main=true) ->
|
|||
dailyChecked += 1
|
||||
else
|
||||
# dailys repeat, so need to calculate how many they've missed according to their own schedule
|
||||
console.log("task: " + task.text) # XXX Alys to remove these
|
||||
scheduleMisses = 0
|
||||
keepGoing = true # XXX Alys to improve how we break out of _.times
|
||||
_.times daysMissed, (n) ->
|
||||
thatDay = moment(now).subtract({days: n + 1})
|
||||
if api.shouldDo(thatDay.toDate(), task, user.preferences)
|
||||
scheduleMisses++
|
||||
if user.stats.buffs.stealth
|
||||
user.stats.buffs.stealth--
|
||||
EvadeTask++
|
||||
if keepGoing
|
||||
console.log("n: " + n)
|
||||
thatDay = moment(now).subtract({days: n + 1})
|
||||
if api.shouldDo(thatDay.toDate(), task, user.preferences)
|
||||
console.log("damage")
|
||||
scheduleMisses++
|
||||
if user.stats.buffs.stealth
|
||||
user.stats.buffs.stealth--
|
||||
EvadeTask++
|
||||
if multiDaysCountAsOneDay
|
||||
console.log("end")
|
||||
keepGoing = false
|
||||
|
||||
if scheduleMisses > EvadeTask
|
||||
perfect = false
|
||||
|
|
@ -1762,7 +1774,7 @@ api.wrap = (user, main=true) ->
|
|||
dailyChecked += fractionChecked
|
||||
else
|
||||
dailyDueUnchecked += 1
|
||||
delta = user.ops.score({params:{id:task.id, direction:'down'}, query:{times:(scheduleMisses-EvadeTask), cron:true}})
|
||||
delta = user.ops.score({params:{id:task.id, direction:'down'}, query:{times:(multiDaysCountAsOneDay ? 1 : (scheduleMisses-EvadeTask)), cron:true}})
|
||||
|
||||
# Apply damage from a boss, less damage for Trivial priority (difficulty)
|
||||
user.party.quest.progress.down += delta * (if task.priority < 1 then task.priority else 1)
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ newUser = (addTasks=true)->
|
|||
user.ops.addTask {body: {type: task, id: shared.uuid()}}
|
||||
user
|
||||
|
||||
cron = (usr) ->
|
||||
usr.lastCron = moment().subtract(1,'days')
|
||||
cron = (usr, missedDays=1) ->
|
||||
usr.lastCron = moment().subtract(missedDays,'days')
|
||||
usr.fns.cron()
|
||||
|
||||
describe 'daily/weekly that repeats everyday (default)', ->
|
||||
|
|
|
|||
|
|
@ -79,6 +79,15 @@ footer.footer(ng-controller='FooterCtrl')
|
|||
a.btn.btn-default(ng-click='setHealthLow()') Health = 1
|
||||
a.btn.btn-default(ng-click='addMissedDay(1)') +1 Missed Day
|
||||
a.btn.btn-default(ng-click='addMissedDay(2)') +2 Missed Days
|
||||
// XXX Alys to remove these excess ones when testing is done:
|
||||
a.btn.btn-default(ng-click='addMissedDay(3)') +3 Missed Days
|
||||
a.btn.btn-default(ng-click='addMissedDay(4)') +4 Missed Days
|
||||
a.btn.btn-default(ng-click='addMissedDay(5)') +5 Missed Days
|
||||
a.btn.btn-default(ng-click='addMissedDay(6)') +6 Missed Days
|
||||
a.btn.btn-default(ng-click='addMissedDay(7)') +7 Missed Days
|
||||
a.btn.btn-default(ng-click='addMissedDay(8)') +8 Missed Days
|
||||
a.btn.btn-default(ng-click='addMissedDay(9)') +9 Missed Days
|
||||
a.btn.btn-default(ng-click='addMissedDay(10)') +10 Missed Day
|
||||
a.btn.btn-default(ng-click='addTenGems()') +10 Gems
|
||||
a.btn.btn-default(ng-click='addGold()') +GP
|
||||
a.btn.btn-default(ng-click='addMana()') +MP
|
||||
|
|
|
|||
Loading…
Reference in a new issue