fortify potion + fix pinning check (#9089)

This commit is contained in:
negue
2017-09-28 01:06:07 +02:00
committed by Keith Holliday
parent ee6ceecc35
commit f4bf2df4a9
4 changed files with 34 additions and 8 deletions
+14
View File
@@ -299,6 +299,20 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
};
break;
}
case 'fortify': {
itemInfo = {
key: 'fortify',
purchaseType: 'fortify',
class: 'inventory_special_fortify',
text: i18n.t('fortifyName'),
notes: i18n.t('fortifyPop'),
value: 4,
currency: 'gems',
path: 'special.fortify',
pinType: 'fortify',
};
break;
}
}
if (itemInfo) {
+6 -5
View File
@@ -116,28 +116,31 @@ function removePinnedItemsByOwnedGear (user) {
});
}
const PATHS_WITHOUT_ITEM = ['special.gems', 'special.rebirth_orb', 'special.fortify'];
/**
* @returns {boolean} TRUE added the item / FALSE removed it
*/
function togglePinnedItem (user, {item, type, path}, req = {}) {
let arrayToChange;
let officialPinnedItems = getOfficialPinnedItems(user);
if (!path) {
// If path isn't passed it means an item was passed
path = getItemInfo(user, type, item, req.language).path;
path = getItemInfo(user, type, item, officialPinnedItems, req.language).path;
} else {
if (!item) {
item = get(content, path);
}
if (!item) {
if (!item && PATHS_WITHOUT_ITEM.indexOf(path) === -1) {
// path not exists in our content structure
throw new BadRequest(i18n.t('wrongItemPath', {path}, req.language));
}
// check if item exists & valid to be pinned
getItemInfo(user, type, item, req.language);
getItemInfo(user, type, item, officialPinnedItems, req.language);
}
@@ -145,8 +148,6 @@ function togglePinnedItem (user, {item, type, path}, req = {}) {
throw new BadRequest(i18n.t('cannotUnpinArmoirPotion', req.language));
}
let officialPinnedItems = getOfficialPinnedItems(user);
let isOfficialPinned = officialPinnedItems.find(officialPinnedItem => {
return officialPinnedItem.path === path;
}) !== undefined;