fix(plans): fix conversion cap

This commit is contained in:
Tyler Renelle
2014-12-03 20:24:35 -07:00
parent 9e64bc3788
commit 6ac6f4d476
2 changed files with 6 additions and 10 deletions
+4 -7
View File
@@ -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"
+2 -3
View File
@@ -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