From 2ca050d61e1935e69e40ee6a24a8598e576bd506 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Fri, 29 Jun 2012 09:04:35 -0400 Subject: [PATCH] Bug fixes on endOfDayTally, put it back into htlm for testing purposes --- src/app/index.coffee | 14 +++++++++++--- views/app/index.html | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/index.coffee b/src/app/index.coffee index 95d7489cc4..35ee5c16bc 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -111,13 +111,14 @@ poormanscron = (model) -> lastCron = new Date() model.set('_user.lastCron', lastCron) -endOfDayTally = (model) -> # Note: Set 12am daily cron for this # At end of day, add value to all incomplete Daily & Todo tasks (further incentive) # For incomplete Dailys, deduct experience +endOfDayTally = (model) -> # users = model.at('users') #TODO this isn't working, iterate over all users # for user in users user = model.at '_user' + todoTally = 0 for key of model.get '_user.tasks' task = model.at "_user.tasks.#{key}" [type, value, completed] = [task.get('type'), task.get('value'), task.get('completed')] @@ -125,8 +126,6 @@ endOfDayTally = (model) -> unless completed value += if (value < 0) then (( -0.1 * value + 1 ) * -1) else (( Math.pow(0.9,value) ) * -1) task.set('value', value) - task.setNull 'history', [] - task.push "history", { date: new Date(), value: value } # Deduct experience for missed Daily tasks, # but not for Todos (just increase todo's value) if (type == 'daily') @@ -135,6 +134,11 @@ endOfDayTally = (model) -> #TODO this is implemented in exports.vote also, make it a user.on or something user.set('hp',50);user.set('lvl',1);user.set('exp',0) task.set('completed', false) if type == 'daily' + if type == 'daily' + task.push "history", { date: new Date(), value: task.get('value') } + else + todoTally += task.get('value') + model.push '_user.history.todos', { date: new Date(), value: todoTally } ## VIEW HELPERS ## view.fn 'taskClasses', (type, completed, value, hideCompleted) -> @@ -335,6 +339,10 @@ ready (model) -> user.set('lvl', lvl) #[user.money, user.hp, user.exp, user.lvl] = [money, hp, exp, lvl] + exports.eodTally = (e, el) -> + #copy/paste endOfDayTally() here for testing purposes + return + ## SHORTCUTS ## exports.shortcuts = (e) -> diff --git a/views/app/index.html b/views/app/index.html index 50fdb9742b..c26e0c214a 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -36,7 +36,7 @@
- + Tally