mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-08 13:35:38 +00:00
[https://github.com/HabitRPG/habitrpg/issues/1994] fixes to purchasing shirts
This commit is contained in:
parent
41c2218976
commit
75b966bda4
2 changed files with 8 additions and 6 deletions
9
dist/habitrpg-shared.js
vendored
9
dist/habitrpg-shared.js
vendored
|
|
@ -11405,14 +11405,15 @@ var process=require("__browserify_process");(function() {
|
|||
}, req) : void 0;
|
||||
},
|
||||
unlock: function(req, cb) {
|
||||
var cost, fullSet, k, path, split, v;
|
||||
var alreadyOwns, cost, fullSet, k, path, split, v;
|
||||
path = req.query.path;
|
||||
fullSet = ~path.indexOf(",");
|
||||
cost = fullSet ? 1.25 : 0.5;
|
||||
if (user.balance < cost) {
|
||||
alreadyOwns = !fullSet && user.fns.dotGet("purchased." + path) === true;
|
||||
if (user.balance < cost && !alreadyOwns) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 401,
|
||||
err: "Not enough gems"
|
||||
message: "Not enough gems"
|
||||
}) : void 0;
|
||||
}
|
||||
if (fullSet) {
|
||||
|
|
@ -11421,7 +11422,7 @@ var process=require("__browserify_process");(function() {
|
|||
return true;
|
||||
});
|
||||
} else {
|
||||
if (user.fns.dotGet("purchased." + path) === true) {
|
||||
if (alreadyOwns) {
|
||||
split = path.split('.');
|
||||
v = split.pop();
|
||||
k = split.join('.');
|
||||
|
|
|
|||
|
|
@ -565,12 +565,13 @@ api.wrap = (user) ->
|
|||
{path} = req.query
|
||||
fullSet = ~path.indexOf(",")
|
||||
cost = if fullSet then 1.25 else 0.5 # 5G per set, 2G per individual
|
||||
return cb?({code:401, err: "Not enough gems"}) if user.balance < cost
|
||||
alreadyOwns = !fullSet and user.fns.dotGet("purchased." + path) is true
|
||||
return cb?({code:401, message: "Not enough gems"}) if user.balance < cost and !alreadyOwns
|
||||
if fullSet
|
||||
_.each path.split(","), (p) ->
|
||||
user.fns.dotSet("purchased.#{p}", true);true
|
||||
else
|
||||
if user.fns.dotGet("purchased." + path) is true
|
||||
if alreadyOwns
|
||||
split = path.split('.');v=split.pop();k=split.join('.')
|
||||
user.fns.dotSet("preferences.#{k}",v)
|
||||
return cb? null, req
|
||||
|
|
|
|||
Loading…
Reference in a new issue