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
+8 -8
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 ==========
+3 -4
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 }