mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-23 14:17:05 +00:00
cleanup corrupt stats too
This commit is contained in:
parent
c40ec44644
commit
8ae6e361b8
3 changed files with 1425 additions and 1409 deletions
File diff suppressed because one or more lines are too long
|
|
@ -265,6 +265,12 @@ try {
|
|||
task.value = value = 0;
|
||||
paths["tasks." + task.id + ".value"] = true;
|
||||
}
|
||||
_.each(user.stats, function(v, k) {
|
||||
if (!_.isNumber(v) || _.isNaN(v)) {
|
||||
user.stats[k] = 0;
|
||||
return paths["stats." + k] = true;
|
||||
}
|
||||
});
|
||||
if (task.value > user.stats.gp && task.type === 'reward') {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1675,7 +1681,7 @@ process.chdir = function (dir) {
|
|||
|
||||
|
||||
})(require("__browserify_process"))
|
||||
},{"./items.coffee":3,"lodash":6,"moment":5,"relative-date":8,"__browserify_process":7}],5:[function(require,module,exports){
|
||||
},{"./items.coffee":3,"moment":5,"lodash":6,"relative-date":8,"__browserify_process":7}],5:[function(require,module,exports){
|
||||
(function(){// moment.js
|
||||
// version : 2.0.0
|
||||
// author : Tim Wood
|
||||
|
|
|
|||
|
|
@ -192,10 +192,14 @@ obj.score = (user, task, direction, options={}) ->
|
|||
priority = task.priority or '!'
|
||||
|
||||
# Handle corrupt tasks
|
||||
# This type of cleanup-code shouldn't be necessary, revisit once we're off Derby
|
||||
return 0 unless task.id
|
||||
if !_.isNumber(value) or _.isNaN(value)
|
||||
task.value = value = 0;
|
||||
paths["tasks.#{task.id}.value"] = true
|
||||
_.each user.stats, (v,k) ->
|
||||
if !_.isNumber(v) or _.isNaN(v)
|
||||
user.stats[k] = 0; paths["stats.#{k}"] = true
|
||||
|
||||
# If they're trying to purhcase a too-expensive reward, don't allow them to do that.
|
||||
if task.value > user.stats.gp and task.type is 'reward'
|
||||
|
|
|
|||
Loading…
Reference in a new issue