* Don't unpin non-gear items Assumes that multiple of bundles, quests, eggs, potions can be bought * Added tests * Changed type checking and made variables global * Lint fix
This commit is contained in:
committed by
Matteo Pagliazzi
parent
c12ae9ea25
commit
5449652bd2
@@ -106,6 +106,8 @@ function purchaseItem (user, item, price, type, key) {
|
||||
}
|
||||
}
|
||||
|
||||
const acceptedTypes = ['eggs', 'hatchingPotions', 'food', 'quests', 'gear', 'bundles'];
|
||||
const singlePurchaseTypes = ['gear'];
|
||||
module.exports = function purchase (user, req = {}, analytics) {
|
||||
let type = get(req.params, 'type');
|
||||
let key = get(req.params, 'key');
|
||||
@@ -129,8 +131,7 @@ module.exports = function purchase (user, req = {}, analytics) {
|
||||
return gemResponse;
|
||||
}
|
||||
|
||||
let acceptedTypes = ['eggs', 'hatchingPotions', 'food', 'quests', 'gear', 'bundles'];
|
||||
if (acceptedTypes.indexOf(type) === -1) {
|
||||
if (!acceptedTypes.includes(type)) {
|
||||
throw new NotFound(i18n.t('notAccteptedType', req.language));
|
||||
}
|
||||
|
||||
@@ -144,8 +145,10 @@ module.exports = function purchase (user, req = {}, analytics) {
|
||||
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
|
||||
}
|
||||
|
||||
let itemInfo = getItemInfo(user, type, item);
|
||||
removeItemByPath(user, itemInfo.path);
|
||||
if (singlePurchaseTypes.includes(type)) {
|
||||
let itemInfo = getItemInfo(user, type, item);
|
||||
removeItemByPath(user, itemInfo.path);
|
||||
}
|
||||
|
||||
for (let i = 0; i < quantity; i += 1) {
|
||||
purchaseItem(user, item, price, type, key);
|
||||
|
||||
Reference in New Issue
Block a user