From 17b9104e098245bcb4a8ddd954b3ea2b83310348 Mon Sep 17 00:00:00 2001 From: Alice Harris Date: Sun, 16 Feb 2014 08:21:32 +1000 Subject: [PATCH] prevent critical hit when unticking a task Fixes https://github.com/HabitRPG/habitrpg/issues/2356 Currently, when you untick a todo or daily, there's a chance of a critical hit. This prevents that. --- script/index.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/index.coffee b/script/index.coffee index f46f8afbd8..99d2647ba0 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -806,7 +806,8 @@ api.wrap = (user, main=true) -> addPoints = -> # ===== CRITICAL HITS ===== - _crit = user.fns.crit() + # allow critical hit only when checking off a task, not when unchecking it: + _crit = (if delta > 0 then user.fns.crit() else 1) # if there was a crit, alert the user via notification user._tmp.crit = _crit if _crit > 1