some typos and bugs, though didn't seem to fix anything

This commit is contained in:
Tyler Renelle 2012-08-08 20:28:01 -04:00
parent b2cd9c0d0f
commit 29acf91e03
4 changed files with 22 additions and 24 deletions

View file

@ -302,17 +302,17 @@ ready(function(model) {
daysPassed = helpers.daysBetween(lastCron, today);
if (daysPassed > 0) {
model.set('_user.lastCron', today);
return _.times(daysPassed, (function() {
return scoring.tally(model);
}));
return _(daysPassed).times(function() {
return scoring.tally(model.at('_user'));
});
}
};
setTimeout((function() {
setTimeout(function() {
return poormanscron();
}), 2000);
setInterval((function() {
}, 2000);
setInterval(function() {
return poormanscron();
}), 3600000);
}, 3600000);
exports.endOfDayTally = function(e, el) {
return scoring.tally(model);
};

View file

@ -108,9 +108,8 @@ module.exports.score = score = function(spec) {
return delta;
};
module.exports.tally = function(model) {
var expTally, lvl, todoTally, user;
user = model.at('_user');
module.exports.tally = function(user) {
var expTally, lvl, todoTally;
todoTally = 0;
_.each(user.get('tasks'), function(taskObj, taskId, list) {
var absVal, completed, task, type, value, _ref;
@ -144,7 +143,7 @@ module.exports.tally = function(model) {
}
}
});
model.push('_user.history.todos', {
user.push('history.todos', {
date: new Date(),
value: todoTally
});
@ -154,7 +153,7 @@ module.exports.tally = function(model) {
lvl++;
expTally += 50 * Math.pow(lvl, 2) - 150 * lvl + 200;
}
return model.push('_user.history.exp', {
return user.push('history.exp', {
date: new Date(),
value: expTally
});

View file

@ -54,7 +54,8 @@ get '/:uidParam?', (page, model, {uidParam}) ->
reroll: content.items.reroll
# http://tibia.wikia.com/wiki/Formula
model.fn '_user._tnl', '_user.stats.lvl', (lvl) -> 50 * Math.pow(lvl, 2) - 150 * lvl + 200
model.fn '_user._tnl', '_user.stats.lvl', (lvl) ->
50 * Math.pow(lvl, 2) - 150 * lvl + 200
# Default Tasks
model.refList "_habitList", "_user.tasks", "_user.habitIds"
@ -250,17 +251,16 @@ ready (model) ->
daysPassed = helpers.daysBetween(lastCron, today)
if daysPassed > 0
model.set('_user.lastCron', today) # reset cron
_.times daysPassed, (->
scoring.tally(model)
)
_(daysPassed).times () ->
scoring.tally(model.at('_user'))
# FIXME seems can't call poormanscron() instantly, have to call after some time (2s here)
# Doesn't do anything otherwise. Don't know why... model not initialized enough yet?
setTimeout (-> # Run once on refresh
setTimeout () -> # Run once on refresh
poormanscron()
), 2000
setInterval (-> # Then run once every hour
, 2000
setInterval () -> # Then run once every hour
poormanscron()
), 3600000
, 3600000
# ========== DEBUGGING ==========

View file

@ -98,8 +98,7 @@ module.exports.score = score = (spec = {user:null, task:null, direction:null, cr
# At end of day, add value to all incomplete Daily & Todo tasks (further incentive)
# For incomplete Dailys, deduct experience
module.exports.tally = (model) ->
user = model.at '_user'
module.exports.tally = (user) ->
todoTally = 0
_.each user.get('tasks'), (taskObj, taskId, list) ->
#FIXME is it hiccuping here? taskId == "$_65255f4e-3728-4d50-bade-3b05633639af_2", & taskObj.id = undefined
@ -116,7 +115,7 @@ module.exports.tally = (model) ->
absVal = if (completed) then Math.abs(value) else value
todoTally += absVal
task.pass({cron:true}).set('completed', false) if type == 'daily'
model.push '_user.history.todos', { date: new Date(), value: todoTally }
user.push 'history.todos', { date: new Date(), value: todoTally }
# tally experience
expTally = user.get 'stats.exp'
@ -124,4 +123,4 @@ module.exports.tally = (model) ->
while lvl < (user.get('stats.lvl')-1)
lvl++
expTally += 50 * Math.pow(lvl, 2) - 150 * lvl + 200
model.push '_user.history.exp', { date: new Date(), value: expTally }
user.push 'history.exp', { date: new Date(), value: expTally }