From c81d3213665ef89be525ce949d10a34a754a187f Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sat, 2 May 2015 22:10:26 -0500 Subject: [PATCH] Checklists should reset even when resting in the inn --- common/script/index.coffee | 1 + test/common/algos.mocha.coffee | 48 +++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/common/script/index.coffee b/common/script/index.coffee index e3f97c5612..215ad65136 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -1488,6 +1488,7 @@ api.wrap = (user, main=true) -> user.stats.buffs = clearBuffs user.dailys.forEach (daily) -> daily.completed = false + _.each daily.checklist, ((i)->i.completed=false;true) return # Tally each task diff --git a/test/common/algos.mocha.coffee b/test/common/algos.mocha.coffee index 78f7886046..5d967d2f84 100644 --- a/test/common/algos.mocha.coffee +++ b/test/common/algos.mocha.coffee @@ -1,6 +1,3 @@ -### Install: npm install --dev ### -### Run: npm test ### - _ = require 'lodash' expect = require 'expect.js' sinon = require 'sinon' @@ -203,6 +200,51 @@ describe 'User', -> cron() expect(user.dailys[0].completed).to.not.be.ok + it 'resets checklist on incomplete dailies', -> + user.dailys[0].checklist = [ + { + "text" : "1", + "id" : "checklist-one", + "completed" : true + }, + { + "text" : "2", + "id" : "checklist-two", + "completed" : true + }, + { + "text" : "3", + "id" : "checklist-three", + "completed" : false + } + ] + cron() + _.each user.dailys[0].checklist, (box)-> + expect(box.completed).to.not.be.ok + + it 'resets checklist on complete dailies', -> + user.dailys[0].checklist = [ + { + "text" : "1", + "id" : "checklist-one", + "completed" : true + }, + { + "text" : "2", + "id" : "checklist-two", + "completed" : true + }, + { + "text" : "3", + "id" : "checklist-three", + "completed" : false + } + ] + user.dailys[0].completed = true + cron() + _.each user.dailys[0].checklist, (box)-> + expect(box.completed).to.not.be.ok + it 'does not damage user for incomplete dailies', -> expect(user).toHaveHP 50 user.dailys[0].completed = true