mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
fix(plans): possible safe-check of gemcapextra cc @Sabrecat
This commit is contained in:
parent
cb8c1359c4
commit
9d3e6c71fe
2 changed files with 5 additions and 1 deletions
5
dist/habitrpg-shared.js
vendored
5
dist/habitrpg-shared.js
vendored
|
|
@ -15062,10 +15062,13 @@ 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, _ref, _ref1, _ref2;
|
||||
var convCap, convRate, item, key, type, _base, _ref, _ref1, _ref2;
|
||||
_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)) {
|
||||
return typeof cb === "function" ? cb({
|
||||
|
|
|
|||
|
|
@ -695,6 +695,7 @@ api.wrap = (user, main=true) ->
|
|||
|
||||
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
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue