fix bug where an un-checked to-do with checklist removes only part of reward

When a to-do is checked off, the rewards are increased by the number of checklist items that have been completed. However as reported in https://github.com/HabitRPG/habitrpg/issues/3474, if the to-do is later un-checked, then the rewards subtracted are not being similarly increased by the number of checklist items completed. This fix will change that - the number of checklist items completed will have an equal effect on checking and unchecking a to-do.

This of course won't fix the problem of, upon unchecking, not being able to calculate the exact value of the rewards that had been given upon checking, so there will still be a discrepancy between checking and unchecking, but it will be much smaller than it is currently.
This commit is contained in:
Alice Harris
2014-05-17 19:55:08 +10:00
parent 3f9daafb8e
commit 8f07f06cb0
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -13159,7 +13159,7 @@ api.wrap = function(user, main) {
return m + (i.completed ? 1 : 0);
}), 0) / task.checklist.length;
}
if (task.type === 'todo' && direction === 'up') {
if (task.type === 'todo') {
nextDelta *= 1 + _.reduce(task.checklist, (function(m, i) {
return m + (i.completed ? 1 : 0);
}), 0);
@@ -13834,4 +13834,4 @@ api.wrap = function(user, main) {
}).call(this,require("/Users/lefnire/Dropbox/Sites/habitrpg/modules/habitrpg-shared/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
},{"./content.coffee":5,"./i18n.coffee":6,"/Users/lefnire/Dropbox/Sites/habitrpg/modules/habitrpg-shared/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":2,"lodash":3,"moment":4}]},{},[1])
},{"./content.coffee":5,"./i18n.coffee":6,"/Users/lefnire/Dropbox/Sites/habitrpg/modules/habitrpg-shared/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":2,"lodash":3,"moment":4}]},{},[1])
+1 -1
View File
@@ -792,7 +792,7 @@ api.wrap = (user, main=true) ->
if direction is 'down' and task.type is 'daily' and options.cron
nextDelta *= (1 - _.reduce(task.checklist,((m,i)->m+(if i.completed then 1 else 0)),0) / task.checklist.length)
# If To-Do, point-match the TD per checklist item completed
if task.type is 'todo' and direction is 'up'
if task.type is 'todo'
nextDelta *= (1 + _.reduce(task.checklist,((m,i)->m+(if i.completed then 1 else 0)),0))
unless task.type is 'reward'