mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
attempt fix using _.each in place of for loops
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
var content, expModifier, hpModifier, updateStats;
|
||||
var content, expModifier, hpModifier, score, updateStats;
|
||||
|
||||
content = require('./content');
|
||||
|
||||
@@ -55,7 +55,7 @@ updateStats = function(user, stats) {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.score = function(spec) {
|
||||
module.exports.score = score = function(spec) {
|
||||
var adjustvalue, cron, delta, direction, exp, hp, lvl, money, sign, task, type, user, value, _ref, _ref1;
|
||||
if (spec == null) {
|
||||
spec = {
|
||||
@@ -109,15 +109,16 @@ module.exports.score = function(spec) {
|
||||
};
|
||||
|
||||
module.exports.tally = function(model) {
|
||||
var absVal, completed, expTally, key, lvl, task, todoTally, type, user, value, _ref;
|
||||
var expTally, lvl, todoTally, user;
|
||||
user = model.at('_user');
|
||||
todoTally = 0;
|
||||
for (key in model.get('_user.tasks')) {
|
||||
task = model.at("_user.tasks." + key);
|
||||
_ref = [task.get('type'), task.get('value'), task.get('completed')], type = _ref[0], value = _ref[1], completed = _ref[2];
|
||||
_.each(user.get('tasks'), function(taskObj, taskId, list) {
|
||||
var absVal, completed, task, type, value, _ref;
|
||||
_ref = [taskObj.type, taskObj.value, taskObj.completed], type = _ref[0], value = _ref[1], completed = _ref[2];
|
||||
task = model.at("_user.tasks." + taskId);
|
||||
if (type === 'todo' || type === 'daily') {
|
||||
if (!completed) {
|
||||
module.exports.score({
|
||||
score({
|
||||
user: user,
|
||||
task: task,
|
||||
direction: 'down',
|
||||
@@ -134,12 +135,12 @@ module.exports.tally = function(model) {
|
||||
todoTally += absVal;
|
||||
}
|
||||
if (type === 'daily') {
|
||||
task.pass({
|
||||
return task.pass({
|
||||
cron: true
|
||||
}).set('completed', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
model.push('_user.history.todos', {
|
||||
date: new Date(),
|
||||
value: todoTally
|
||||
|
||||
Reference in New Issue
Block a user