From 74723c7cab816bad78af1808928c4f89511a4e2b Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 13 Feb 2013 16:07:45 -0500 Subject: [PATCH] put purchase confirm up top, otherwise they still lose GP --- src/app/scoring.coffee | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 96751803d2..6a3e53023f 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -110,6 +110,7 @@ updateStats = (newStats, batch) -> # {times} # times to call score on this task (1 unless cron, usually) # {update} if we're running updates en-mass (eg, cron on server) pass in userObj score = (taskId, direction, times, batch, cron) -> + commit = false unless batch? commit = true @@ -123,6 +124,13 @@ score = (taskId, direction, times, batch, cron) -> taskObj = obj.tasks[taskId] {type, value} = taskObj + # If they're trying to purhcase a too-expensive reward, confirm they want to take a hit for it + if taskObj.value > obj.stats.gp and taskObj.type is 'reward' + r = confirm "Not enough GP to purchase this reward, buy anyway and lose HP? (Punishment for taking a reward you didn't earn)." + unless r + batch.commit() + return + delta = 0 times ?= 1 calculateDelta = (adjustvalue=true) -> @@ -176,11 +184,8 @@ score = (taskId, direction, times, batch, cron) -> gp -= Math.abs(taskObj.value) num = parseFloat(taskObj.value).toFixed(2) # if too expensive, reduce health & zero gp - if gp < 0 - r = confirm "You don't have enough GP to purchase this reward, purchase anyway and lose health?" - if r - hp += gp # hp - gp difference + hp += gp # hp - gp difference gp = 0 taskObj.value = value