From f4bf2df4a9ed17af80233a06c4e1e4b7f67af941 Mon Sep 17 00:00:00 2001 From: negue Date: Thu, 28 Sep 2017 01:06:07 +0200 Subject: [PATCH] fortify potion + fix pinning check (#9089) --- website/client/components/shops/market/index.vue | 5 ++++- website/client/store/actions/shops.js | 12 ++++++++++-- website/common/script/libs/getItemInfo.js | 14 ++++++++++++++ website/common/script/ops/pinnedGearUtils.js | 11 ++++++----- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/website/client/components/shops/market/index.vue b/website/client/components/shops/market/index.vue index 8d9f78ef8d..0714f1c437 100644 --- a/website/client/components/shops/market/index.vue +++ b/website/client/components/shops/market/index.vue @@ -485,7 +485,10 @@ export default { }), }); - let specialItems = []; + let specialItems = [{ + ...getItemInfo(this.user, 'fortify'), + showCount: false, + }]; if (this.user.purchased.plan.customerId) { let gemItem = getItemInfo(this.user, 'gem'); diff --git a/website/client/store/actions/shops.js b/website/client/store/actions/shops.js index 59fb6ed867..f3c3e3ed2f 100644 --- a/website/client/store/actions/shops.js +++ b/website/client/store/actions/shops.js @@ -7,6 +7,7 @@ import hourglassPurchaseOp from 'common/script/ops/hourglassPurchase'; import sellOp from 'common/script/ops/sell'; import unlockOp from 'common/script/ops/unlock'; import buyArmoire from 'common/script/ops/buyArmoire'; +import rerollOp from 'common/script/ops/reroll'; export function buyItem (store, params) { const user = store.state.user.data; @@ -87,6 +88,15 @@ export function genericPurchase (store, params) { axios.post('/api/v3/user/buy-armoire'); return; + case 'fortify': { + let rerollResult = rerollOp(store.state.user.data); + + axios.post('/api/v3/user/reroll'); + + return rerollResult; + } + case 'rebirth_orb': + return store.dispatch('user:rebirth'); case 'potion': case 'marketGear': return buyItem(store, params); @@ -99,8 +109,6 @@ export function genericPurchase (store, params) { default: if (params.pinType === 'quests' && params.currency === 'gold') { return buyQuestItem(store, params); - } else if (params.key === 'rebirth_orb') { - return store.dispatch('user:rebirth'); } else if (params.currency === 'hourglasses') { return purchaseHourglassItem(store, params); } else { diff --git a/website/common/script/libs/getItemInfo.js b/website/common/script/libs/getItemInfo.js index 37f466c3af..f44c67af17 100644 --- a/website/common/script/libs/getItemInfo.js +++ b/website/common/script/libs/getItemInfo.js @@ -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) { diff --git a/website/common/script/ops/pinnedGearUtils.js b/website/common/script/ops/pinnedGearUtils.js index 2725b2ed69..9aa0e2eef7 100644 --- a/website/common/script/ops/pinnedGearUtils.js +++ b/website/common/script/ops/pinnedGearUtils.js @@ -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;