From 6ac6f4d476999737dad30c772bb5d2d4a462b6a5 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 3 Dec 2014 20:24:35 -0700 Subject: [PATCH] fix(plans): fix conversion cap --- dist/habitrpg-shared.js | 11 ++++------- script/index.coffee | 5 ++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index e6273c932b..985d2663da 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -15062,15 +15062,12 @@ api.wrap = function(user, main) { return typeof cb === "function" ? cb(null, _.pick(user, $w('items stats'))) : void 0; }, purchase: function(req, cb, ga) { - var convCap, convRate, item, key, type, _base, _ref, _ref1, _ref2; + var convCap, convRate, item, key, type, _ref, _ref1, _ref2, _ref3; _ref = req.params, type = _ref.type, key = _ref.key; if (type === 'gems' && key === 'gem') { - convRate = api.planGemLimits.convRate; - if ((_base = user.purchased.plan.consecutive).gemCapExtra == null) { - _base.gemCapExtra = 0; - } - convCap = api.planGemLimits + user.purchased.plan.consecutive.gemCapExtra; - if (!((_ref1 = user.purchased) != null ? (_ref2 = _ref1.plan) != null ? _ref2.planId : void 0 : void 0)) { + _ref1 = api.planGemLimits, convRate = _ref1.convRate, convCap = _ref1.convCap; + convCap += user.purchased.plan.consecutive.gemCapExtra; + if (!((_ref2 = user.purchased) != null ? (_ref3 = _ref2.plan) != null ? _ref3.planId : void 0 : void 0)) { return typeof cb === "function" ? cb({ code: 401, message: "Must subscribe to purchase gems with GP" diff --git a/script/index.coffee b/script/index.coffee index cdd5c6b5dd..7e485f8a8b 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -694,9 +694,8 @@ api.wrap = (user, main=true) -> {type,key} = req.params if type is 'gems' and key is 'gem' - {convRate} = api.planGemLimits - user.purchased.plan.consecutive.gemCapExtra ?= 0 #fixme this necessary? - convCap = api.planGemLimits + user.purchased.plan.consecutive.gemCapExtra + {convRate, convCap} = api.planGemLimits + convCap += user.purchased.plan.consecutive.gemCapExtra return cb?({code:401,message:"Must subscribe to purchase gems with GP"},req) unless user.purchased?.plan?.planId return cb?({code:401,message:"Not enough Gold"}) unless user.stats.gp >= convRate return cb?({code:401,message:"You've reached the Gold=>Gem conversion cap (#{convCap}) for this month. We have this to prevent abuse / farming. The cap will reset within the first three days of next month."}) if user.purchased.plan.gemsBought >= convCap